fix: al canviar de pantalla lateralment, es resetejava la altura de salt i el jugador caia

This commit is contained in:
2025-11-19 22:52:31 +01:00
parent 28f11a42b7
commit 7d962ae752

View File

@@ -85,6 +85,7 @@ void Player::move(float delta_time) {
#ifdef _DEBUG
Debug::get()->add(std::string("X : " + std::to_string(static_cast<int>(x_))));
Debug::get()->add(std::string("Y : " + std::to_string(static_cast<int>(y_))));
Debug::get()->add(std::string("LGP: " + std::to_string(static_cast<int>(last_grounded_position_))));
#endif
}
@@ -393,11 +394,15 @@ void Player::switchBorders() {
switch (border_) {
case Room::Border::TOP:
y_ = PLAY_AREA_BOTTOM - HEIGHT - TILE_SIZE;
// CRÍTICO: Resetear last_grounded_position_ para evitar muerte falsa por diferencia de Y entre pantallas
last_grounded_position_ = static_cast<int>(y_);
transitionToState(State::ON_GROUND); // TODO: Detectar si debe ser ON_SLOPE
break;
case Room::Border::BOTTOM:
y_ = PLAY_AREA_TOP;
// CRÍTICO: Resetear last_grounded_position_ para evitar muerte falsa por diferencia de Y entre pantallas
last_grounded_position_ = static_cast<int>(y_);
transitionToState(State::ON_GROUND); // TODO: Detectar si debe ser ON_SLOPE
break;
@@ -413,8 +418,6 @@ void Player::switchBorders() {
break;
}
// CRÍTICO: Resetear last_grounded_position_ para evitar muerte falsa por diferencia de Y entre pantallas
last_grounded_position_ = static_cast<int>(y_);
is_on_border_ = false;
placeSprite();
}