corregit bug en el modo invulnerable si caies de molt alt, es quedava marcat com mort i al llevar la invulnerabilitat, moria

This commit is contained in:
2025-11-21 23:14:40 +01:00
parent ec3cc49710
commit 6052be0c38
3 changed files with 31 additions and 3 deletions

View File

@@ -86,6 +86,20 @@ void Player::move(float delta_time) {
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(last_grounded_position_)));
switch (state_) {
case State::ON_GROUND:
Debug::get()->add(std::string("ON_GROUND"));
break;
case State::ON_SLOPE:
Debug::get()->add(std::string("ON_SLOPE"));
break;
case State::JUMPING:
Debug::get()->add(std::string("JUMPING"));
break;
case State::FALLING:
Debug::get()->add(std::string("FALLING"));
break;
}
#endif
}
@@ -179,6 +193,7 @@ void Player::updateOnGround(float delta_time) {
void Player::updateOnSlope(float delta_time) {
(void)delta_time; // No usado en este método, pero se mantiene por consistencia
handleShouldFall();
// NOTA: No llamamos handleShouldFall() aquí porque moveOnSlope() ya maneja
// todas las condiciones de salida de la rampa (out of bounds, transición a superficie plana)
@@ -757,6 +772,10 @@ void Player::placeSprite() {
// Gestiona la muerta al ccaer desde muy alto
void Player::handleDeathByFalling() {
if (Options::cheats.invincible == Options::Cheat::State::ENABLED) {
return;
}
const int FALL_DISTANCE = static_cast<int>(y_) - last_grounded_position_;
if (previous_state_ == State::FALLING && FALL_DISTANCE > MAX_FALLING_HEIGHT) {
is_alive_ = false; // Muere si cae más de 32 píxeles
@@ -901,8 +920,8 @@ void Player::setDebugPosition(float x, float y) {
void Player::finalizeDebugTeleport() {
vx_ = 0.0F;
vy_ = 0.0F;
state_ = State::ON_GROUND;
last_grounded_position_ = static_cast<int>(y_);
transitionToState(State::ON_GROUND);
syncSpriteAndCollider();
}
#endif