diff --git a/source/player.cpp b/source/player.cpp index 1e0dba2..4dd518b 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -219,7 +219,6 @@ void Player::move() vx = 0.0f; } - // Mueve en el eje Y y comprueba colisiones con muros y += vy; if (checkMapCollisions()) @@ -238,8 +237,8 @@ void Player::move() vy = 0.0f; } - // Si no hay colisiones con los muros en el eje Y, comprueba no haya atravesado - // el suelo de un tile atravesble + // Si no hay colisiones con los muros en el eje Y, comprueba + // no haya atravesado el suelo de un tile atravesble else { const int a = (lastPosition.y + h) / tileSize; @@ -265,16 +264,22 @@ void Player::move() } } + const bool going_down2 = vy >= 0.0f; + const bool tile_aligned2 = ((int)y + h) % tileSize == 0; // Si está cayendo - if (vy >= 0.0f) + if (going_down2) { state = falling; - - if (isOnFloor()) + // Si está alineado con el tile mira el suelo (para que no lo mire si está + // dentro de un tile atravesable y lo deje a medias) + if (tile_aligned2) { - state = standing; + if (isOnFloor()) + { + state = standing; + } } - + // Si no esta enganchado a una plataforma if (hookedOnMovingPlatform == -1) {