From 6052be0c3819c362d78567226a656eab7ae9a16a Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Fri, 21 Nov 2025 23:14:40 +0100 Subject: [PATCH] corregit bug en el modo invulnerable si caies de molt alt, es quedava marcat com mort i al llevar la invulnerabilitat, moria --- source/core/system/director.cpp | 2 ++ source/game/entities/player.cpp | 21 ++++++++++++++++++++- source/game/scenes/game.cpp | 11 +++++++++-- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/source/core/system/director.cpp b/source/core/system/director.cpp index 5948052..25f2796 100644 --- a/source/core/system/director.cpp +++ b/source/core/system/director.cpp @@ -151,6 +151,8 @@ Director::Director(std::vector const& args) { Debug::init(); #endif + std::cout << "\n"; // Fin de inicialización de sistemas + // Special handling for cheevos.bin - also needs filesystem path #ifdef RELEASE_BUILD std::string cheevos_path = system_folder_ + "/cheevos.bin"; diff --git a/source/game/entities/player.cpp b/source/game/entities/player.cpp index cc43f52..ce2db9e 100644 --- a/source/game/entities/player.cpp +++ b/source/game/entities/player.cpp @@ -86,6 +86,20 @@ void Player::move(float delta_time) { Debug::get()->add(std::string("X : " + std::to_string(static_cast(x_)))); Debug::get()->add(std::string("Y : " + std::to_string(static_cast(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(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(y_); + transitionToState(State::ON_GROUND); syncSpriteAndCollider(); } #endif \ No newline at end of file diff --git a/source/game/scenes/game.cpp b/source/game/scenes/game.cpp index 7a548c7..f1abde7 100644 --- a/source/game/scenes/game.cpp +++ b/source/game/scenes/game.cpp @@ -473,10 +473,15 @@ void Game::handleDebugMouseDrag(float delta_time) { float game_x = render_x - dst_rect.x; 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 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 SDL_FRect player_rect = player_->getRect(); float player_x = player_rect.x; @@ -501,6 +506,8 @@ void Game::handleDebugMouseDrag(float delta_time) { } debug_dragging_player_ = true; + Debug::get()->add(std::string("X : " + std::to_string(static_cast(player_rect.x)))); + Debug::get()->add(std::string("Y : " + std::to_string(static_cast(player_rect.y)))); } else if (debug_dragging_player_) { // Botón soltado después de arrastrar: finalizar teleport player_->finalizeDebugTeleport();