summary refs log tree commit diff stats
path: root/src/game.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-05-17 15:55:37 -0400
committerGitHub <noreply@github.com>2018-05-17 15:55:37 -0400
commit90aadf3844386824140a20d7fbb847bc16009a94 (patch)
tree6f83fce90e71abb22b1a8f3e09c79963b2a34d5d /src/game.h
parentbc63fa57ced1c7329f7fdcfd168eaf7e290158bc (diff)
parent86f0106d0523825549f1e74b835688c78a10cf6c (diff)
downloadtherapy-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.h89
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
11class Entity;
12struct GLFWwindow;
13
14struct Savefile {
15 const Map* map;
16 std::pair<double, double> position;
17};
18 8
19class Game { 9class Game {
20 public: 10public:
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
43private:
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 */