-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.cpp
59 lines (50 loc) · 829 Bytes
/
game.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
#include "game.h"
Game::Game()
{
InitVariables();
InitWindow();
}
Game::~Game()
{
delete this->window;
}
void Game::InitVariables()
{
endgame = false;
}
void Game::InitWindow()
{
this->window = new sf::RenderWindow(sf::VideoMode(1024, 768), "RaZPoNG", sf::Style::Close | sf::Style::Titlebar);
}
const bool Game::isRunning() const
{
return this->window->isOpen();
}
void Game::PollEvents()
{
while (this->window->pollEvent(this->event))
{
switch (this->event.type)
{
case sf::Event::Closed:
this->window->close();
break;
case sf::Event::KeyPressed:
if (this->event.key.code == sf::Keyboard::Escape)
this->window->close();
break;
default:
break;
}
}
}
void Game::Update()
{
PollEvents();
}
void Game::Render()
{
this->window->clear();
// DRAW
this->window->display();
}