-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.cpp
More file actions
executable file
·78 lines (55 loc) · 1.46 KB
/
Game.cpp
File metadata and controls
executable file
·78 lines (55 loc) · 1.46 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
// Created by segalle on 02/11/2021.
//
#include "Game.h"
Game::Game() : window(WINDOW_WIDTH, WINDOW_HEIGHT), assets(), sprite_loader(), menu(), p1(), p2(), player_menu(){
Being::setAssetManager(&assets);
Being::setWindowManager(&window);
sprite_loader.run();
menu.initialize();
player_menu.initialize();
level_menu.initialize(&p1, &p2);
end_game.initialize();
leader_board.initialize();
}
Game::~Game() {
}
void Game::run() {
while (window.isOpen()){
window.clear();
if (window.pollEvent(&event) && event.type == sf::Event::Closed){
window.close();
break;
}
switch (Being::getMenuState(0)) {
case st_global_menu:
menu.run();
break;
case st_player_menu:
player_menu.run();
break;
case st_level_menu:
level_menu.run();
break;
case st_end_game:
end_game.run();
resetPlayers();
break;
case st_leader_board:
leader_board.run();
break;
case st_quit_game:
window.close();
break;
}
window.display();
}
}
void Game::resetPlayers(){
p1.setHealth(100);
p2.setHealth(100);
p1.setScore(0);
p1.setIsAlive(true);
p2.setIsAlive(true);
}
sf::Event Game::event = sf::Event();