-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGameActivity.h
65 lines (54 loc) · 1.75 KB
/
GameActivity.h
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
#ifndef GAMEACTIVITY_H_INCLUDED
#define GAMEACTIVITY_H_INCLUDED
#include "../scenes/Intro/Intro.h"
#include "../scenes/MainMenu/MainMenu.h"
#include "../scenes/LevelEditor/LevelEditor.h"
// example
// #include "../scenes/YourScene/YourScene.h"
////////////////////////////////////////////////////////////
/// Allows to manage the different scenes of the game
////////////////////////////////////////////////////////////
class GameActivity
{
private:
std::shared_ptr<is::GameDisplay> m_gameScene;
public:
bool m_changeActivity = false;
GameActivity(is::GameSystemExtended &gameSysExt)
{
m_gameScene = nullptr;
////////////////////////////////////////////////////////////
// Allows to choose the scene that will be launched
switch (gameSysExt.m_launchOption)
{
case is::DisplayOption::INTRO:
m_gameScene = std::make_shared<Intro>(gameSysExt);
break;
case is::DisplayOption::MAIN_MENU:
m_gameScene = std::make_shared<MainMenu>(gameSysExt);
break;
case is::DisplayOption::LEVEL_EDITOR:
m_gameScene = std::make_shared<LevelEditor>(gameSysExt);
break;
// example
// case is::DisplayOption::YOUR_SCENE:
// m_gameScene = std::make_shared<YourScene>(gameSysExt);
// break;
default:
is::showLog("ERROR: Scene not found !", true);
break;
}
m_gameScene->loadResources();
}
virtual void onUpdate()
{
if (m_gameScene->getIsRunning()) m_gameScene->step();
else
{
if (!m_changeActivity) m_changeActivity = true;
}
}
virtual void onDraw() {m_gameScene->drawScreen();}
virtual ~GameActivity() {}
};
#endif // GAMEACTIVITY_H_INCLUDED