diff options
Diffstat (limited to 'src/game.h')
-rw-r--r-- | src/game.h | 89 |
1 files changed, 48 insertions, 41 deletions
diff --git a/src/game.h b/src/game.h index dd4b2f7..d7fdcd7 100644 --- a/src/game.h +++ b/src/game.h | |||
@@ -1,45 +1,52 @@ | |||
1 | #ifndef GAME_H | 1 | #ifndef GAME_H_1014DDC9 |
2 | #define GAME_H | 2 | #define GAME_H_1014DDC9 |
3 | 3 | ||
4 | #include <memory> | 4 | #include <random> |
5 | #include <functional> | 5 | #include "entity_manager.h" |
6 | #include <list> | 6 | #include "system_manager.h" |
7 | #include <map> | 7 | #include "renderer/renderer.h" |
8 | #include "map.h" | ||
9 | #include "world.h" | ||
10 | |||
11 | class Entity; | ||
12 | struct GLFWwindow; | ||
13 | |||
14 | struct Savefile { | ||
15 | const Map* map; | ||
16 | std::pair<double, double> position; | ||
17 | }; | ||
18 | 8 | ||
19 | class Game { | 9 | class Game { |
20 | public: | 10 | public: |
21 | Game(const char* maps); | 11 | |
22 | void execute(GLFWwindow* window); | 12 | Game(std::mt19937& rng); |
23 | void loadMap(const Map& map, std::pair<double, double> position); | 13 | |
24 | void detectCollision(Entity& collider, std::pair<double, double> old_position); | 14 | void execute(); |
25 | void saveGame(); | 15 | |
26 | void schedule(double time, std::function<void ()> callback); | 16 | inline std::mt19937& getRng() |
27 | void playerDie(); | 17 | { |
28 | const World& getWorld() const; | 18 | return rng_; |
29 | 19 | } | |
30 | private: | 20 | |
31 | friend void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods); | 21 | inline Renderer& getRenderer() |
32 | 22 | { | |
33 | std::list<std::shared_ptr<Entity>> entities; | 23 | return renderer_; |
34 | std::list<std::shared_ptr<Entity>> nextEntities; | 24 | } |
35 | std::pair<double, double> nextPosition; | 25 | |
36 | bool newWorld; | 26 | inline EntityManager& getEntityManager() |
37 | std::shared_ptr<Entity> player; | 27 | { |
38 | const Map* currentMap; | 28 | return entityManager_; |
39 | Savefile save; | 29 | } |
40 | std::list<std::pair<double, std::function<void ()>>> scheduled; | 30 | |
41 | bool shouldQuit = false; | 31 | inline SystemManager& getSystemManager() |
42 | World world; | 32 | { |
33 | return systemManager_; | ||
34 | } | ||
35 | |||
36 | friend void key_callback( | ||
37 | GLFWwindow* window, | ||
38 | int key, | ||
39 | int scancode, | ||
40 | int action, | ||
41 | int mods); | ||
42 | |||
43 | private: | ||
44 | |||
45 | std::mt19937 rng_; | ||
46 | Renderer renderer_; | ||
47 | SystemManager systemManager_; | ||
48 | EntityManager entityManager_; | ||
49 | bool shouldQuit_ = false; | ||
43 | }; | 50 | }; |
44 | 51 | ||
45 | #endif | 52 | #endif /* end of include guard: GAME_H_1014DDC9 */ |