aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Core/Game.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-07-28 13:47:51 +0800
committerchai <chaifix@163.com>2018-07-28 13:47:51 +0800
commitd033400614e7e2c0ff49e5100c81e937e5818e74 (patch)
tree82e011222e9d88b3f7dff239aefae4a2c100fef4 /src/libjin/Core/Game.h
parent7b7a510321112978090575e89c3dabeba9ea9f97 (diff)
*update
Diffstat (limited to 'src/libjin/Core/Game.h')
-rw-r--r--src/libjin/Core/Game.h58
1 files changed, 26 insertions, 32 deletions
diff --git a/src/libjin/Core/Game.h b/src/libjin/Core/Game.h
index becb780..e9d0340 100644
--- a/src/libjin/Core/Game.h
+++ b/src/libjin/Core/Game.h
@@ -1,40 +1,35 @@
#ifndef __JIN_CORE_GAME_H
#define __JIN_CORE_GAME_H
-#include <SDL2/SDL.h>
+#include "SDL2/SDL.h"
-#include "../common/singleton.h"
+#include "../Common/Subsystem.hpp"
#include "../utils/macros.h"
+#include "../Input/Event.h"
namespace jin
{
namespace core
{
- class Game : public Singleton<Game>
+
+ class Game : public Subsystem<Game>
{
public:
- struct Setting
- {
+ typedef void(*onEvent)(jin::input::Event* e);
+ typedef void(*onUpdate)(float dt);
+ typedef void(*onDraw)();
- };
-
- inline void quit()
+ struct Setting : SettingBase
{
- CALLONCE(_quit());
- }
-
- inline bool running()
- {
- return run;
- }
-
- inline void exit()
- {
- CALLONCE(_exit());
- }
+ onEvent eventHandler;
+ onUpdate updater;
+ onDraw drawer;
+ };
void run();
+ inline void stop() { _running = false; };
+ bool running() { return _running; };
private:
@@ -43,19 +38,18 @@ namespace core
SINGLETON(Game);
- bool _run;
+ onEvent _onEvent;
+ onUpdate _onUpdate;
+ onDraw _onDraw;
- inline void _exit()
- {
- SDL_Quit();
- }
+ bool _running;
+
+ onlyonce bool initSystem(const SettingBase* setting);
+ onlyonce void quitSystem();
- inline void _quit()
- {
- _run = false;
- }
};
-}
-}
-#endif \ No newline at end of file
+} // core
+} // jin
+
+#endif // __JIN_CORE_GAME_H \ No newline at end of file