#ifndef GAME_H #define GAME_H #include #include #include "renderer.h" #include class Entity; class Map; const int TILE_WIDTH = 8; const int TILE_HEIGHT = 8; const int GAME_WIDTH = 320; const int GAME_HEIGHT = 200; const int MAP_WIDTH = GAME_WIDTH/TILE_WIDTH; const int MAP_HEIGHT = GAME_HEIGHT/TILE_HEIGHT - 1; const int FRAMES_PER_SECOND = 60; const double SECONDS_PER_FRAME = 1.0 / FRAMES_PER_SECOND; struct Savefile { const Map* map; std::pair position; }; class Game { public: Game(); void execute(GLFWwindow* window); void loadMap(const Map& map, std::pair position); void detectCollision(Entity& collider, std::pair old_position); void saveGame(); void schedule(double time, std::function callback); void playerDie(); private: friend void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods); std::list> entities; std::list> nextEntities; std::pair nextPosition; bool newWorld; std::shared_ptr player; const Map* currentMap; Savefile save; std::list>> scheduled; bool shouldQuit = false; }; #endif