-
Notifications
You must be signed in to change notification settings - Fork 0
/
MenuLoop.cpp
45 lines (29 loc) · 989 Bytes
/
MenuLoop.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
#include "MenuLoop.h"
#include "Graphic.h"
#include "Game.h"
using namespace std;
using namespace sf;
MenuLoop::MenuLoop(int sizeX, int sizeY, vector<Vector2i> moves) {
size = Vector2i (sizeX, sizeY);
window.create(sf::VideoMode(sizeX * 32,sizeY * 32), "Maze Random Generator");
this->moves = moves;
}
MenuLoop::~MenuLoop()=default;
void MenuLoop::generateScreen() {
Graphic graphic(new Game(window, moves, size));
times = seconds(10);
while (window.isOpen()) {
while (window.pollEvent(event)) {
graphic.setInput(event, window);
}
if (!graphic.getState()) {
if (times.asSeconds() > 0.5) {
window.clear();
graphic.draw(window);
window.display();
clock.restart(); //puts the time counter back to zero
}
times=clock.getElapsedTime(); //returns the time elapsed since the last call to restart()
}
}
}