-
Notifications
You must be signed in to change notification settings - Fork 0
/
moteur.cpp
executable file
·101 lines (87 loc) · 1.6 KB
/
moteur.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include "moteur.h"
Moteur::Moteur()
{
jeu = new Jeu(this);
quitter = false;
state = IN_GAME;
game_over = NULL;
menu = NULL;
}
Moteur::~Moteur()
{
if (game_over != NULL)
delete game_over;
if (menu != NULL)
delete menu;
delete jeu;
}
bool Moteur::init()
{
if (!jeu->init())
return false;
return true;
}
void Moteur::affiche(SDL_Surface * screen)
{
jeu->affiche(screen);
if (state == IN_MENU)
menu->affiche(screen);
else if (state == IN_GAMEOVER)
game_over->affiche(screen);
else;
}
void Moteur::gereScene()
{
if (state == IN_GAME)
jeu->gereScene();
else;
}
void Moteur::gereTouche(int touche)
{
if (state == IN_GAME)
jeu->gereTouche(touche);
else if (state == IN_MENU)
menu->gereTouche(touche);
else if (state == IN_GAMEOVER)
game_over->gereTouche(touche);
else;
}
int Moteur::getLvl()
{
return jeu->getLvl();
}
void Moteur::openGameOver()
{
state = IN_GAMEOVER;
game_over = new GameOver(this);
}
void Moteur::openMenu()
{
state = IN_MENU;
menu = new Menu(this);
}
void Moteur::quitMenu()
{
state = IN_GAME;
if (menu != NULL)
{
delete menu;
menu = NULL;
}
}
void Moteur::restartJeu()
{
if (game_over != NULL)
{
delete game_over;
game_over = NULL;
}
if (menu != NULL)
{
delete menu;
menu = NULL;
}
delete jeu;
jeu = new Jeu(this);
state = IN_GAME;
}