diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-03-18 09:48:43 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-03-18 09:48:43 -0400 |
commit | 2ec163612042bfa5e4e1bf220b489506f7039677 (patch) | |
tree | ead735eb871c3faf813635d08a89ec48195dab35 /src/game.h | |
parent | dc0f0d6fa178403080658887af3ca1a6c0e41188 (diff) | |
download | therapy-2ec163612042bfa5e4e1bf220b489506f7039677.tar.gz therapy-2ec163612042bfa5e4e1bf220b489506f7039677.tar.bz2 therapy-2ec163612042bfa5e4e1bf220b489506f7039677.zip |
Game can now read map file from map editor (also added new map)
Diffstat (limited to 'src/game.h')
-rw-r--r-- | src/game.h | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/game.h b/src/game.h index 1818cec..3f0fcc8 100644 --- a/src/game.h +++ b/src/game.h | |||
@@ -3,21 +3,12 @@ | |||
3 | 3 | ||
4 | #include <memory> | 4 | #include <memory> |
5 | #include <functional> | 5 | #include <functional> |
6 | #include "renderer.h" | ||
7 | #include <list> | 6 | #include <list> |
7 | #include <map> | ||
8 | #include "map.h" | ||
8 | 9 | ||
9 | class Entity; | 10 | class Entity; |
10 | class Map; | 11 | struct GLFWwindow; |
11 | |||
12 | const int TILE_WIDTH = 8; | ||
13 | const int TILE_HEIGHT = 8; | ||
14 | const int GAME_WIDTH = 320; | ||
15 | const int GAME_HEIGHT = 200; | ||
16 | const int MAP_WIDTH = GAME_WIDTH/TILE_WIDTH; | ||
17 | const int MAP_HEIGHT = GAME_HEIGHT/TILE_HEIGHT - 1; | ||
18 | |||
19 | const int FRAMES_PER_SECOND = 60; | ||
20 | const double SECONDS_PER_FRAME = 1.0 / FRAMES_PER_SECOND; | ||
21 | 12 | ||
22 | struct Savefile { | 13 | struct Savefile { |
23 | const Map* map; | 14 | const Map* map; |
@@ -26,17 +17,21 @@ struct Savefile { | |||
26 | 17 | ||
27 | class Game { | 18 | class Game { |
28 | public: | 19 | public: |
29 | Game(); | 20 | Game(const char* maps); |
30 | void execute(GLFWwindow* window); | 21 | void execute(GLFWwindow* window); |
31 | void loadMap(const Map& map, std::pair<double, double> position); | 22 | void loadMap(const Map& map, std::pair<double, double> position); |
32 | void detectCollision(Entity& collider, std::pair<double, double> old_position); | 23 | void detectCollision(Entity& collider, std::pair<double, double> old_position); |
33 | void saveGame(); | 24 | void saveGame(); |
34 | void schedule(double time, std::function<void ()> callback); | 25 | void schedule(double time, std::function<void ()> callback); |
35 | void playerDie(); | 26 | void playerDie(); |
27 | const Map& getMap(int id) const; | ||
36 | 28 | ||
37 | private: | 29 | private: |
38 | friend void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods); | 30 | friend void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods); |
39 | 31 | ||
32 | std::map<int, Map> maps; | ||
33 | int startMap; | ||
34 | std::pair<int, int> startPos; | ||
40 | std::list<std::shared_ptr<Entity>> entities; | 35 | std::list<std::shared_ptr<Entity>> entities; |
41 | std::list<std::shared_ptr<Entity>> nextEntities; | 36 | std::list<std::shared_ptr<Entity>> nextEntities; |
42 | std::pair<double, double> nextPosition; | 37 | std::pair<double, double> nextPosition; |