summary refs log tree commit diff stats
path: root/src/game.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.h')
-rw-r--r--src/game.h21
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
9class Entity; 10class Entity;
10class Map; 11struct GLFWwindow;
11
12const int TILE_WIDTH = 8;
13const int TILE_HEIGHT = 8;
14const int GAME_WIDTH = 320;
15const int GAME_HEIGHT = 200;
16const int MAP_WIDTH = GAME_WIDTH/TILE_WIDTH;
17const int MAP_HEIGHT = GAME_HEIGHT/TILE_HEIGHT - 1;
18
19const int FRAMES_PER_SECOND = 60;
20const double SECONDS_PER_FRAME = 1.0 / FRAMES_PER_SECOND;
21 12
22struct Savefile { 13struct Savefile {
23 const Map* map; 14 const Map* map;
@@ -26,17 +17,21 @@ struct Savefile {
26 17
27class Game { 18class 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;