From 6b1dcc5df51df4a2d8b724187eb1bcdb4fd9df8b Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 14 Mar 2015 19:25:23 -0400 Subject: Added sound when you hit the ground Also split up components.cpp into files for each class, fixed a bug concerning falling off the screen when you change maps, and converted collision data into doubles. --- src/game.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index 6e79f75..20b8564 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1,9 +1,12 @@ #include "game.h" #include "renderer.h" -#include "components.h" #include "muxer.h" -#include "entityfactory.h" #include "map.h" +#include "components/user_movement.h" +#include "components/player_physics.h" +#include "components/player_sprite.h" +#include "components/map_render.h" +#include "components/map_collision.h" Game::Game() { @@ -23,7 +26,7 @@ Game::Game() Map& startingMap = Map::getNamedMap("embarass"); save = {&startingMap, player->position}; - loadMap(startingMap); + loadMap(startingMap, player->position); } void key_callback(GLFWwindow* window, int key, int, int action, int) @@ -65,6 +68,8 @@ void Game::execute(GLFWwindow* window) newWorld = false; entities.clear(); entities = std::move(nextEntities); + + player->position = nextPosition; } // Handle input @@ -106,7 +111,7 @@ void Game::execute(GLFWwindow* window) } } -void Game::loadMap(const Map& map) +void Game::loadMap(const Map& map, std::pair position) { auto mapEn = std::make_shared(); @@ -125,6 +130,7 @@ void Game::loadMap(const Map& map) newWorld = true; currentMap = ↦ + nextPosition = position; } void Game::detectCollision(Entity& collider, std::pair old_position) @@ -154,10 +160,11 @@ void Game::playerDie() schedule(0.75, [&] () { if (*currentMap != *save.map) { - loadMap(*save.map); + loadMap(*save.map, save.position); + } else { + player->position = save.position; } - player->position = save.position; player->send(*this, Message::Type::stopDying); }); } -- cgit 1.4.1