blob: f3a056db555cbf76381b8af280d44c00137916e4 (
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
53
54
55
56
57
58
59
60
|
/** ---------------------------------------------------------------------------
* @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/core.h"
#include "space.h"
namespace yage
{
Engine::~Engine()
{
quit();
}
void Engine::init()
{
yage::init();
window_.create("Game Engine", 800, 640);
}
void Engine::mainLoop()
{
while (!window_.shouldClose()) {
window_.pollEvents();
window_.clearBuffer();
update();
window_.swapBuffer();
}
}
void Engine::update()
{
for (auto &space : spaces_) {
space->update();
}
}
void Engine::addSpace(std::unique_ptr<Space> space)
{
spaces_.push_back(std::move(space));
}
Engine &Engine::instance()
{
static Engine engine_instance;
return engine_instance;
}
} // namespace yage
|