blob: 5e8b3e58c85b12553d723f705b2ae93a0214b92a (
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
61
62
63
64
|
#include <engine.hpp>
#include <config.hpp>
#include <world.hpp>
#include <window.hpp>
#include <ui.hpp>
#include <inventory.hpp>
#include <components.hpp>
#include <player.hpp>
extern World *currentWorld;
Engine::Engine(void)
: shouldRun(true), systems(game::entities, game::events)
{
}
void Engine::init(void) {
game::config::read();
game::events.subscribe<GameEndEvent>(*this);
systems.add<WindowSystem>();
systems.add<RenderSystem>();
systems.add<InputSystem>();
systems.add<InventorySystem>();
systems.add<WorldSystem>();
systems.add<PlayerSystem>();
systems.add<PhysicsSystem>();
systems.add<MovementSystem>();
systems.add<DialogSystem>();
systems.configure();
game::config::update();
getSystem<PlayerSystem>()->create();
}
void Engine::render(entityx::TimeDelta dt)
{
systems.update<RenderSystem>(dt);
systems.update<WindowSystem>(dt);
systems.update<InventorySystem>(dt);
ui::fadeUpdate();
}
void Engine::update(entityx::TimeDelta dt)
{
systems.update<InputSystem>(dt);
systems.update<MovementSystem>(dt);
systems.update<DialogSystem>(dt);
systems.update<WorldSystem>(dt);
systems.update<PlayerSystem>(dt);
}
namespace game {
entityx::EventManager events;
entityx::EntityManager entities (events);
SpriteLoader sprite_l;
Engine engine;
}
|