From b6cbc65a2ab075e1504692a474e793098003ba27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Valor=20Mart=C3=ADnez?= Date: Sun, 28 Aug 2022 07:30:13 +0200 Subject: [PATCH] =?UTF-8?q?corregido=20un=20bug=20en=20la=20ca=C3=ADda=20d?= =?UTF-8?q?el=20personaje?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/player.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) 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) {