43 lines
847 B
C++
43 lines
847 B
C++
#ifndef GAME_SCENE_H
|
|
#define GAME_SCENE_H
|
|
|
|
#include "../graphics/Rect.h"
|
|
|
|
class Scene {
|
|
public:
|
|
virtual ~Scene() = default;
|
|
virtual void run() = 0;
|
|
virtual void enter() = 0;
|
|
virtual void exit() = 0;
|
|
|
|
protected:
|
|
Scene() = default;
|
|
};
|
|
|
|
|
|
namespace Scenes {
|
|
enum SceneId {
|
|
IntroScene,
|
|
MainMenuScene,
|
|
GameScene,
|
|
};
|
|
|
|
extern SceneId currentSceneId;
|
|
extern Scene *sceneList[];
|
|
|
|
inline SceneId setScene(SceneId scene) {
|
|
auto previousSceneId = currentSceneId;
|
|
sceneList[currentSceneId]->exit();
|
|
currentSceneId = scene;
|
|
sceneList[currentSceneId]->enter();
|
|
return previousSceneId;
|
|
}
|
|
|
|
inline Scene *getCurrentScene() { return sceneList[currentSceneId]; }
|
|
inline SceneId getCurrentSceneId() { return currentSceneId; }
|
|
|
|
}
|
|
|
|
|
|
#endif //GAME_SCENE_H
|