diff options
Diffstat (limited to 'src/libjin/game/application.h')
-rw-r--r-- | src/libjin/game/application.h | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src/libjin/game/application.h b/src/libjin/game/application.h new file mode 100644 index 0000000..4c4f48b --- /dev/null +++ b/src/libjin/game/application.h @@ -0,0 +1,84 @@ +#ifndef __JE_CORE_GAME_H__ +#define __JE_CORE_GAME_H__ + +#include "../core/configuration.h" +#if defined(jin_game) + +#include "../common/subsystem.hpp" +#include "../utils/macros.h" +#include "../input/Event.h" + +#include "SDL2/SDL.h" + +namespace JinEngine +{ + namespace Game + { + + /// + /// Game class. + /// + class Application : public Subsystem<Application> + { + public: + typedef void(*onLoad)(); + typedef void(*onEvent)(JinEngine::Input::Event* e); + typedef void(*onUpdate)(int dt); + typedef void(*onDraw)(); + + Application(); + ~Application() {}; + + /// + /// Game setting. + /// + struct Setting : SettingBase + { + onEvent eventHandler; + onUpdate updater; + onDraw drawer; + onLoad loader; + }; + + /// + /// Main game loop. + /// + void run(); + + /// + /// Stop game. + /// + inline void stop() + { + _running = false; + }; + + /// + /// Return if game is running. + /// + /// @return True if game is running, otherwise return false. + /// + inline bool running() + { + return _running; + }; + + private: + onEvent _onEvent; + onUpdate _onUpdate; + onDraw _onDraw; + onLoad _onLoad; + + bool _running; + + bool startSystem(const SettingBase* setting); + void quitSystem(); + + }; + + } // namespace Core +} // namespace JinEngine + +#endif // jin_game + +#endif // __JE_CORE_GAME_H__
\ No newline at end of file |