From 73008992e0d01f148858f48959daedda4b6e6948 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Thu, 20 Mar 2025 13:37:17 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20no=20actualitzava=20correctament=20la=20?= =?UTF-8?q?caixa=20de=20colisions=20del=20jugador=20al=20canviar=20d'habit?= =?UTF-8?q?aci=C3=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/player.cpp | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/source/player.cpp b/source/player.cpp index c00a1a97..e494bf11 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -202,26 +202,34 @@ void Player::checkState() // Cambia al jugador de un borde al opuesto. Util para el cambio de pantalla void Player::switchBorders() { - if (border_ == BORDER_TOP) + switch (border_) { - y_ = PLAY_AREA_BOTTOM - HEIGHT_ - 0 - BLOCK; + case BORDER_TOP: + y_ = PLAY_AREA_BOTTOM - HEIGHT_ - BLOCK; setState(PlayerState::STANDING); - } - else if (border_ == BORDER_BOTTOM) - { - y_ = PLAY_AREA_TOP + 0; + break; + + case BORDER_BOTTOM: + y_ = PLAY_AREA_TOP; setState(PlayerState::STANDING); - } - else if (border_ == BORDER_RIGHT) - { - x_ = PLAY_AREA_LEFT + 0; - } - if (border_ == BORDER_LEFT) - { - x_ = PLAY_AREA_RIGHT - WIDTH_ - 0; + break; + + case BORDER_RIGHT: + x_ = PLAY_AREA_LEFT; + break; + + case BORDER_LEFT: + x_ = PLAY_AREA_RIGHT - WIDTH_; + break; + + default: + // Manejo para casos no previstos (opcional) + break; } is_on_border_ = false; + placeSprite(); + collider_box_ = getRect(); } // Aplica gravedad al jugador