From da5d88062696353598c126f914dceb7f21d54373 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Tue, 7 Apr 2026 20:58:37 +0200 Subject: [PATCH] slopes solides i a cagar --- data/room/01.yaml | 19 ++++----- data/room/03.yaml | 55 ++++++++++++------------- data/tilesets/collision.gif | Bin 415 -> 436 bytes source/game/entities/player.cpp | 19 +++++---- source/game/gameplay/room.cpp | 1 - source/game/gameplay/tile_collider.cpp | 25 +++++------ source/game/scenes/game.cpp | 19 ++++++--- source/game/scenes/game.hpp | 2 +- 8 files changed, 73 insertions(+), 67 deletions(-) diff --git a/data/room/01.yaml b/data/room/01.yaml index 6200e17..12e7a07 100644 --- a/data/room/01.yaml +++ b/data/room/01.yaml @@ -1,6 +1,5 @@ room: bgColor: 1 - border: 0 tileSetFile: standard.gif # Conexiones de la habitación (null = sin conexión) @@ -36,11 +35,11 @@ tilemap: - [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 116, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] - [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 116, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] - [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 116, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] - - [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 545, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] - - [26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 545, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] - - [26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 545, -1, -1, -1, -1, -1, -1, -1, -1, -1] - - [26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 303, 303, -1, -1, -1, -1, -1, -1, -1] - - [26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 534, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 186, 534, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 186, 186, 534, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 186, 186, 186, 186, 186, 534, -1, -1, -1, -1, -1, -1] + - [26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 186, 186, 186, 186, 186, 186, 534, -1, -1, -1, -1, -1] - [51, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] # Mapa de colisiones (0 = vacio, 1 = solido) collision: @@ -60,10 +59,10 @@ tilemap: - [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,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/data/room/03.yaml index 4698cd0..4d2fcf0 100644 --- a/data/room/03.yaml +++ b/data/room/03.yaml @@ -1,6 +1,5 @@ room: bgColor: 34 - border: 0 tileSetFile: standard.gif # Conexiones de la habitación (null = sin conexión) @@ -25,22 +24,22 @@ tilemap: - [48, 50, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] - - [0, 2, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, -1, -1, -1, -1, -1, 504, 6, 7, 7, 7, 7, 7, 24, 26] - - [24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 504, -1, -1, -1, -1, -1, -1, -1, 24, 26] - - [24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 504, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] - - [24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 504, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] - - [24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 504, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] - - [24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 504, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] - - [24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 504, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] - - [24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 504, -1, -1, 307, 307, 307, 307, -1, -1, -1, -1, -1, -1, -1, 24, 26] - - [24, 26, -1, -1, -1, -1, -1, -1, -1, 6, 7, 7, 7, 7, 7, 8, -1, -1, -1, -1, -1, 305, 305, -1, -1, -1, -1, -1, -1, -1, 24, 26] + - [0, 2, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, -1, -1, 510, 186, 7, 7, 7, 7, 7, 24, 26] + - [24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 510, 186, -1, -1, -1, -1, -1, -1, 24, 26] + - [24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 510, 186, -1, -1, -1, -1, -1, -1, -1, 24, 26] + - [24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 510, 186, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] + - [24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 510, 186, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] + - [24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 510, 186, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] + - [24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 510, 186, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] + - [24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 510, 186, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] + - [24, 26, -1, -1, -1, -1, -1, -1, -1, 266, 266, 266, 266, 266, 266, 186, 186, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] - [24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] - - [24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 2, -1, -1, 307, 307, -1, -1, -1, -1, -1, -1, -1, 24, 26] - - [48, 50, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 48, 50, 329, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] - - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] - - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] - - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, -1, -1, -1, -1, -1, 24, 26] - - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 25, 25, 26, -1, -1, -1, -1, -1, 24, 26] + - [24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] + - [48, 50, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] + - [-1, -1, -1, -1, -1, -1, -1, 169, 169, 169, 169, 169, 169, 169, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] + - [-1, -1, -1, -1, -1, -1, -1, -1, 168, 168, 168, 168, 168, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] + - [-1, -1, -1, -1, -1, -1, -1, -1, 168, -1, 168, -1, 168, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, 2, -1, -1, -1, -1, -1, 24, 26] + - [-1, -1, -1, -1, -1, -1, -1, -1, 168, 168, 168, 168, 168, -1, -1, -1, -1, -1, -1, -1, -1, 24, 25, 25, 26, -1, -1, -1, -1, -1, 24, 26] - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 53, 25, 25, 51, 555, 555, 555, 555, 555, 53, 51] # Mapa de colisiones (0 = vacio, 1 = solido) collision: @@ -48,19 +47,19 @@ tilemap: - [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1] - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1] - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1] - - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 4, 1, 1, 1, 1, 1, 1, 1, 1] - - [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 1, 1] + - [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1] + - [0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1] - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1] - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1] - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1] diff --git a/data/tilesets/collision.gif b/data/tilesets/collision.gif index 07802bb29f59add5b937ba208268b8001bc34397..a9242bf43c9040d98d4a985b3a91b2b26c7ce81c 100644 GIT binary patch delta 247 zcmVXOC)aY;16ZbRR2xDtLN)dps|Lgo2r)hKh%ajF6COlWvu9mzifPDgm5* zpM9ZxfuW^++Ed7gfy)#)q3 xiQ21Y-O1m~oAyrj_f&m)=(Oy=EVav4j0_SaOqfVn_{548E)cVLnK&^B06XiZalQZm delta 210 zcmV;@04@Kt1D^v2M@dFFH(@}L2gfG=3rocPaslbdPj-bBL06AD3QVfl8Z&p^Kk# zi&Kt|r*f&Nte3A~gPftir;DO+j&+qQl)cZbf5NfEXN%cR7}?rXbaBmzzG}dINJvaf MSy@(A>sUbmI~9Odng9R* diff --git a/source/game/entities/player.cpp b/source/game/entities/player.cpp index 7e00373..43b0ef4 100644 --- a/source/game/entities/player.cpp +++ b/source/game/entities/player.cpp @@ -181,14 +181,6 @@ void Player::handleJumpAndDrop() { return; } - // Drop-through: slope - if (wanna_down_ && state_ == State::ON_SLOPE) { - y_ += 1.0F; - vy_ = 0.0F; - transitionToState(State::ON_AIR); - return; - } - // Drop-through: plataforma passable if (wanna_down_ && state_ == State::ON_GROUND) { auto [tc, ox, oy] = getCollisionContext(); @@ -399,6 +391,17 @@ void Player::checkFalling() { // ON_GROUND: comprobar si sigue habiendo suelo float foot_y = (y_ + oy) + HEIGHT; if (!tc.hasGroundBelow(x_ + ox, foot_y, WIDTH)) { + // Sticking: si no hay suelo pero hay slope debajo, snapear a ella + // para transición suave suelo→slope (bajada de rampas sin caer) + auto slope = tc.checkSlopeBelow(x_ + ox, foot_y, WIDTH); + if (slope.on_slope) { + y_ = slope.surface_y - HEIGHT - oy; + slope_tile_x_ = slope.tile_x; + slope_tile_y_ = slope.tile_y; + slope_type_ = slope.type; + transitionToState(State::ON_SLOPE); + return; + } vy_ = 0.0F; transitionToState(State::ON_AIR); } diff --git a/source/game/gameplay/room.cpp b/source/game/gameplay/room.cpp index 4845925..7a1ca20 100644 --- a/source/game/gameplay/room.cpp +++ b/source/game/gameplay/room.cpp @@ -31,7 +31,6 @@ Room::Room(const std::string& room_path, std::shared_ptr data) // Crea el renderizador del tilemap (necesita tile_map_, tile_set_width_, surface_, bg_color_, conveyor_belt_direction_) tilemap_renderer_ = std::make_unique(tile_map_, tile_set_width_, surface_, bg_color_, conveyor_belt_direction_); tilemap_renderer_->initialize(room->collision_tile_map); - } // Destructor diff --git a/source/game/gameplay/tile_collider.cpp b/source/game/gameplay/tile_collider.cpp index 6bf008f..71ecd1f 100644 --- a/source/game/gameplay/tile_collider.cpp +++ b/source/game/gameplay/tile_collider.cpp @@ -81,7 +81,9 @@ auto TileCollider::checkCeiling(float x, float y, float w) const -> float { int right_col = toTile(static_cast(x + w - 1)); for (int col = left_col; col <= right_col; ++col) { - if (isSolid(col, top_row)) { + auto tile = getTileAt(col, top_row); + // Slopes actúan como techo (no se atraviesan desde abajo) + if (tile == Tile::WALL || tile == Tile::SLOPE_L || tile == Tile::SLOPE_R) { return static_cast((top_row + 1) * TS); } } @@ -93,9 +95,7 @@ auto TileCollider::checkCeiling(float x, float y, float w) const -> float { // Busca suelo entre foot_y_current y foot_y_new (rango de caída del frame). // WALL: siempre bloquea. // PASSABLE: solo si los pies estaban por encima del borde superior del tile. -// SLOPE: solo si los pies estaban por encima de la superficie Y el jugador no está -// parcialmente dentro de otra slope (evita aterrizar al hacer drop-through -// o al saltar a través de una slope desde abajo). +// SLOPE: siempre bloquea (las slopes son sólidas, como muros en diagonal). // NOLINTNEXTLINE(readability-function-cognitive-complexity) auto TileCollider::checkFloor(float x, float foot_y_current, float w, float foot_y_new) const -> FloorHit { int start_row = toTile(static_cast(foot_y_current)); @@ -103,9 +103,6 @@ auto TileCollider::checkFloor(float x, float foot_y_current, float w, float foot int left_col = toTile(static_cast(x)); int right_col = toTile(static_cast(x + w - 1)); - // Si algún pie está por debajo de la superficie de algún slope → bloquear aterrizaje en slopes - bool block_slope_landing = isInsideAnySlope(x, foot_y_current, w); - FloorHit best; for (int row = start_row; row <= end_row; ++row) { @@ -121,11 +118,11 @@ auto TileCollider::checkFloor(float x, float foot_y_current, float w, float foot if (foot_y_current <= tile_top) { floor_y = tile_top; } - } else if (!block_slope_landing && (tile == Tile::SLOPE_L || tile == Tile::SLOPE_R)) { + } else if (tile == Tile::SLOPE_L || tile == Tile::SLOPE_R) { float check_x = (tile == Tile::SLOPE_L) ? x : x + w - 1; float slope_y = getSlopeY(col, row, check_x); - // Solo aterrizar si los pies estaban por encima de la superficie - if (foot_y_new >= slope_y && foot_y_current <= slope_y) { + // Slopes son sólidas: aterrizar siempre que los pies lleguen a la superficie + if (foot_y_new >= slope_y) { floor_y = slope_y; } } @@ -204,15 +201,15 @@ auto TileCollider::checkSlopeBelow(float x, float foot_y, float w) const -> Slop for (int col = left_col; col <= right_col; ++col) { auto tile = getTileAt(col, row); if (tile == Tile::SLOPE_L) { - float foot_x = (col == left_col) ? x : x + w - 1; - float slope_y = getSlopeY(col, row, foot_x); + // SLOPE_L (\): alta a la izquierda → siempre pie izquierdo + float slope_y = getSlopeY(col, row, x); if (slope_y <= foot_y && slope_y >= foot_y - TS) { return {.on_slope = true, .type = Tile::SLOPE_L, .tile_x = col, .tile_y = row, .surface_y = slope_y}; } } if (tile == Tile::SLOPE_R) { - float foot_x = (col == right_col) ? x + w - 1 : x; - float slope_y = getSlopeY(col, row, foot_x); + // SLOPE_R (/): alta a la derecha → siempre pie derecho + float slope_y = getSlopeY(col, row, x + w - 1); if (slope_y <= foot_y && slope_y >= foot_y - TS) { return {.on_slope = true, .type = Tile::SLOPE_R, .tile_x = col, .tile_y = row, .surface_y = slope_y}; } diff --git a/source/game/scenes/game.cpp b/source/game/scenes/game.cpp index 8f61908..b2b633e 100644 --- a/source/game/scenes/game.cpp +++ b/source/game/scenes/game.cpp @@ -821,11 +821,20 @@ void Game::checkPlayerIsOnBorder() { // La dirección es la opuesta: si salimos por TOP, la vieja queda en BOTTOM Room::Border opposite = Room::Border::NONE; switch (BORDER) { - case Room::Border::TOP: opposite = Room::Border::BOTTOM; break; - case Room::Border::BOTTOM: opposite = Room::Border::TOP; break; - case Room::Border::LEFT: opposite = Room::Border::RIGHT; break; - case Room::Border::RIGHT: opposite = Room::Border::LEFT; break; - default: break; + case Room::Border::TOP: + opposite = Room::Border::BOTTOM; + break; + case Room::Border::BOTTOM: + opposite = Room::Border::TOP; + break; + case Room::Border::LEFT: + opposite = Room::Border::RIGHT; + break; + case Room::Border::RIGHT: + opposite = Room::Border::LEFT; + break; + default: + break; } player_->setAdjacentRoom(transition_old_room_, opposite); diff --git a/source/game/scenes/game.hpp b/source/game/scenes/game.hpp index 4878795..6a4890d 100644 --- a/source/game/scenes/game.hpp +++ b/source/game/scenes/game.hpp @@ -110,7 +110,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 - bool transition_just_ended_{false}; // Cooldown de 1 frame tras finalizar transición + bool transition_just_ended_{false}; // Cooldown de 1 frame tras finalizar transición // Variables de demo mode DemoData demo_; // Variables para el modo demo