-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSceneManager.cpp
More file actions
100 lines (76 loc) · 1.85 KB
/
SceneManager.cpp
File metadata and controls
100 lines (76 loc) · 1.85 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "SceneManager.h"
#include "settings.h"
SceneManager::SceneManager() : _background(stg::StarAmount, 20, 100)
{
_currentScene = &_menu;
Init();
}
void SceneManager::Init()
{
_background.Init();
_currentScene->Init();
}
void SceneManager::SwitchScene(Scene& scene)
{
_currentScene = &scene;
_currentScene->Init();
}
void SceneManager::Update()
{
int scoreDiff{ 0 };
SceneID currentSceneName = _currentScene->GetSceneName();
if (currentSceneName != Jeu)
_background.Update({ stg::screenWidth / 2.0f , stg::screenHeight / 2.0f });
_currentScene->Update();
switch (currentSceneName)
{
case Menu:
// Commencer une partie
if (_menu.IsSceneSwitching())
SwitchScene(_jeu);
break;
case Jeu:
// Mettre le jeu en pause
if (IsKeyPressed(KEY_ESCAPE))
SwitchScene(_pause);
// Vérifier si quelqu'un a gagné
// _gameover.SetScore(scoreDiff);
// SwitchScene(_gameover);
break;
case Pause:
if (_pause.IsSceneSwitching() == Nothing)
break;
if (_pause.IsSceneSwitching() == Resume) // Reprendre la partie
_currentScene = &_jeu;
else if (_pause.IsSceneSwitching() == Reset) // Recommencer la partie
SwitchScene(_jeu);
else if (_pause.IsSceneSwitching() == Quit) // Retourner au menu
SwitchScene(_menu);
break;
case PartieFinie:
if (_gameover.IsSceneSwitching() == Nothing)
break;
if (_gameover.IsSceneSwitching() == Reset) // Reprendre la partie
SwitchScene(_jeu);
else if (_gameover.IsSceneSwitching() == Quit) // Recommencer la partie
SwitchScene(_menu);
break;
default:
break;
}
}
void SceneManager::Draw()
{
ClearBackground(BLACK);
SceneID currentSceneName = _currentScene->GetSceneName();
if (currentSceneName != Jeu)
_background.Draw();
_currentScene->Draw();
}
//if (_jeu.playerDeath() > 0) // Joueur 1 gagne
//{
//
//}
//else if (_jeu.playerDeath() < 0) // Joueur 2 gagne
//{
//}