diff options
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; |
