aboutsummaryrefslogtreecommitdiffstats
path: root/yage/engine/engine.cpp
blob: 3918e7e9183621f3dbbd55fc4fa955b49615c94f (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
47
48
49
50
51
52
/** ---------------------------------------------------------------------------
 * @file: engine.cpp
 *
 * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
 * MIT License, see LICENSE file for more details.
 * ----------------------------------------------------------------------------
 */

#include "engine.h"

#include "../core/window.h"

namespace yage
{

void Engine::mainLoop()
{
    Window window;

    window.create("Game Engine", 800, 640);

    while(!window.shouldClose()) {
        window.clearBuffer();

        update();

        window.swapBuffer();
    }
}

void Engine::update()
{
    const double dt = 1.0 / 60.0;

    for(auto &&system : systems_) {
        system->update(dt);
    }
}

void Engine::addSystem(System *system)
{
    systems_.push_back(system);
}

Engine &Engine::instance()
{
    static Engine engine_instance;

    return engine_instance;
}

} // namespace yage