summary refs log tree commit diff stats
path: root/src/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/game.cpp b/src/game.cpp index cbbae06..e392923 100644 --- a/src/game.cpp +++ b/src/game.cpp
@@ -20,6 +20,8 @@ Game::Game()
20 auto player_anim = std::make_shared<PlayerSpriteComponent>(); 20 auto player_anim = std::make_shared<PlayerSpriteComponent>();
21 player->addComponent(player_anim); 21 player->addComponent(player_anim);
22 22
23 save = {&m, player->position};
24
23 loadMap(m); 25 loadMap(m);
24} 26}
25 27
@@ -87,7 +89,7 @@ void Game::execute(GLFWwindow* window)
87 } 89 }
88} 90}
89 91
90void Game::loadMap(Map& map) 92void Game::loadMap(const Map& map)
91{ 93{
92 auto mapEn = std::make_shared<Entity>(); 94 auto mapEn = std::make_shared<Entity>();
93 95
@@ -111,3 +113,18 @@ void Game::detectCollision(Entity& collider, std::pair<double, double> old_posit
111 entity->detectCollision(*this, collider, old_position); 113 entity->detectCollision(*this, collider, old_position);
112 } 114 }
113} 115}
116
117void Game::saveGame(const Map& map, std::pair<double, double> position)
118{
119 save = {&map, position};
120}
121
122void Game::loadGame(const Map& curMap)
123{
124 if (&curMap != save.map)
125 {
126 loadMap(*(save.map));
127 }
128
129 player->position = save.position;
130}