blob: dd4b2f793b2964184677818e0c0870558970fd03 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#ifndef GAME_H
#define GAME_H
#include <memory>
#include <functional>
#include <list>
#include <map>
#include "map.h"
#include "world.h"
class Entity;
struct GLFWwindow;
struct Savefile {
const Map* map;
std::pair<double, double> position;
};
class Game {
public:
Game(const char* maps);
void execute(GLFWwindow* window);
void loadMap(const Map& map, std::pair<double, double> position);
void detectCollision(Entity& collider, std::pair<double, double> old_position);
void saveGame();
void schedule(double time, std::function<void ()> callback);
void playerDie();
const World& getWorld() const;
private:
friend void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods);
std::list<std::shared_ptr<Entity>> entities;
std::list<std::shared_ptr<Entity>> nextEntities;
std::pair<double, double> nextPosition;
bool newWorld;
std::shared_ptr<Entity> player;
const Map* currentMap;
Savefile save;
std::list<std::pair<double, std::function<void ()>>> scheduled;
bool shouldQuit = false;
World world;
};
#endif
|