diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-03-10 19:42:04 -0400 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2015-03-10 19:42:04 -0400 |
| commit | 0e0389752a0912614737e5c059b5cd4719ef9cf2 (patch) | |
| tree | fc39e676bd819ee973f27fc40150a7874d2f8503 /src/game.cpp | |
| parent | 7f0e8c7ef70c62814c274f110367db92f01cbb26 (diff) | |
| download | therapy-0e0389752a0912614737e5c059b5cd4719ef9cf2.tar.gz therapy-0e0389752a0912614737e5c059b5cd4719ef9cf2.tar.bz2 therapy-0e0389752a0912614737e5c059b5cd4719ef9cf2.zip | |
Const correctness!
Also created savefile and refactored collisions a bit.
Diffstat (limited to 'src/game.cpp')
| -rw-r--r-- | src/game.cpp | 19 |
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 | ||
| 90 | void Game::loadMap(Map& map) | 92 | void 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 | |||
| 117 | void Game::saveGame(const Map& map, std::pair<double, double> position) | ||
| 118 | { | ||
| 119 | save = {&map, position}; | ||
| 120 | } | ||
| 121 | |||
| 122 | void Game::loadGame(const Map& curMap) | ||
| 123 | { | ||
| 124 | if (&curMap != save.map) | ||
| 125 | { | ||
| 126 | loadMap(*(save.map)); | ||
| 127 | } | ||
| 128 | |||
| 129 | player->position = save.position; | ||
| 130 | } | ||
