-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathGameActivity.h
64 lines (52 loc) · 1.72 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
#ifndef GAMEACTIVITY_H_INCLUDED
#define GAMEACTIVITY_H_INCLUDED
#include "../scenes/HelloScene/HelloScene.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::HELLO_SCENE:
m_gameScene = std::make_shared<HelloScene>(gameSysExt);
break;
/*
* /!\ WARNING! /!\
* This constructor is no longer supported in this version of the engine. Use the one in the example.
*
* m_gameScene = std::make_shared<YourScene>(activityCtrl.getWindow(), getView(), m_surface, gameSysExt);
*/
// 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