diff options
author | chai <chaifix@163.com> | 2018-10-23 12:23:58 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-10-23 12:23:58 +0800 |
commit | 40fc27154fe754181934dc7ee31375e6bdfb33fc (patch) | |
tree | 897ad98d759bc308ef66561181ba88b85f2ccd47 /src/libjin/Core/Game.cpp | |
parent | 1480c9445100075c9e1a894eb07c0ef727b509a1 (diff) |
*merge from minimal
Diffstat (limited to 'src/libjin/Core/Game.cpp')
-rw-r--r-- | src/libjin/Core/Game.cpp | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/src/libjin/Core/Game.cpp b/src/libjin/Core/Game.cpp deleted file mode 100644 index b480b12..0000000 --- a/src/libjin/Core/Game.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "game.h" -#include "../Time/Timer.h" -#include "../input/Event.h" -#include "../Graphics/Window.h" -#include "../Math/Math.h" -#include <iostream> - -namespace jin -{ -namespace core -{ - - using namespace jin::graphics; - using namespace jin::input; - using namespace jin::time; - using namespace jin::math; - - Game::Game() :_running(true) {}; - - void Game::run() - { - SAFECALL(_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 previous = getMilliSecond(); - int dt = MS_PER_UPDATE; - while (_running) - { - while (jin::input::pollEvent(&e)) - { - SAFECALL(_onEvent, &e); - if (!_running) goto quitloop; - } - SAFECALL(_onUpdate, dt); - SAFECALL(_onDraw); - wnd->swapBuffers(); - const int current = getMilliSecond(); - dt = current - previous; - const int wait = MS_PER_UPDATE - (current - previous); - previous += MS_PER_UPDATE; - if (wait > 0) - { - sleep(wait); - dt = MS_PER_UPDATE; - } - else - previous = current; - } - 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; - } - - void Game::quitSystem() - { - } - -} // core -} // jin
\ No newline at end of file |