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

@@ -151,6 +151,8 @@ Director::Director(std::vector<std::string> const& args) {
Debug::init(); Debug::init();
#endif #endif
std::cout << "\n"; // Fin de inicialización de sistemas
// Special handling for cheevos.bin - also needs filesystem path // Special handling for cheevos.bin - also needs filesystem path
#ifdef RELEASE_BUILD #ifdef RELEASE_BUILD
std::string cheevos_path = system_folder_ + "/cheevos.bin"; std::string cheevos_path = system_folder_ + "/cheevos.bin";

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("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("Y : " + std::to_string(static_cast<int>(y_))));
Debug::get()->add(std::string("LGP: " + std::to_string(last_grounded_position_))); 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 #endif
} }
@@ -179,6 +193,7 @@ void Player::updateOnGround(float delta_time) {
void Player::updateOnSlope(float delta_time) { void Player::updateOnSlope(float delta_time) {
(void)delta_time; // No usado en este método, pero se mantiene por consistencia (void)delta_time; // No usado en este método, pero se mantiene por consistencia
handleShouldFall();
// NOTA: No llamamos handleShouldFall() aquí porque moveOnSlope() ya maneja // 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) // 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 // Gestiona la muerta al ccaer desde muy alto
void Player::handleDeathByFalling() { void Player::handleDeathByFalling() {
if (Options::cheats.invincible == Options::Cheat::State::ENABLED) {
return;
}
const int FALL_DISTANCE = static_cast<int>(y_) - last_grounded_position_; const int FALL_DISTANCE = static_cast<int>(y_) - last_grounded_position_;
if (previous_state_ == State::FALLING && FALL_DISTANCE > MAX_FALLING_HEIGHT) { if (previous_state_ == State::FALLING && FALL_DISTANCE > MAX_FALLING_HEIGHT) {
is_alive_ = false; // Muere si cae más de 32 píxeles 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() { void Player::finalizeDebugTeleport() {
vx_ = 0.0F; vx_ = 0.0F;
vy_ = 0.0F; vy_ = 0.0F;
state_ = State::ON_GROUND;
last_grounded_position_ = static_cast<int>(y_); last_grounded_position_ = static_cast<int>(y_);
transitionToState(State::ON_GROUND);
syncSpriteAndCollider(); syncSpriteAndCollider();
} }
#endif #endif

View File

@@ -473,10 +473,15 @@ void Game::handleDebugMouseDrag(float delta_time) {
float game_x = render_x - dst_rect.x; float game_x = render_x - dst_rect.x;
float game_y = render_y - dst_rect.y; float game_y = render_y - dst_rect.y;
// Verificar si el botón izquierdo está presionado // Verificar si los botones están presionados
bool left_button_pressed = (buttons & SDL_BUTTON_LMASK) != 0; bool left_button_pressed = (buttons & SDL_BUTTON_LMASK) != 0;
bool right_button_pressed = (buttons & SDL_BUTTON_RMASK) != 0;
if (left_button_pressed) { // Botón derecho: teleport instantáneo a la posición del cursor
if (right_button_pressed && !debug_dragging_player_) {
player_->setDebugPosition(game_x, game_y);
player_->finalizeDebugTeleport();
} else if (left_button_pressed) {
// Obtener posición actual del jugador // Obtener posición actual del jugador
SDL_FRect player_rect = player_->getRect(); SDL_FRect player_rect = player_->getRect();
float player_x = player_rect.x; float player_x = player_rect.x;
@@ -501,6 +506,8 @@ void Game::handleDebugMouseDrag(float delta_time) {
} }
debug_dragging_player_ = true; debug_dragging_player_ = true;
Debug::get()->add(std::string("X : " + std::to_string(static_cast<int>(player_rect.x))));
Debug::get()->add(std::string("Y : " + std::to_string(static_cast<int>(player_rect.y))));
} else if (debug_dragging_player_) { } else if (debug_dragging_player_) {
// Botón soltado después de arrastrar: finalizar teleport // Botón soltado después de arrastrar: finalizar teleport
player_->finalizeDebugTeleport(); player_->finalizeDebugTeleport();