From d033400614e7e2c0ff49e5100c81e937e5818e74 Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 28 Jul 2018 13:47:51 +0800 Subject: *update --- src/libjin/core/game.cpp | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'src/libjin/core/game.cpp') 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 -- cgit v1.1-26-g67d0