blob: 2bde6de2b95129dfef90151f773da9d43cfe8c83 (
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
|
#ifndef ENGINE_HPP_
#define ENGINE_HPP_
#include <entityx/entityx.h>
#include <events.hpp>
class Engine : public entityx::Receiver<Engine> {
private:
bool gameRunning;
public:
entityx::SystemManager systems;
explicit Engine(void);
void init(void);
void render(entityx::TimeDelta dt);
void update(entityx::TimeDelta dt);
template<typename T>
inline T* getSystem(void) {
return dynamic_cast<T*>(systems.system<T>().get());
}
/*void configure(entityx::EventManager &ev) {
(void)ev;
}*/
inline void receive(const GameEndEvent &gee) {
gameRunning = !(gee.really);
}
inline bool shouldRun(void) const {
return gameRunning;
}
};
namespace game {
extern entityx::EventManager events;
extern entityx::EntityManager entities;
extern Engine engine;
inline void endGame(void) {
events.emit<GameEndEvent>();
}
}
#endif // ENGINE_HPP_
|