aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Core/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/Core/game.cpp')
-rw-r--r--src/libjin/Core/game.cpp74
1 files changed, 0 insertions, 74 deletions
diff --git a/src/libjin/Core/game.cpp b/src/libjin/Core/game.cpp
deleted file mode 100644
index 3f905f2..0000000
--- a/src/libjin/Core/game.cpp
+++ /dev/null
@@ -1,74 +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()
- {
- 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 previous = getMilliSecond();
- int dt = MS_PER_UPDATE;
- while (_running)
- {
- while (jin::input::pollEvent(&e))
- {
- if (_onEvent != nullptr)
- _onEvent(&e);
- if (!_running) goto quitloop;
- }
- if (_onUpdate != nullptr) _onUpdate(dt);
- if (_onDraw != nullptr) _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