-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.cpp
50 lines (43 loc) · 1.12 KB
/
main.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
#include "gamescene.h"
#include <SFML/Graphics.hpp>
void handleEvents(sf::RenderWindow& window)
{
sf::Event event;
while (window.pollEvent(event))
{
// Кнопка закрытия окна
if (event.type == sf::Event::Closed)
{
window.close();
}
}
}
void update(sf::Clock& clock, GameScene& scene)
{
const float elapsedTime = clock.getElapsedTime().asSeconds();
clock.restart();
updateGameScene(scene, elapsedTime);
}
void render(sf::RenderWindow& window, const GameScene& scene)
{
window.clear();
drawGameScene(window, scene);
window.display();
}
int main(int, char* [])
{
sf::ContextSettings settings;
settings.antialiasingLevel = 4;
sf::RenderWindow window(sf::VideoMode(800, 800), "PacMan Game Clone", sf::Style::Close, settings);
sf::Clock clock;
GameScene scene;
initializeGameScene(scene, sf::Vector2f(window.getSize()));
while (window.isOpen())
{
handleEvents(window);
update(clock, scene);
window.setTitle(getGameSceneWindowTitle(scene));
render(window, scene);
}
return 0;
}