diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-05-17 15:55:37 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-17 15:55:37 -0400 |
| commit | 90aadf3844386824140a20d7fbb847bc16009a94 (patch) | |
| tree | 6f83fce90e71abb22b1a8f3e09c79963b2a34d5d /src/game.h | |
| parent | bc63fa57ced1c7329f7fdcfd168eaf7e290158bc (diff) | |
| parent | 86f0106d0523825549f1e74b835688c78a10cf6c (diff) | |
| download | therapy-90aadf3844386824140a20d7fbb847bc16009a94.tar.gz therapy-90aadf3844386824140a20d7fbb847bc16009a94.tar.bz2 therapy-90aadf3844386824140a20d7fbb847bc16009a94.zip | |
Merge pull request #7 from hatkirby/es-rewrite
The ECS rewrite exceeds the original branch in functionality, so it is time to merge it in.
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 */ |
