aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine.cpp
blob: e53a68844acdd1aa0ca077b73a5a7feec24e39a1 (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
#include <engine.hpp>

#include <config.hpp>
#include <world.hpp>
#include <ui.hpp>
//#include <inventory.hpp>
#include <window.hpp>
#include <components.hpp>

extern World *currentWorld;

Engine::Engine(void)
    : gameRunning(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<MovementSystem>();	
//    systems.add<PlayerSystem>(&player);

    systems.configure();

	game::config::update();
}

void Engine::render(entityx::TimeDelta dt)
{
    systems.update<RenderSystem>(dt);
	systems.update<WindowSystem>(dt);
	
}

void Engine::update(entityx::TimeDelta dt)
{
    systems.update<InputSystem>(dt);
//    systems.update<InventorySystem>(dt);
//    systems.update<PlayerSystem>(dt);
	systems.update<MovementSystem>(dt);
	systems.update<WorldSystem>(dt);
}


namespace game {
	entityx::EventManager events;
	entityx::EntityManager entities (events);
	SpriteLoader sprite_l;	

    Engine engine;
}