From e6eeb3396af320d9667d952ff46a9f6a63f8e7f6 Mon Sep 17 00:00:00 2001 From: Sergio Date: Tue, 7 Apr 2026 13:15:46 +0200 Subject: [PATCH] mes edge merdes --- source/game/scenes/game.cpp | 22 ++++++++++++++++++++++ source/game/scenes/game.hpp | 1 + 2 files changed, 23 insertions(+) diff --git a/source/game/scenes/game.cpp b/source/game/scenes/game.cpp index c9dc101..4d5761a 100644 --- a/source/game/scenes/game.cpp +++ b/source/game/scenes/game.cpp @@ -325,6 +325,26 @@ void Game::updatePlaying(float delta_time) { #else player_->update(delta_time); #endif + // Si durante una transición el jugador cruza de vuelta por el borde opuesto, + // abortar la transición y volver a la habitación anterior + if (transitioning_ && player_->isOnBorder()) { + const auto BORDER = player_->getBorder(); + const bool FELL_BACK = + (transition_direction_ == Room::Border::TOP && BORDER == Room::Border::BOTTOM) || + (transition_direction_ == Room::Border::BOTTOM && BORDER == Room::Border::TOP) || + (transition_direction_ == Room::Border::LEFT && BORDER == Room::Border::RIGHT) || + (transition_direction_ == Room::Border::RIGHT && BORDER == Room::Border::LEFT); + + if (FELL_BACK) { + room_ = transition_old_room_; + player_->setRoom(room_); + player_->switchBorders(); + spawn_data_ = player_->getSpawnParams(); + current_room_ = transition_old_room_path_; + setScoreBoardColor(); + endTransition(); + } + } checkPlayerIsOnBorder(); checkPlayerAndItems(); checkPlayerAndEnemies(); @@ -816,6 +836,7 @@ void Game::checkPlayerIsOnBorder() { // Guardar la habitación saliente transition_old_room_ = room_; + transition_old_room_path_ = current_room_; transition_direction_ = BORDER; // Crear nueva habitación y reposicionar jugador @@ -844,6 +865,7 @@ void Game::endTransition() { transition_just_ended_ = true; transition_timer_ = 0.0F; transition_old_room_.reset(); + transition_old_room_path_.clear(); transition_direction_ = Room::Border::NONE; Screen::get()->setRenderOffset(0, 0); } diff --git a/source/game/scenes/game.hpp b/source/game/scenes/game.hpp index 8e1ba3e..c262cfd 100644 --- a/source/game/scenes/game.hpp +++ b/source/game/scenes/game.hpp @@ -111,6 +111,7 @@ class Game { float transition_timer_{0.0F}; // Tiempo transcurrido en la transición std::shared_ptr transition_old_room_; // Habitación saliente (se mantiene viva durante la transición) Room::Border transition_direction_{Room::Border::NONE}; // Dirección de la transición + std::string transition_old_room_path_; // Path de la habitación saliente (para poder restaurarla) bool transition_just_ended_{false}; // Cooldown de 1 frame tras finalizar transición // Variables de demo mode