-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWindow.cpp
61 lines (48 loc) · 1.06 KB
/
Window.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// Created by Athos Innocenti on 30/10/2018.
//
#include "Window.h"
Window::Window() {
setup("Game", sf::Vector2u(400, 600));
}
Window::~Window() {
destroy();
};
Window::Window(const std::string &title, const sf::Vector2u &size) {
setup(title, size);
}
void Window::setup(const std::string &title, const sf::Vector2u &size) {
windowTitle = title;
windowSize = size;
done = false;
window.setFramerateLimit(30);
create();
}
void Window::update() {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
done = true;
}
}
void Window::create() {
window.create({windowSize.x, windowSize.y}, windowTitle);
}
void Window::destroy() {
window.close();
}
void Window::beginDraw() {
window.clear(sf::Color::White);
}
void Window::endDraw() {
window.display();
}
void Window::draw(sf::Drawable &drawable) {
window.draw(drawable);
}
sf::RenderWindow *Window::getRenderWindow() {
return &window;
}
sf::Vector2u Window::getWindowSize() {
return windowSize;
}