diff options
Diffstat (limited to 'src/libjin/Game/Game.cpp')
-rw-r--r-- | src/libjin/Game/Game.cpp | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/src/libjin/Game/Game.cpp b/src/libjin/Game/Game.cpp index 65baaaa..82597b7 100644 --- a/src/libjin/Game/Game.cpp +++ b/src/libjin/Game/Game.cpp @@ -7,66 +7,66 @@ namespace jin { -namespace core -{ + namespace core + { - using namespace jin::graphics; - using namespace jin::input; - using namespace jin::time; - using namespace jin::math; + using namespace jin::graphics; + using namespace jin::input; + using namespace jin::time; + using namespace jin::math; - Game::Game() :_running(true) {}; + Game::Game() :_running(true) {}; - /* default game loop */ - void Game::run() - { - if (_onLoad != nullptr) - _onLoad(); - Window* wnd = Window::get(); - const int FPS = wnd ? wnd->getFPS() : 60; - const int MS_PER_UPDATE = 1000.0f / FPS; - _running = true; - Event e; - int current = getMilliSecond(); - int previous = current; - int dt = 0; - while (_running) - { - while (jin::input::pollEvent(&e)) - { - if (_onEvent != nullptr) - _onEvent(&e); - if (!_running) - goto quitloop; - } - previous = current; - current = getMilliSecond(); - dt = current - previous; - if (_onUpdate != nullptr) - _onUpdate(dt); - if (_onDraw != nullptr) - _onDraw(); - wnd->swapBuffers(); - sleep(1); - } - quitloop:; - } + /* default game loop */ + void Game::run() + { + if (_onLoad != nullptr) + _onLoad(); + Window* wnd = Window::get(); + const int FPS = wnd ? wnd->getFPS() : 60; + const int MS_PER_UPDATE = 1000.0f / FPS; + _running = true; + Event e; + int current = getMilliSecond(); + int previous = current; + int dt = 0; + while (_running) + { + while (jin::input::pollEvent(&e)) + { + if (_onEvent != nullptr) + _onEvent(&e); + if (!_running) + goto quitloop; + } + previous = current; + current = getMilliSecond(); + dt = current - previous; + if (_onUpdate != nullptr) + _onUpdate(dt); + if (_onDraw != nullptr) + _onDraw(); + wnd->swapBuffers(); + sleep(1); + } + quitloop:; + } - 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; - _onLoad = s->loader; - return true; - } + 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; + _onLoad = s->loader; + return true; + } - void Game::quitSystem() - { - } + void Game::quitSystem() + { + } -} // core + } // core } // jin
\ No newline at end of file |