diff --git a/source/game.cpp b/source/game.cpp index d87d88dd..29282f66 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -7,6 +7,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input) clock = SDL_GetTicks(); currentRoom = "01.room"; spawnPoint = {2 * 8, 12 * 8, 0, 0, 0, s_standing, SDL_FLIP_NONE}; + spawnPoint = {154, 72, 0, 0, 0, s_standing, SDL_FLIP_NONE}; debug = true; // Copia los punteros diff --git a/source/player.cpp b/source/player.cpp index 20399304..a0fcfbdd 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -244,18 +244,20 @@ void Player::move() { // Bajando y -= ((int)y + h) % tileSize; state = s_standing; + vy = 0.0f; } else { // Subiendo y += tileSize - ((int)y % tileSize); state = s_falling; + vy = maxVY; } } else // Si no colisiona con los muros, haz comprobaciones extra { - const int a = (lastPosition.y + h) / tileSize; - const int b = ((int)y + h) / tileSize; + const int a = (lastPosition.y + h - 1) / tileSize; + const int b = ((int)y + h - 1) / tileSize; const bool tile_change = a != b; bool going_down = vy >= 0.0f; @@ -268,6 +270,7 @@ void Player::move() if (isOnFloor()) { // Y deja al jugador de pie state = s_standing; + vy = 0.0f; // Si ademas ha habido un cambio de tile recoloca al jugador if (tile_change) @@ -280,6 +283,7 @@ void Player::move() else if (state != s_jumping) { state = s_falling; + vy = maxVY; } } @@ -292,6 +296,7 @@ void Player::move() if (state != s_jumping) { state = s_falling; + vy = maxVY; } // Si está alineado con el tile mira el suelo (para que no lo mire si está @@ -301,6 +306,7 @@ void Player::move() if (isOnFloor()) { state = s_standing; + vy = 0.0f; } } } @@ -334,6 +340,7 @@ void Player::checkJumpEnd() if (y >= jump_ini) { state = s_falling; + vy = maxVY; } }