diff options
author | chai <chaifix@163.com> | 2018-07-28 13:47:51 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-07-28 13:47:51 +0800 |
commit | d033400614e7e2c0ff49e5100c81e937e5818e74 (patch) | |
tree | 82e011222e9d88b3f7dff239aefae4a2c100fef4 /src/libjin/Core/Game.cpp | |
parent | 7b7a510321112978090575e89c3dabeba9ea9f97 (diff) |
*update
Diffstat (limited to 'src/libjin/Core/Game.cpp')
-rw-r--r-- | src/libjin/Core/Game.cpp | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/libjin/Core/Game.cpp b/src/libjin/Core/Game.cpp index 2090d64..f2223b2 100644 --- a/src/libjin/Core/Game.cpp +++ b/src/libjin/Core/Game.cpp @@ -1,17 +1,46 @@ #include "game.h" +#include "../Time/Timer.h" +#include "../input/Event.h" namespace jin { namespace core { - Game::Game() :_run(true) {}; + using namespace jin::input; + + Game::Game() :_running(true) {}; void Game::run() { + _running = true; + Event e; + while (_running) + { + while (jin::input::pollEvent(&e)) + { + if (_instance != nullptr && _onEvent) + _onEvent(&e); + } + if (!_running) + break; + } + } + + bool Game::initSystem(const SettingBase* setting) + { + if (setting == nullptr) + return false; + Game::Setting* s = (Game::Setting*) setting; + _onEvent = s->eventHandler; + _onUpdate = s->updater; + _onDraw = s->drawer; + return true; + } + void Game::quitSystem() + { } - -} -} +} // core +} // jin
\ No newline at end of file |