aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Core/Game.cpp
blob: f2223b22e42e09174951c1a36fbb9da356fed0bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "game.h"
#include "../Time/Timer.h"
#include "../input/Event.h"

namespace jin
{
namespace core
{

    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