diff --git a/config/assets.yaml b/config/assets.yaml index 6fe37a8..e028739 100644 --- a/config/assets.yaml +++ b/config/assets.yaml @@ -75,6 +75,7 @@ assets: tilesets: BITMAP: - ${PREFIX}/data/tilesets/standard.gif + - ${PREFIX}/data/tilesets/collision.gif # ENEMIES enemies: diff --git a/data/console/commands.yaml b/data/console/commands.yaml index 921be06..e694af3 100644 --- a/data/console/commands.yaml +++ b/data/console/commands.yaml @@ -227,11 +227,11 @@ categories: - keyword: EDIT handler: cmd_edit description: "Map editor mode (GAME only)" - usage: "EDIT [ON|OFF|REVERT|SHOW|HIDE|MAPBG|MAPCONN] [...]" + usage: "EDIT [ON|OFF|REVERT|SHOW|HIDE|DRAW|COLLISION|MAPBG|MAPCONN] [...]" scope: [debug, editor] dynamic_completions: true completions: - EDIT: [ON, OFF, REVERT, SHOW, HIDE, MAPBG, MAPCONN] + EDIT: [ON, OFF, REVERT, SHOW, HIDE, DRAW, COLLISION, MAPBG, MAPCONN] EDIT SHOW: [INFO, GRID] EDIT HIDE: [INFO, GRID] diff --git a/data/room/01.yaml b/data/room/01.yaml index 4e1ea18..6200e17 100644 --- a/data/room/01.yaml +++ b/data/room/01.yaml @@ -18,29 +18,53 @@ room: conveyorBelt: none # Tilemap: 21 filas x 32 columnas @ 8px/tile -# Índices de tiles (-1 = vacío) tilemap: - - [191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191] - - [167, 165, 184, 166, 165, 184, 165, 165, 167, 165, 165, 166, 165, 165, 184, 165, 165, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 165] - - [210, 180, 210, 212, 210, 180, 210, 211, 212, 210, 180, 210, 210, 211, 210, 212, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42] - - [163, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 163, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42] - - [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42] - - [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264] - - [24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] - - [48, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 50, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] - - [33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 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, 8, -1, -1, -1, -1, -1, -1, -1, 116, 137, 138, -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] - - [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] - - [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 dibujo (indices de tiles, -1 = vacio) + draw: + - [191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191] + - [167, 165, 184, 166, 165, 184, 165, 165, 167, 165, 165, 166, 165, 165, 184, 165, 165, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 165] + - [210, 180, 210, 212, 210, 180, 210, 211, 212, 210, 180, 210, 210, 211, 210, 212, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42] + - [163, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 163, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42] + - [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42] + - [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264] + - [24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [48, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 50, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 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, 8, -1, -1, -1, -1, -1, -1, -1, 116, 137, 138, -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] + - [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] + - [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: + - [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, 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, 1, 1] + - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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, 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, 3, 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, 0, 0, 0, 0, 0, 3, 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, 0, 0, 0, 0, 0, 0, 3, 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, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0] + - [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, 0] + - [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, 1] # Enemigos en esta habitación enemies: diff --git a/data/room/02.yaml b/data/room/02.yaml index 7bc6c15..df94d89 100644 --- a/data/room/02.yaml +++ b/data/room/02.yaml @@ -18,29 +18,53 @@ room: conveyorBelt: none # Tilemap: 21 filas x 32 columnas @ 8px/tile -# Índices de tiles (-1 = vacío) tilemap: - - [191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 48, 5, 25, 25, 25] - - [42, 165, 165, 166, 167, 165, 184, 166, 165, 184, 165, 165, 167, 165, 165, 166, 165, 165, 184, 165, 165, 165, 184, 166, 165, 165, 165, 184, 48, 49, 49, 49] - - [42, 42, 210, 211, 211, 210, 180, 210, 212, 210, 180, 210, 211, 212, 210, 180, 210, 210, 210, 210, 211, 212, 210, 180, 210, 212, 180, 210, -1, -1, -1, -1] - - [42, 42, 42, -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] - - [42, 42, 42, -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, 6, 1, 1, 1] - - [33, 33, 303, -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, 48, 5, 25] - - [33, 33, -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, 302, 24, 25] - - [33, 33, -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, 25] - - [33, 33, -1, 412, 412, 412, 412, -1, -1, -1, -1, 412, 303, 412, 412, 412, -1, -1, -1, -1, 412, 303, 412, 412, 412, 412, 303, -1, -1, -1, 24, 25] - - [33, 33, -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, 25] - - [33, 33, -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, 410, 24, 25] - - [33, 33, -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, 25] - - [33, 33, 412, -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, 410, 48, 49] - - [-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, -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, -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, -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, -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, -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, -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, -1, -1, -1, -1, -1, -1, -1] - - [188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190] + # Mapa de dibujo (indices de tiles, -1 = vacio) + draw: + - [191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 48, 5, 25, 25, 25] + - [42, 165, 165, 166, 167, 165, 184, 166, 165, 184, 165, 165, 167, 165, 165, 166, 165, 165, 184, 165, 165, 165, 184, 166, 165, 165, 165, 184, 48, 49, 49, 49] + - [42, 42, 210, 211, 211, 210, 180, 210, 212, 210, 180, 210, 211, 212, 210, 180, 210, 210, 210, 210, 211, 212, 210, 180, 210, 212, 180, 210, -1, -1, -1, -1] + - [42, 42, 42, -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] + - [42, 42, 42, -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, 6, 1, 1, 1] + - [33, 33, 303, -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, 48, 5, 25] + - [33, 33, -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, 302, 24, 25] + - [33, 33, -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, 25] + - [33, 33, -1, 412, 412, 412, 412, -1, -1, -1, -1, 412, 303, 412, 412, 412, -1, -1, -1, -1, 412, 303, 412, 412, 412, 412, 303, -1, -1, -1, 24, 25] + - [33, 33, -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, 25] + - [33, 33, -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, 410, 24, 25] + - [33, 33, -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, 25] + - [33, 33, 412, -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, 410, 48, 49] + - [-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, -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, -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, -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, -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, -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, -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, -1, -1, -1, -1, -1, -1, -1] + - [188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190, 188, 190] + # Mapa de colisiones (0 = vacio, 1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, 1, 1, 1, 1, 1, 1] # Enemigos en esta habitación enemies: diff --git a/data/room/03.yaml b/data/room/03.yaml index 1fba41b..83f7d63 100644 --- a/data/room/03.yaml +++ b/data/room/03.yaml @@ -18,29 +18,53 @@ room: conveyorBelt: left # Tilemap: 21 filas x 32 columnas @ 8px/tile -# Índices de tiles (-1 = vacío) tilemap: - - [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, -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, -1, -1, -1, -1, -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, -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, -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, 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] - - [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, 1, 1, 1, 1, 1, 53, 51] + # Mapa de dibujo (indices de tiles, -1 = vacio) + draw: + - [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, -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, -1, -1, -1, -1, -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, -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, -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, 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] + - [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, 1, 1, 1, 1, 1, 53, 51] + # Mapa de colisiones (0 = vacio, 1 = solido) + collision: + - [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] + - [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, 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, 4, 0, 0, 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, 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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] + - [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, 1] # Enemigos en esta habitación enemies: diff --git a/data/room/04.yaml b/data/room/04.yaml index 890fab5..28f5a08 100644 --- a/data/room/04.yaml +++ b/data/room/04.yaml @@ -18,26 +18,50 @@ room: conveyorBelt: none # Tilemap: 21 filas x 32 columnas @ 8px/tile -# Índices de tiles (-1 = vacío) tilemap: - - [-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, -1] - - [-1, -1, 70, 71, -1, -1, 141, -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, 94, 95, -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, -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, -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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 266, 266, 266, 266, -1, -1, -1, -1, -1, -1, -1] - - [-1, -1, 141, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 234, 234, -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, -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, -1, -1, -1, -1, -1, -1, -1, 380, -1] - - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 267, 267, 267, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1] - - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 234, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 25] - - [-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, 25] - - [-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, 25] - - [-1, -1, -1, -1, -1, -1, 268, 268, 268, 268, 268, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 25] - - [-1, -1, -1, -1, -1, -1, 234, 234, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 25] - - [-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, 25] - - [-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, 25] - - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 269, 269, 269, 269, 269, -1, -1, -1, -1, -1, -1, -1, 24, 25] - - [-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, 25] - - [-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, 25] - - [-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, 6, 7, 7, 7, 50, 25] + # Mapa de dibujo (indices de tiles, -1 = vacio) + draw: + - [-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, -1] + - [-1, -1, 70, 71, -1, -1, 141, -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, 94, 95, -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, -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, -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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 266, 266, 266, 266, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, 141, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 234, 234, -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, -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, -1, -1, -1, -1, -1, -1, -1, 380, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 267, 267, 267, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 234, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 25] + - [-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, 25] + - [-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, 25] + - [-1, -1, -1, -1, -1, -1, 268, 268, 268, 268, 268, 268, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 25] + - [-1, -1, -1, -1, -1, -1, 234, 234, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 25] + - [-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, 25] + - [-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, 25] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 269, 269, 269, 269, 269, -1, -1, -1, -1, -1, -1, -1, 24, 25] + - [-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, 25] + - [-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, 25] + - [-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, 6, 7, 7, 7, 50, 25] + # Mapa de colisiones (0 = vacio, 1 = solido) + collision: + - [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, 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, 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, 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, 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,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 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, 2, 2, 2, 2, 2, 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] + - [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] diff --git a/data/tilesets/collision.gif b/data/tilesets/collision.gif new file mode 100644 index 0000000..a2fa7be Binary files /dev/null and b/data/tilesets/collision.gif differ diff --git a/data/tilesets/standard.gif b/data/tilesets/standard.gif index 30961de..5ed1b04 100644 Binary files a/data/tilesets/standard.gif and b/data/tilesets/standard.gif differ diff --git a/source/core/rendering/screen.hpp b/source/core/rendering/screen.hpp index d06cc07..a0801f0 100644 --- a/source/core/rendering/screen.hpp +++ b/source/core/rendering/screen.hpp @@ -72,7 +72,7 @@ class Screen { void nextShader(); // Cicla al siguiente shader disponible (para futura UI) // Render offset (para transiciones de pantalla) - void setRenderOffset(int x, int y); // Establece el offset de renderizado + void setRenderOffset(int x, int y); // Establece el offset de renderizado [[nodiscard]] auto getRenderOffsetX() const -> int { return render_offset_x_; } [[nodiscard]] auto getRenderOffsetY() const -> int { return render_offset_y_; } diff --git a/source/core/rendering/text.hpp b/source/core/rendering/text.hpp index 35e074e..a2d8f2c 100644 --- a/source/core/rendering/text.hpp +++ b/source/core/rendering/text.hpp @@ -48,13 +48,13 @@ class Text { auto writeToSurface(const std::string& text, int zoom = 1, int kerning = 1) -> std::shared_ptr; // Escribe el texto en una textura auto writeDXToSurface(Uint8 flags, const std::string& text, int kerning = 1, Uint8 text_color = Uint8(), Uint8 shadow_distance = 1, Uint8 shadow_color = Uint8(), int lenght = -1) -> std::shared_ptr; // Escribe el texto con extras en una textura - void writeColoredMono(int x, int y, const std::string& text, Uint8 color, int cell_w); // Escribe texto monoespaciado con color - [[nodiscard]] auto length(const std::string& text, int kerning = 1) const -> int; // Obtiene la longitud en pixels de una cadena - [[nodiscard]] auto lengthMono(const std::string& text, int cell_w) const -> int; // Obtiene la longitud en pixels de una cadena monoespaciada - [[nodiscard]] auto getCharacterSize() const -> int; // Devuelve el tamaño del caracter - [[nodiscard]] auto glyphWidth(uint32_t codepoint, int kerning = 0) const -> int; // Devuelve el ancho en pixels de un glifo - [[nodiscard]] auto getGlyphClip(uint32_t codepoint) const -> SDL_FRect; // Devuelve el clip rect del glifo - [[nodiscard]] auto getSprite() const -> Sprite* { return sprite_.get(); } // Acceso al sprite interno + void writeColoredMono(int x, int y, const std::string& text, Uint8 color, int cell_w); // Escribe texto monoespaciado con color + [[nodiscard]] auto length(const std::string& text, int kerning = 1) const -> int; // Obtiene la longitud en pixels de una cadena + [[nodiscard]] auto lengthMono(const std::string& text, int cell_w) const -> int; // Obtiene la longitud en pixels de una cadena monoespaciada + [[nodiscard]] auto getCharacterSize() const -> int; // Devuelve el tamaño del caracter + [[nodiscard]] auto glyphWidth(uint32_t codepoint, int kerning = 0) const -> int; // Devuelve el ancho en pixels de un glifo + [[nodiscard]] auto getGlyphClip(uint32_t codepoint) const -> SDL_FRect; // Devuelve el clip rect del glifo + [[nodiscard]] auto getSprite() const -> Sprite* { return sprite_.get(); } // Acceso al sprite interno void setFixedWidth(bool value); // Establece si se usa un tamaño fijo de letra diff --git a/source/core/resources/resource_cache.cpp b/source/core/resources/resource_cache.cpp index dc42261..cc7f969 100644 --- a/source/core/resources/resource_cache.cpp +++ b/source/core/resources/resource_cache.cpp @@ -40,7 +40,8 @@ namespace Resource { // Constructor Cache::Cache(LoadingMode mode) - : loading_mode_(mode), loading_text_(Screen::get()->getText()) { + : loading_mode_(mode), + loading_text_(Screen::get()->getText()) { load(); } diff --git a/source/core/resources/resource_cache.hpp b/source/core/resources/resource_cache.hpp index f8c1cfb..07fa954 100644 --- a/source/core/resources/resource_cache.hpp +++ b/source/core/resources/resource_cache.hpp @@ -17,8 +17,8 @@ namespace Resource { }; static void init(LoadingMode mode = LoadingMode::EAGER); // Inicialización singleton - static void destroy(); // Destrucción singleton - static auto get() -> Cache*; // Acceso al singleton + static void destroy(); // Destrucción singleton + static auto get() -> Cache*; // Acceso al singleton auto getSound(const std::string& name) -> JA_Sound_t*; // Getters de recursos auto getMusic(const std::string& name) -> JA_Music_t*; diff --git a/source/core/system/debug.cpp b/source/core/system/debug.cpp index bc1985a..37cda18 100644 --- a/source/core/system/debug.cpp +++ b/source/core/system/debug.cpp @@ -136,7 +136,10 @@ void Debug::loadFromFile() { auto yaml = fkyaml::node::deserialize(content); // Detecta si falta alguna clave esperada para regenerar el fichero con los nuevos defaults for (const char* key : {"room", "spawn_x", "spawn_y", "spawn_flip", "initial_scene", "lazy_loading", "render_info"}) { - if (!yaml.contains(key)) { needs_save = true; break; } + if (!yaml.contains(key)) { + needs_save = true; + break; + } } if (yaml.contains("room")) { spawn_settings_.room = yaml["room"].get_value(); diff --git a/source/core/system/debug.hpp b/source/core/system/debug.hpp index c63ae99..b19a82e 100644 --- a/source/core/system/debug.hpp +++ b/source/core/system/debug.hpp @@ -47,7 +47,7 @@ class Debug { void setSpawnSettings(const SpawnSettings& s) { spawn_settings_ = s; } // Establece los valores de spawn [[nodiscard]] auto getInitialScene() const -> SceneManager::Scene { return initial_scene_; } // Obtiene la escena inicial de debug void setInitialScene(SceneManager::Scene s) { initial_scene_ = s; } // Establece la escena inicial de debug - [[nodiscard]] auto getLazyLoading() const -> bool { return lazy_loading_; } // Indica si el modo lazy de recursos está activo + [[nodiscard]] auto getLazyLoading() const -> bool { return lazy_loading_; } // Indica si el modo lazy de recursos está activo [[nodiscard]] auto getRenderInfoEnabled() const -> bool { return render_info_enabled_; } // Indica si el overlay RenderInfo arranca activo private: diff --git a/source/core/system/director.cpp b/source/core/system/director.cpp index dd2daa4..c4c4095 100644 --- a/source/core/system/director.cpp +++ b/source/core/system/director.cpp @@ -166,8 +166,8 @@ Director::Director() { // Initialize resources (works for both release and development) #ifdef _DEBUG Resource::Cache::init(Debug::get()->getLazyLoading() - ? Resource::Cache::LoadingMode::LAZY - : Resource::Cache::LoadingMode::EAGER); + ? Resource::Cache::LoadingMode::LAZY + : Resource::Cache::LoadingMode::EAGER); #else Resource::Cache::init(); #endif diff --git a/source/core/system/director.hpp b/source/core/system/director.hpp index 9e6a3f8..b60055b 100644 --- a/source/core/system/director.hpp +++ b/source/core/system/director.hpp @@ -13,9 +13,9 @@ class Game; class Director { public: - Director(); // Constructor - ~Director(); // Destructor - auto iterate() -> SDL_AppResult; // Una iteración del bucle principal (callback model) + Director(); // Constructor + ~Director(); // Destructor + auto iterate() -> SDL_AppResult; // Una iteración del bucle principal (callback model) private: // --- Variables --- diff --git a/source/game/editor/map_editor.cpp b/source/game/editor/map_editor.cpp index ddbb5e7..ef44f21 100644 --- a/source/game/editor/map_editor.cpp +++ b/source/game/editor/map_editor.cpp @@ -121,9 +121,10 @@ auto MapEditor::showGrid(bool show) -> std::string { return show ? "Grid ON" : "Grid OFF"; } -// Parsea un color como índice numérico -static auto parseColor(const std::string& value) -> Uint8 { - return static_cast(safeStoi(value, 0)); +auto MapEditor::setEditingCollision(bool collision) -> std::string { + editing_collision_ = collision; + brush_tile_ = NO_BRUSH; // Resetear brush al cambiar de modo + return editing_collision_ ? "Editing: collision" : "Editing: draw"; } void MapEditor::toggleMiniMap() { @@ -225,6 +226,12 @@ void MapEditor::enter(std::shared_ptr room, std::shared_ptr player selected_item_ = -1; brush_tile_ = NO_BRUSH; painting_ = false; + editing_collision_ = false; + + // Asegurar que collision_tile_map tiene el tamaño correcto + if (room_data_.collision_tile_map.size() != static_cast(Map::WIDTH * Map::HEIGHT)) { + room_data_.collision_tile_map.resize(Map::WIDTH * Map::HEIGHT, 0); + } active_ = true; std::cout << "MapEditor: ON (room " << room_path_ << ")\n"; @@ -332,10 +339,20 @@ void MapEditor::update(float delta_time) { // Si estamos pintando tiles, pintar en la posición actual del ratón if (painting_ && brush_tile_ != NO_BRUSH) { int tile_index = (mouse_tile_y_ * 32) + mouse_tile_x_; - if (tile_index >= 0 && tile_index < static_cast(room_data_.tile_map.size())) { - if (room_data_.tile_map[tile_index] != brush_tile_) { - room_data_.tile_map[tile_index] = brush_tile_; - room_->setTile(tile_index, brush_tile_); + if (editing_collision_) { + // Pintar en el mapa de colisiones + if (tile_index >= 0 && tile_index < static_cast(room_data_.collision_tile_map.size())) { + if (room_data_.collision_tile_map[tile_index] != brush_tile_) { + room_data_.collision_tile_map[tile_index] = brush_tile_; + } + } + } else { + // Pintar en el mapa de dibujo + if (tile_index >= 0 && tile_index < static_cast(room_data_.tile_map.size())) { + if (room_data_.tile_map[tile_index] != brush_tile_) { + room_data_.tile_map[tile_index] = brush_tile_; + room_->setTile(tile_index, brush_tile_); + } } } } @@ -351,6 +368,28 @@ void MapEditor::update(float delta_time) { void MapEditor::render() { // El tilemap ya ha sido renderizado por Game::renderPlaying() antes de llamar aquí + // Si estamos editando colisiones, superponer el mapa de colisiones + if (editing_collision_) { + auto collision_surface = Resource::Cache::get()->getSurface("collision.gif"); + if (collision_surface) { + const int TILE_W = Tile::SIZE; + for (int y = 0; y < Map::HEIGHT; ++y) { + for (int x = 0; x < Map::WIDTH; ++x) { + int index = (y * Map::WIDTH) + x; + if (index >= static_cast(room_data_.collision_tile_map.size())) { continue; } + int tile = room_data_.collision_tile_map[index]; + if (tile <= 0) { continue; } // 0 = vacío, no dibujar + SDL_FRect clip = { + .x = static_cast(tile * TILE_W), + .y = 0, + .w = static_cast(TILE_W), + .h = static_cast(TILE_W)}; + collision_surface->render(x * TILE_W, y * TILE_W, &clip); + } + } + } + } + // Grid (debajo de todo) if (settings_.grid) { renderGrid(); @@ -418,22 +457,41 @@ void MapEditor::handleEvent(const SDL_Event& event) { // NOLINT(readability-fun return; } - // Click derecho: abrir TilePicker del mapa + // 7: alternar entre draw y collision + if (event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_7 && static_cast(event.key.repeat) == 0) { + setEditingCollision(!editing_collision_); + return; + } + + // Click derecho: abrir TilePicker if (event.type == SDL_EVENT_MOUSE_BUTTON_DOWN && event.button.button == SDL_BUTTON_RIGHT) { // Deseleccionar entidades selected_enemy_ = -1; selected_item_ = -1; - // Tile bajo el cursor como tile actual del picker - int tile_index = (mouse_tile_y_ * 32) + mouse_tile_x_; - int current = (tile_index >= 0 && tile_index < static_cast(room_data_.tile_map.size())) - ? room_data_.tile_map[tile_index] - : -1; + if (editing_collision_) { + // Abrir tile picker del collision tileset + int tile_index = (mouse_tile_y_ * 32) + mouse_tile_x_; + int current = (tile_index >= 0 && tile_index < static_cast(room_data_.collision_tile_map.size())) + ? room_data_.collision_tile_map[tile_index] + : 0; - tile_picker_.on_select = [this](int tile) { - brush_tile_ = tile; - }; - tile_picker_.open(room_->getTileSetFile(), current, room_data_.bg_color); + tile_picker_.on_select = [this](int tile) { + brush_tile_ = tile; + }; + tile_picker_.open("collision.gif", current, 0); + } else { + // Abrir tile picker del mapa de dibujo + int tile_index = (mouse_tile_y_ * 32) + mouse_tile_x_; + int current = (tile_index >= 0 && tile_index < static_cast(room_data_.tile_map.size())) + ? room_data_.tile_map[tile_index] + : -1; + + tile_picker_.on_select = [this](int tile) { + brush_tile_ = tile; + }; + tile_picker_.open(room_->getTileSetFile(), current, room_data_.bg_color); + } return; } @@ -463,9 +521,15 @@ void MapEditor::handleEvent(const SDL_Event& event) { // NOLINT(readability-fun // Pintar tile y entrar en modo painting painting_ = true; int tile_index = (mouse_tile_y_ * 32) + mouse_tile_x_; - if (tile_index >= 0 && tile_index < static_cast(room_data_.tile_map.size())) { - room_data_.tile_map[tile_index] = brush_tile_; - room_->setTile(tile_index, brush_tile_); + if (editing_collision_) { + if (tile_index >= 0 && tile_index < static_cast(room_data_.collision_tile_map.size())) { + room_data_.collision_tile_map[tile_index] = brush_tile_; + } + } else { + if (tile_index >= 0 && tile_index < static_cast(room_data_.tile_map.size())) { + room_data_.tile_map[tile_index] = brush_tile_; + room_->setTile(tile_index, brush_tile_); + } } return; } @@ -1329,6 +1393,7 @@ auto MapEditor::createNewRoom(const std::string& direction) -> std::string { // new_room.right_room = "0"; new_room.conveyor_belt_direction = 0; new_room.tile_map.resize(Map::WIDTH * Map::HEIGHT, -1); + new_room.collision_tile_map.resize(Map::WIDTH * Map::HEIGHT, 0); // Conexión recíproca: la nueva room conecta de vuelta a la actual if (direction == "UP") { diff --git a/source/game/editor/map_editor.hpp b/source/game/editor/map_editor.hpp index 74f9df5..75d681a 100644 --- a/source/game/editor/map_editor.hpp +++ b/source/game/editor/map_editor.hpp @@ -50,6 +50,7 @@ class MapEditor { // Opciones del editor (llamados desde console_commands / teclas) auto showInfo(bool show) -> std::string; auto showGrid(bool show) -> std::string; + auto setEditingCollision(bool collision) -> std::string; [[nodiscard]] auto isGridEnabled() const -> bool { return settings_.grid; } void toggleMiniMap(); void setReenter(bool value) { reenter_ = value; } @@ -122,6 +123,7 @@ class MapEditor { static constexpr int ERASER_BRUSH = -1; // Brush borrador (pinta tile vacío = -1) int brush_tile_{NO_BRUSH}; // Tile activo para pintar bool painting_{false}; // true mientras se está pintando con click izquierdo mantenido + bool editing_collision_{false}; // true = editando collision tilemap, false = editando draw tilemap // Datos de la habitación Room::Data room_data_; diff --git a/source/game/editor/mini_map.hpp b/source/game/editor/mini_map.hpp index ba56639..dd03aae 100644 --- a/source/game/editor/mini_map.hpp +++ b/source/game/editor/mini_map.hpp @@ -86,7 +86,7 @@ class MiniMap { float view_start_y_{0.0F}; // Constantes - static constexpr int ROOM_W = Map::WIDTH; // Ancho de una room en pixels del minimapa (1 pixel por tile) + static constexpr int ROOM_W = Map::WIDTH; // Ancho de una room en pixels del minimapa (1 pixel por tile) static constexpr int ROOM_H = Map::HEIGHT; // Alto de una room en pixels del minimapa (1 pixel por tile) static constexpr int BORDER = 1; // Borde alrededor de cada room static constexpr int CELL_W = ROOM_W + (BORDER * 2); // Room + borde diff --git a/source/game/editor/room_saver.cpp b/source/game/editor/room_saver.cpp index ff08902..d3971db 100644 --- a/source/game/editor/room_saver.cpp +++ b/source/game/editor/room_saver.cpp @@ -37,7 +37,7 @@ auto RoomSaver::conveyorBeltToString(int direction) -> std::string { // Genera el YAML completo como texto con formato compacto auto RoomSaver::buildYAML(const fkyaml::node& original_yaml, const Room::Data& room_data) -> std::string { // NOLINT(readability-function-cognitive-complexity) - (void)original_yaml; // Ya no se usa; mantenido para compatibilidad con la firma de saveYAML + (void)original_yaml; // Ya no se usa; mantenido para compatibilidad con la firma de saveYAML std::ostringstream out; // --- Sección room --- @@ -70,10 +70,13 @@ auto RoomSaver::buildYAML(const fkyaml::node& original_yaml, const Room::Data& r // --- Tilemap (MAP_HEIGHT filas × MAP_WIDTH columnas, formato flow) --- out << "\n"; out << "# Tilemap: " << Map::HEIGHT << " filas x " << Map::WIDTH << " columnas @ " << Tile::SIZE << "px/tile\n"; - out << "# Índices de tiles (-1 = vacío)\n"; out << "tilemap:\n"; + + // Mapa de dibujo + out << " # Mapa de dibujo (indices de tiles, -1 = vacio)\n"; + out << " draw:\n"; for (int row = 0; row < Map::HEIGHT; ++row) { - out << " - ["; + out << " - ["; for (int col = 0; col < Map::WIDTH; ++col) { int index = (row * Map::WIDTH) + col; if (index < static_cast(room_data.tile_map.size())) { @@ -86,6 +89,23 @@ auto RoomSaver::buildYAML(const fkyaml::node& original_yaml, const Room::Data& r out << "]\n"; } + // Mapa de colisiones + out << " # Mapa de colisiones (0 = vacio, 1 = solido)\n"; + out << " collision:\n"; + for (int row = 0; row < Map::HEIGHT; ++row) { + out << " - ["; + for (int col = 0; col < Map::WIDTH; ++col) { + int index = (row * Map::WIDTH) + col; + if (index < static_cast(room_data.collision_tile_map.size())) { + out << room_data.collision_tile_map[index]; + } else { + out << 0; + } + if (col < Map::WIDTH - 1) { out << ", "; } + } + out << "]\n"; + } + // --- Enemigos --- if (!room_data.enemies.empty()) { out << "\n"; diff --git a/source/game/entities/player.cpp b/source/game/entities/player.cpp index 6558ced..4ca431e 100644 --- a/source/game/entities/player.cpp +++ b/source/game/entities/player.cpp @@ -591,16 +591,16 @@ void Player::updateColliderPoints() { const float Y1 = y_ + 8; const float Y2 = y_ + 16; const float Y3 = y_ + HEIGHT - 1; - collider_points_[0] = {.x = L, .y = Y0}; - collider_points_[1] = {.x = M, .y = Y0}; - collider_points_[2] = {.x = R, .y = Y0}; - collider_points_[3] = {.x = L, .y = Y1}; - collider_points_[4] = {.x = M, .y = Y1}; - collider_points_[5] = {.x = R, .y = Y1}; - collider_points_[6] = {.x = L, .y = Y2}; - collider_points_[7] = {.x = M, .y = Y2}; - collider_points_[8] = {.x = R, .y = Y2}; - collider_points_[9] = {.x = L, .y = Y3}; + collider_points_[0] = {.x = L, .y = Y0}; + collider_points_[1] = {.x = M, .y = Y0}; + collider_points_[2] = {.x = R, .y = Y0}; + collider_points_[3] = {.x = L, .y = Y1}; + collider_points_[4] = {.x = M, .y = Y1}; + collider_points_[5] = {.x = R, .y = Y1}; + collider_points_[6] = {.x = L, .y = Y2}; + collider_points_[7] = {.x = M, .y = Y2}; + collider_points_[8] = {.x = R, .y = Y2}; + collider_points_[9] = {.x = L, .y = Y3}; collider_points_[10] = {.x = M, .y = Y3}; collider_points_[11] = {.x = R, .y = Y3}; } @@ -680,15 +680,24 @@ void Player::updateVelocity(float delta_time) { target = HORIZONTAL_VELOCITY * room_->getConveyorBeltDirection(); } else { switch (wanna_go_) { - case Direction::LEFT: target = -HORIZONTAL_VELOCITY; break; - case Direction::RIGHT: target = HORIZONTAL_VELOCITY; break; - default: target = 0.0F; break; + case Direction::LEFT: + target = -HORIZONTAL_VELOCITY; + break; + case Direction::RIGHT: + target = HORIZONTAL_VELOCITY; + break; + default: + target = 0.0F; + break; } } // Orientación del sprite según la dirección deseada (sin cambiar cuando target=0) - if (target > 0.0F) { sprite_->setFlip(Flip::RIGHT); } - else if (target < 0.0F) { sprite_->setFlip(Flip::LEFT); } + if (target > 0.0F) { + sprite_->setFlip(Flip::RIGHT); + } else if (target < 0.0F) { + sprite_->setFlip(Flip::LEFT); + } // Inercia: // - En el aire: inercia completa (arranque y frenada graduales) diff --git a/source/game/entities/player.hpp b/source/game/entities/player.hpp index 7ebb993..0ca6882 100644 --- a/source/game/entities/player.hpp +++ b/source/game/entities/player.hpp @@ -33,12 +33,12 @@ class Player { }; // --- Constantes de física (públicas para permitir cálculos en structs) --- - static constexpr float HORIZONTAL_VELOCITY = 60.0F; // Velocidad horizontal objetivo en pixels/segundo - static constexpr float HORIZONTAL_ACCEL = 500.0F; // Aceleración/deceleración horizontal en pixels/segundo² (inercia ligera) - static constexpr float MAX_VY = 160.0F; // Velocidad vertical máxima en pixels/segundo - static constexpr float JUMP_VELOCITY = -178.5F; // Velocidad inicial del salto en pixels/segundo - static constexpr float GRAVITY_FORCE = 360.0F; // Fuerza de gravedad en pixels/segundo² - static constexpr float LOW_JUMP_GRAVITY_MULT = 3.0F; // Multiplicador de gravedad al soltar el botón de salto (salto variable) + static constexpr float HORIZONTAL_VELOCITY = 60.0F; // Velocidad horizontal objetivo en pixels/segundo + static constexpr float HORIZONTAL_ACCEL = 500.0F; // Aceleración/deceleración horizontal en pixels/segundo² (inercia ligera) + static constexpr float MAX_VY = 160.0F; // Velocidad vertical máxima en pixels/segundo + static constexpr float JUMP_VELOCITY = -178.5F; // Velocidad inicial del salto en pixels/segundo + static constexpr float GRAVITY_FORCE = 360.0F; // Fuerza de gravedad en pixels/segundo² + static constexpr float LOW_JUMP_GRAVITY_MULT = 3.0F; // Multiplicador de gravedad al soltar el botón de salto (salto variable) struct SpawnData { float x = 0; @@ -181,9 +181,9 @@ class Player { void placeSprite(); // Coloca el sprite en la posición del jugador // --- Funciones de finalización --- - void animate(float delta_time); // Establece la animación del jugador - auto handleBorders() -> Room::Border; // Comprueba si se halla en alguno de los cuatro bordes - auto handleKillingTiles() -> bool; // Comprueba que el jugador no toque ningun tile de los que matan - void updateVelocity(float delta_time); // Calcula la velocidad en x con inercia ligera - void markAsDead(); // Marca al jugador como muerto + void animate(float delta_time); // Establece la animación del jugador + auto handleBorders() -> Room::Border; // Comprueba si se halla en alguno de los cuatro bordes + auto handleKillingTiles() -> bool; // Comprueba que el jugador no toque ningun tile de los que matan + void updateVelocity(float delta_time); // Calcula la velocidad en x con inercia ligera + void markAsDead(); // Marca al jugador como muerto }; \ No newline at end of file diff --git a/source/game/gameplay/collision_map.cpp b/source/game/gameplay/collision_map.cpp index bd9dfe8..31d795f 100644 --- a/source/game/gameplay/collision_map.cpp +++ b/source/game/gameplay/collision_map.cpp @@ -8,9 +8,8 @@ #include "utils/defines.hpp" // Para Collision // Constructor -CollisionMap::CollisionMap(std::vector tile_map, int tile_set_width, int conveyor_belt_direction) - : tile_map_(std::move(tile_map)), - tile_set_width_(tile_set_width), +CollisionMap::CollisionMap(std::vector collision_tile_map, int conveyor_belt_direction) + : collision_tile_map_(std::move(collision_tile_map)), conveyor_belt_direction_(conveyor_belt_direction) { // Inicializa todas las superficies de colisión initializeSurfaces(); @@ -35,43 +34,21 @@ auto CollisionMap::getTile(SDL_FPoint point) const -> Tile { return getTile(POS); } -// Devuelve el tipo de tile que hay en ese indice -auto CollisionMap::getTile(int index) const -> Tile { // NOLINT(readability-convert-member-functions-to-static) - const bool ON_RANGE = (index > -1) && (index < (int)tile_map_.size()); - - if (ON_RANGE) { - // Las filas 0-8 son de tiles t_wall - if ((tile_map_[index] >= 0) && (tile_map_[index] < 9 * tile_set_width_)) { - return Tile::WALL; - } - - // Las filas 9-17 son de tiles t_passable - if ((tile_map_[index] >= 9 * tile_set_width_) && (tile_map_[index] < 18 * tile_set_width_)) { - return Tile::PASSABLE; - } - - // Las filas 18-20 es de tiles t_animated - if ((tile_map_[index] >= 18 * tile_set_width_) && (tile_map_[index] < 21 * tile_set_width_)) { - return Tile::ANIMATED; - } - - // La fila 21 es de tiles t_slope_r - if ((tile_map_[index] >= 21 * tile_set_width_) && (tile_map_[index] < 22 * tile_set_width_)) { - return Tile::SLOPE_R; - } - - // La fila 22 es de tiles t_slope_l - if ((tile_map_[index] >= 22 * tile_set_width_) && (tile_map_[index] < 23 * tile_set_width_)) { - return Tile::SLOPE_L; - } - - // La fila 23 es de tiles t_kill - if ((tile_map_[index] >= 23 * tile_set_width_) && (tile_map_[index] < 24 * tile_set_width_)) { - return Tile::KILL; - } +// Devuelve el tipo de tile que hay en ese indice (lee del collision_tile_map) +auto CollisionMap::getTile(int index) const -> Tile { + if (index < 0 || index >= static_cast(collision_tile_map_.size())) { + return Tile::EMPTY; } - return Tile::EMPTY; + switch (collision_tile_map_[index]) { + case 1: return Tile::WALL; + case 2: return Tile::PASSABLE; + case 3: return Tile::SLOPE_L; + case 4: return Tile::SLOPE_R; + case 5: return Tile::KILL; + case 6: return Tile::ANIMATED; + default: return Tile::EMPTY; + } } // Obten la coordenada de la cuesta a partir de un punto perteneciente a ese tile @@ -234,7 +211,7 @@ auto CollisionMap::collectBottomTiles() -> std::vector { // NOLINT(readabi // Busca todos los tiles de tipo muro que no tengan debajo otro muro // Hay que recorrer la habitación por filas (excepto los de la última fila) - for (int i = 0; i < (int)tile_map_.size() - MAP_WIDTH; ++i) { + for (int i = 0; i < (int)collision_tile_map_.size() - MAP_WIDTH; ++i) { if (getTile(i) == Tile::WALL && getTile(i + MAP_WIDTH) != Tile::WALL) { tile.push_back(i); @@ -256,7 +233,7 @@ auto CollisionMap::collectTopTiles() -> std::vector { // NOLINT(readabilit // Busca todos los tiles de tipo muro o pasable que no tengan encima un muro // Hay que recorrer la habitación por filas (excepto los de la primera fila) - for (int i = MAP_WIDTH; i < (int)tile_map_.size(); ++i) { + for (int i = MAP_WIDTH; i < (int)collision_tile_map_.size(); ++i) { if ((getTile(i) == Tile::WALL || getTile(i) == Tile::PASSABLE) && getTile(i - MAP_WIDTH) != Tile::WALL) { tile.push_back(i); @@ -272,13 +249,12 @@ auto CollisionMap::collectTopTiles() -> std::vector { // NOLINT(readabilit return tile; } -// Helper: recopila tiles animados (para superficies automaticas/conveyor belts) -auto CollisionMap::collectAnimatedTiles() -> std::vector { // NOLINT(readability-make-member-function-const) +// Helper: recopila tiles conveyor belt +auto CollisionMap::collectConveyorTiles() -> std::vector { // NOLINT(readability-make-member-function-const) std::vector tile; - // Busca todos los tiles de tipo animado - // Hay que recorrer la habitación por filas (excepto los de la primera fila) - for (int i = MAP_WIDTH; i < (int)tile_map_.size(); ++i) { + // Busca todos los tiles de tipo conveyor + for (int i = MAP_WIDTH; i < (int)collision_tile_map_.size(); ++i) { if (getTile(i) == Tile::ANIMATED) { tile.push_back(i); @@ -437,7 +413,7 @@ void CollisionMap::setRightSurfaces() { // NOLINT(readability-make-member-funct void CollisionMap::setLeftSlopes() { // NOLINT(readability-make-member-function-const) // Recorre la habitación entera por filas buscando tiles de tipo t_slope_l std::vector found; - for (int i = 0; i < (int)tile_map_.size(); ++i) { + for (int i = 0; i < (int)collision_tile_map_.size(); ++i) { if (getTile(i) == Tile::SLOPE_L) { found.push_back(i); } @@ -472,7 +448,7 @@ void CollisionMap::setLeftSlopes() { // NOLINT(readability-make-member-function void CollisionMap::setRightSlopes() { // NOLINT(readability-make-member-function-const) // Recorre la habitación entera por filas buscando tiles de tipo t_slope_r std::vector found; - for (int i = 0; i < (int)tile_map_.size(); ++i) { + for (int i = 0; i < (int)collision_tile_map_.size(); ++i) { if (getTile(i) == Tile::SLOPE_R) { found.push_back(i); } @@ -505,6 +481,6 @@ void CollisionMap::setRightSlopes() { // NOLINT(readability-make-member-functio // Calcula las superficies automaticas (conveyor belts) void CollisionMap::setAutoSurfaces() { - std::vector tile = collectAnimatedTiles(); + std::vector tile = collectConveyorTiles(); buildHorizontalLines(tile, conveyor_belt_floors_, false); } diff --git a/source/game/gameplay/collision_map.hpp b/source/game/gameplay/collision_map.hpp index e867409..8dc74c5 100644 --- a/source/game/gameplay/collision_map.hpp +++ b/source/game/gameplay/collision_map.hpp @@ -5,7 +5,7 @@ #include // Para vector #include "utils/defines.hpp" // Para Tile::SIZE, Map::WIDTH, Map::HEIGHT -#include "utils/utils.hpp" // Para LineHorizontal, LineDiagonal, LineVertical +#include "utils/utils.hpp" // Para LineHorizontal, LineDiagonal, LineVertical /** * @brief Mapa de colisiones de una habitación @@ -31,11 +31,10 @@ class CollisionMap { /** * @brief Constructor - * @param tile_map Vector con índices de tiles de la habitación - * @param tile_set_width Ancho del tileset en tiles (para calcular tipo de tile) + * @param collision_tile_map Mapa de colisiones por tile (0=vacío, 1=muro, 2=passable, 3=slope_l, 4=slope_r, 5=kill, 6=conveyor) * @param conveyor_belt_direction Dirección de las cintas transportadoras (-1, 0, +1) */ - CollisionMap(std::vector tile_map, int tile_set_width, int conveyor_belt_direction); + CollisionMap(std::vector collision_tile_map, int conveyor_belt_direction); ~CollisionMap() = default; // Prohibir copia y movimiento @@ -84,14 +83,13 @@ class CollisionMap { private: // --- Constantes --- - static constexpr int TILE_SIZE = ::Tile::SIZE; // Tamaño del tile en pixels - static constexpr int MAP_WIDTH = ::Map::WIDTH; // Ancho del mapa en tiles + static constexpr int TILE_SIZE = ::Tile::SIZE; // Tamaño del tile en pixels + static constexpr int MAP_WIDTH = ::Map::WIDTH; // Ancho del mapa en tiles static constexpr int MAP_HEIGHT = ::Map::HEIGHT; // Alto del mapa en tiles // --- Datos de la habitación --- - std::vector tile_map_; // Índices de tiles de la habitación - int tile_set_width_; // Ancho del tileset en tiles - int conveyor_belt_direction_; // Dirección de conveyor belts + std::vector collision_tile_map_; // Mapa de colisiones por tile + int conveyor_belt_direction_; // Dirección de conveyor belts // --- Geometría de colisión --- std::vector bottom_floors_; // Superficies inferiores (suelos) @@ -108,7 +106,7 @@ class CollisionMap { // Helpers para recopilar tiles auto collectBottomTiles() -> std::vector; // Tiles con superficie inferior auto collectTopTiles() -> std::vector; // Tiles con superficie superior - auto collectAnimatedTiles() -> std::vector; // Tiles animados (conveyor belts) + auto collectConveyorTiles() -> std::vector; // Tiles conveyor belt // Construcción de geometría static void buildHorizontalLines(const std::vector& tiles, std::vector& lines, bool is_bottom_surface); diff --git a/source/game/gameplay/room.cpp b/source/game/gameplay/room.cpp index 7cc5985..0cf927c 100644 --- a/source/game/gameplay/room.cpp +++ b/source/game/gameplay/room.cpp @@ -26,8 +26,8 @@ Room::Room(const std::string& room_path, std::shared_ptr data) item_manager_ = std::make_unique(room->number, data_); initializeRoom(*room); - // Crea el mapa de colisiones (necesita tile_map_, tile_set_width_, conveyor_belt_direction_) - collision_map_ = std::make_unique(tile_map_, tile_set_width_, conveyor_belt_direction_); + // Crea el mapa de colisiones desde el collision_tile_map + collision_map_ = std::make_unique(room->collision_tile_map, conveyor_belt_direction_); // 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_); @@ -78,7 +78,6 @@ void Room::initializeRoom(const Data& room) { } } - // Dibuja el mapa en pantalla void Room::renderMap() { tilemap_renderer_->render(); diff --git a/source/game/gameplay/room.hpp b/source/game/gameplay/room.hpp index 1a2d773..089b3dc 100644 --- a/source/game/gameplay/room.hpp +++ b/source/game/gameplay/room.hpp @@ -9,7 +9,7 @@ #include "game/entities/enemy.hpp" // Para EnemyData #include "game/entities/item.hpp" // Para ItemData #include "game/gameplay/scoreboard.hpp" // Para Scoreboard::Data -#include "utils/defines.hpp" // Para Tile::SIZE, Map::WIDTH, Map::HEIGHT +#include "utils/defines.hpp" // Para Tile::SIZE, Map::WIDTH, Map::HEIGHT #include "utils/utils.hpp" // Para LineHorizontal, LineDiagonal, LineVertical class Sprite; // lines 12-12 class Surface; // lines 13-13 @@ -40,20 +40,21 @@ class Room { }; struct Data { - std::string number; // Numero de la habitación - Uint8 bg_color{0}; // Color de fondo de la habitación - Uint8 border_color{0}; // Color del borde de la pantalla - Uint8 item_color1{12}; // Color 1 para los items de la habitación - Uint8 item_color2{6}; // Color 2 para los items de la habitación - std::string upper_room; // Identificador de la habitación que se encuentra arriba - std::string lower_room; // Identificador de la habitación que se encuentra abajo - std::string left_room; // Identificador de la habitación que se encuentra a la izquierda - std::string right_room; // Identificador de la habitación que se encuentra a la derecha - std::string tile_set_file; // Imagen con los gráficos para la habitación - int conveyor_belt_direction{0}; // Sentido en el que arrastran las superficies automáticas de la habitación - std::vector tile_map; // Índice de los tiles a dibujar en la habitación (embebido desde YAML) - std::vector enemies; // Listado con los enemigos de la habitación - std::vector items; // Listado con los items que hay en la habitación + std::string number; // Numero de la habitación + Uint8 bg_color{0}; // Color de fondo de la habitación + Uint8 border_color{0}; // Color del borde de la pantalla + Uint8 item_color1{12}; // Color 1 para los items de la habitación + Uint8 item_color2{6}; // Color 2 para los items de la habitación + std::string upper_room; // Identificador de la habitación que se encuentra arriba + std::string lower_room; // Identificador de la habitación que se encuentra abajo + std::string left_room; // Identificador de la habitación que se encuentra a la izquierda + std::string right_room; // Identificador de la habitación que se encuentra a la derecha + std::string tile_set_file; // Imagen con los gráficos para la habitación + int conveyor_belt_direction{0}; // Sentido en el que arrastran las superficies automáticas de la habitación + std::vector tile_map; // Índice de los tiles a dibujar en la habitación (embebido desde YAML) + std::vector collision_tile_map; // Mapa de colisiones por tile (0=vacío, 1=sólido) + std::vector enemies; // Listado con los enemigos de la habitación + std::vector items; // Listado con los items que hay en la habitación }; // Constructor y destructor @@ -61,21 +62,21 @@ class Room { ~Room(); // NOLINT(modernize-use-equals-default, performance-trivially-destructible) -- defined in .cpp for unique_ptr with forward declarations // --- Funciones --- - [[nodiscard]] auto getNumber() const -> const std::string& { return number_; } // Devuelve el numero de la habitación - [[nodiscard]] auto getBGColor() const -> Uint8 { return bg_color_; } // Devuelve el color de la habitación - [[nodiscard]] auto getBorderColor() const -> Uint8 { return border_color_; } // Devuelve el color del borde - void renderMap(); // Dibuja el mapa en pantalla - void renderEnemies(); // Dibuja los enemigos en pantalla - void renderItems(); // Dibuja los objetos en pantalla + [[nodiscard]] auto getNumber() const -> const std::string& { return number_; } // Devuelve el numero de la habitación + [[nodiscard]] auto getBGColor() const -> Uint8 { return bg_color_; } // Devuelve el color de la habitación + [[nodiscard]] auto getBorderColor() const -> Uint8 { return border_color_; } // Devuelve el color del borde + void renderMap(); // Dibuja el mapa en pantalla + void renderEnemies(); // Dibuja los enemigos en pantalla + void renderItems(); // Dibuja los objetos en pantalla #ifdef _DEBUG - void redrawMap(); // Redibuja el mapa (para actualizar modo debug) - void updateEditorMode(float delta_time); // Actualiza animaciones sin mover enemigos (para editor) - void resetEnemyPositions(const std::vector& enemy_data); // Resetea enemigos a posiciones iniciales - auto getEnemyManager() -> EnemyManager* { return enemy_manager_.get(); } // Acceso al gestor de enemigos (para editor) - auto getItemManager() -> ItemManager* { return item_manager_.get(); } // Acceso al gestor de items (para editor) - void setBgColor(Uint8 color); // Cambia color de fondo y redibuja (para editor) - void setItemColors(Uint8 color1, Uint8 color2); // Cambia colores de items (para editor) - void setTile(int index, int tile_value); // Cambia un tile y redibuja (para editor) + void redrawMap(); // Redibuja el mapa (para actualizar modo debug) + void updateEditorMode(float delta_time); // Actualiza animaciones sin mover enemigos (para editor) + void resetEnemyPositions(const std::vector& enemy_data); // Resetea enemigos a posiciones iniciales + auto getEnemyManager() -> EnemyManager* { return enemy_manager_.get(); } // Acceso al gestor de enemigos (para editor) + auto getItemManager() -> ItemManager* { return item_manager_.get(); } // Acceso al gestor de items (para editor) + void setBgColor(Uint8 color); // Cambia color de fondo y redibuja (para editor) + void setItemColors(Uint8 color1, Uint8 color2); // Cambia colores de items (para editor) + void setTile(int index, int tile_value); // Cambia un tile y redibuja (para editor) [[nodiscard]] auto getTileSetFile() const -> const std::string& { return tile_set_file_; } [[nodiscard]] auto getTileSetWidth() const -> int { return tile_set_width_; } #endif @@ -107,8 +108,8 @@ class Room { private: // Constantes - static constexpr int TILE_SIZE = ::Tile::SIZE; // Ancho del tile en pixels - static constexpr int MAP_WIDTH = ::Map::WIDTH; // Ancho del mapa en tiles + static constexpr int TILE_SIZE = ::Tile::SIZE; // Ancho del tile en pixels + static constexpr int MAP_WIDTH = ::Map::WIDTH; // Ancho del mapa en tiles static constexpr int MAP_HEIGHT = ::Map::HEIGHT; // Alto del mapa en tiles // Objetos y punteros diff --git a/source/game/gameplay/room_loader.cpp b/source/game/gameplay/room_loader.cpp index 223f963..9a3ab2b 100644 --- a/source/game/gameplay/room_loader.cpp +++ b/source/game/gameplay/room_loader.cpp @@ -119,20 +119,12 @@ void RoomLoader::parseRoomConnections(const fkyaml::node& conn_node, Room::Data& : "0"; } -// Parsea el tilemap de la habitación -void RoomLoader::parseTilemap(const fkyaml::node& yaml, Room::Data& room, const std::string& file_name, bool verbose) { // NOLINT(readability-convert-member-functions-to-static) - if (!yaml.contains("tilemap")) { - std::cerr << "Warning: No tilemap found in " << file_name << '\n'; - return; - } - - const auto& tilemap_node = yaml["tilemap"]; - - // Read 2D array +// Lee un array 2D de enteros desde un nodo YAML +static auto readTilemap2D(const fkyaml::node& node) -> std::vector> { std::vector> tilemap_2d; tilemap_2d.reserve(Map::HEIGHT); - for (const auto& row_node : tilemap_node) { + for (const auto& row_node : node) { std::vector row; row.reserve(Map::WIDTH); @@ -143,11 +135,36 @@ void RoomLoader::parseTilemap(const fkyaml::node& yaml, Room::Data& room, const tilemap_2d.push_back(row); } - // Convert to 1D flat array - room.tile_map = flattenTilemap(tilemap_2d); + return tilemap_2d; +} + +// Parsea el tilemap de la habitación +void RoomLoader::parseTilemap(const fkyaml::node& yaml, Room::Data& room, const std::string& file_name, bool verbose) { // NOLINT(readability-convert-member-functions-to-static) + if (!yaml.contains("tilemap")) { + std::cerr << "Warning: No tilemap found in " << file_name << '\n'; + return; + } + + const auto& tilemap_node = yaml["tilemap"]; + + // Nuevo formato: tilemap.draw + tilemap.collision + if (tilemap_node.contains("draw")) { + room.tile_map = flattenTilemap(readTilemap2D(tilemap_node["draw"])); + + if (tilemap_node.contains("collision")) { + room.collision_tile_map = flattenTilemap(readTilemap2D(tilemap_node["collision"])); + } + } else { + // Formato antiguo: tilemap es directamente el array 2D de dibujo + room.tile_map = flattenTilemap(readTilemap2D(tilemap_node)); + } if (verbose) { - std::cout << "Loaded tilemap: " << room.tile_map.size() << " tiles\n"; + std::cout << "Loaded tilemap: " << room.tile_map.size() << " tiles"; + if (!room.collision_tile_map.empty()) { + std::cout << " + collision: " << room.collision_tile_map.size() << " tiles"; + } + std::cout << '\n'; } } diff --git a/source/game/gameplay/scoreboard.cpp b/source/game/gameplay/scoreboard.cpp index d6a0758..3947295 100644 --- a/source/game/gameplay/scoreboard.cpp +++ b/source/game/gameplay/scoreboard.cpp @@ -95,9 +95,7 @@ void Scoreboard::fillTexture() { // Valores formateados const std::string LIVES_STR = std::to_string(data_->lives); const std::string ITEMS_STR = std::to_string(data_->items); - const std::string TIME_STR = std::to_string((clock_.minutes % 100) / 10) + std::to_string(clock_.minutes % 10) - + clock_.separator - + std::to_string((clock_.seconds % 60) / 10) + std::to_string(clock_.seconds % 10); + const std::string TIME_STR = std::to_string((clock_.minutes % 100) / 10) + std::to_string(clock_.minutes % 10) + clock_.separator + std::to_string((clock_.seconds % 60) / 10) + std::to_string(clock_.seconds % 10); // --- Línea 1: vides X - objectes X - temps MM:SS (centrada) --- const std::string LIVES_LABEL = Locale::get()->get("scoreboard.lives"); @@ -105,9 +103,7 @@ void Scoreboard::fillTexture() { const std::string TIME_LABEL = Locale::get()->get("scoreboard.time"); // Ancho total: labels proporcionales + valores monoespaciados - const int LINE1_W = text->length(LIVES_LABEL) + text->lengthMono(LIVES_STR, MONO_W) - + text->length(SEP) + text->length(ITEMS_LABEL) + text->lengthMono(ITEMS_STR, MONO_W) - + text->length(SEP) + text->length(TIME_LABEL) + text->lengthMono(TIME_STR, MONO_W); + const int LINE1_W = text->length(LIVES_LABEL) + text->lengthMono(LIVES_STR, MONO_W) + text->length(SEP) + text->length(ITEMS_LABEL) + text->lengthMono(ITEMS_STR, MONO_W) + text->length(SEP) + text->length(TIME_LABEL) + text->lengthMono(TIME_STR, MONO_W); int x = (CANVAS_W - LINE1_W) / 2; text->writeColored(x, LINE1_Y, LIVES_LABEL, LABEL_COLOR); diff --git a/source/game/gameplay/tilemap_renderer.hpp b/source/game/gameplay/tilemap_renderer.hpp index d762162..764231c 100644 --- a/source/game/gameplay/tilemap_renderer.hpp +++ b/source/game/gameplay/tilemap_renderer.hpp @@ -92,12 +92,12 @@ class TilemapRenderer { }; // === Constantes === - static constexpr int TILE_SIZE = Tile::SIZE; // Ancho del tile en pixels - static constexpr int MAP_WIDTH = Map::WIDTH; // Ancho del mapa en tiles - static constexpr int MAP_HEIGHT = Map::HEIGHT; // Alto del mapa en tiles - static constexpr int PLAY_AREA_WIDTH = PlayArea::WIDTH; // Ancho del área de juego en pixels - static constexpr int PLAY_AREA_HEIGHT = PlayArea::HEIGHT; // Alto del área de juego en pixels - static constexpr float CONVEYOR_FRAME_DURATION = 0.05F; // Duración de cada frame (3 frames @ 60fps) + static constexpr int TILE_SIZE = Tile::SIZE; // Ancho del tile en pixels + static constexpr int MAP_WIDTH = Map::WIDTH; // Ancho del mapa en tiles + static constexpr int MAP_HEIGHT = Map::HEIGHT; // Alto del mapa en tiles + static constexpr int PLAY_AREA_WIDTH = PlayArea::WIDTH; // Ancho del área de juego en pixels + static constexpr int PLAY_AREA_HEIGHT = PlayArea::HEIGHT; // Alto del área de juego en pixels + static constexpr float CONVEYOR_FRAME_DURATION = 0.05F; // Duración de cada frame (3 frames @ 60fps) // === Datos de la habitación === std::vector tile_map_; // Índices de tiles de la habitación diff --git a/source/game/scene_manager.hpp b/source/game/scene_manager.hpp index 11926cd..a29025b 100644 --- a/source/game/scene_manager.hpp +++ b/source/game/scene_manager.hpp @@ -25,7 +25,7 @@ namespace SceneManager { }; // --- Variables de estado globales --- - inline Scene current = Scene::LOGO; // Escena actual (en _DEBUG sobrescrito por Director tras cargar debug.yaml) + inline Scene current = Scene::LOGO; // Escena actual (en _DEBUG sobrescrito por Director tras cargar debug.yaml) inline Options options = Options::LOGO_TO_TITLE; // Opciones de la escena actual inline Scene scene_before_restart = Scene::LOGO; // escena a relanzar tras RESTART_CURRENT diff --git a/source/game/scenes/game.cpp b/source/game/scenes/game.cpp index 12dcc4d..568e784 100644 --- a/source/game/scenes/game.cpp +++ b/source/game/scenes/game.cpp @@ -15,7 +15,7 @@ #include "core/rendering/text.hpp" // Para Text, Text::CENTER_FLAG, Text::COLOR_FLAG #include "core/resources/resource_cache.hpp" // Para ResourceRoom, Resource #include "core/resources/resource_list.hpp" // Para Asset -#include "core/system/event_buffer.hpp" // Para EventBuffer +#include "core/system/event_buffer.hpp" // Para EventBuffer #include "core/system/global_events.hpp" // Para check #include "game/defaults.hpp" // Para Defaults::Game #include "game/game_control.hpp" // Para GameControl @@ -29,7 +29,7 @@ #include "game/ui/console.hpp" // Para Console #include "game/ui/notifier.hpp" // Para Notifier, NotificationText, CHEEVO_NO... #include "utils/defines.hpp" // Para Tile::SIZE, PlayArea::HEIGHT, RoomBorder::BOTTOM -#include "utils/easing_functions.hpp" // Para Easing::cubicInOut +#include "utils/easing_functions.hpp" // Para Easing::cubicInOut #include "utils/utils.hpp" #ifdef _DEBUG diff --git a/source/game/scenes/game.hpp b/source/game/scenes/game.hpp index ea69b6e..098b13f 100644 --- a/source/game/scenes/game.hpp +++ b/source/game/scenes/game.hpp @@ -112,15 +112,14 @@ class Game { float fade_accumulator_{0.0F}; // Acumulador de tiempo para el fade // Transición animada entre pantallas - bool transitioning_{false}; // Indica si hay una transición en curso - 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 transitioning_{false}; // Indica si hay una transición en curso + 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 // Variables de demo mode DemoData demo_; // Variables para el modo demo - #ifdef _DEBUG // Variables de debug para arrastre con ratón bool debug_dragging_player_{false}; // Indica si estamos arrastrando al jugador con el ratón diff --git a/source/game/scenes/logo.cpp b/source/game/scenes/logo.cpp index 1434bdf..bf46fc6 100644 --- a/source/game/scenes/logo.cpp +++ b/source/game/scenes/logo.cpp @@ -13,7 +13,7 @@ #include "core/rendering/sprite/sprite.hpp" // Para SSprite #include "core/rendering/surface.hpp" // Para Surface #include "core/resources/resource_cache.hpp" // Para Resource -#include "core/system/event_buffer.hpp" // Para EventBuffer +#include "core/system/event_buffer.hpp" // Para EventBuffer #include "core/system/global_events.hpp" // Para check #include "game/options.hpp" // Para Options, SectionState, options, Section #include "game/scene_manager.hpp" // Para SceneManager diff --git a/source/game/scenes/title.cpp b/source/game/scenes/title.cpp index 1b6c332..1794323 100644 --- a/source/game/scenes/title.cpp +++ b/source/game/scenes/title.cpp @@ -14,7 +14,7 @@ #include "core/rendering/text.hpp" // Para Text, Text::CENTER_FLAG, Text::COLOR_FLAG #include "core/resources/resource_cache.hpp" // Para Resource #include "core/resources/resource_list.hpp" // Para Asset -#include "core/system/event_buffer.hpp" // Para EventBuffer +#include "core/system/event_buffer.hpp" // Para EventBuffer #include "core/system/global_events.hpp" // Para check #include "game/gameplay/cheevos.hpp" // Para Cheevos, Achievement #include "game/options.hpp" // Para Options, options, SectionState, Section @@ -42,9 +42,9 @@ Title::Title() SceneManager::options = SceneManager::Options::NONE; // Acciones iniciales - createCheevosTexture(); // Crea y rellena la textura para mostrar los logros - Screen::get()->setBorderColor(0); // Cambia el color del borde - Audio::get()->playMusic("574071_EA_DTV.ogg"); // Inicia la musica + createCheevosTexture(); // Crea y rellena la textura para mostrar los logros + Screen::get()->setBorderColor(0); // Cambia el color del borde + Audio::get()->playMusic("574071_EA_DTV.ogg"); // Inicia la musica } // Destructor @@ -233,7 +233,6 @@ void Title::updateMainMenu(float delta_time) { // Actualiza el estado CHEEVOS_MENU void Title::updateCheevosMenu(float delta_time) { - // Determina la velocidad objetivo basada en el input float target_velocity = 0.0F; if (Input::get()->checkAction(InputAction::RIGHT, Input::ALLOW_REPEAT)) { diff --git a/source/game/scenes/title.hpp b/source/game/scenes/title.hpp index 8ac28fd..ed8745e 100644 --- a/source/game/scenes/title.hpp +++ b/source/game/scenes/title.hpp @@ -5,6 +5,7 @@ #include // Para std::array #include // Para shared_ptr #include // Para string + #include "game/scene_manager.hpp" // Para SceneManager::Scene #include "utils/delta_timer.hpp" // Para DeltaTimer class Sprite; // Forward declaration @@ -68,13 +69,13 @@ class Title { // --- Variables miembro --- // Objetos y punteros - std::shared_ptr game_logo_surface_; // Textura con los graficos - std::unique_ptr game_logo_sprite_; // SSprite para manejar la surface - std::shared_ptr cheevos_surface_; // Textura con la lista de logros - std::unique_ptr cheevos_sprite_; // SSprite para manejar la surface con la lista de logros - std::shared_ptr title_surface_; // Surface donde se dibuja toda la clase - std::unique_ptr delta_timer_; // Timer para delta time - std::shared_ptr menu_text_; // Texto para los menus + std::shared_ptr game_logo_surface_; // Textura con los graficos + std::unique_ptr game_logo_sprite_; // SSprite para manejar la surface + std::shared_ptr cheevos_surface_; // Textura con la lista de logros + std::unique_ptr cheevos_sprite_; // SSprite para manejar la surface con la lista de logros + std::shared_ptr title_surface_; // Surface donde se dibuja toda la clase + std::unique_ptr delta_timer_; // Timer para delta time + std::shared_ptr menu_text_; // Texto para los menus // Variables de estado del menú de logros SDL_FRect cheevos_surface_view_; // Zona visible de la surface con el listado de logros diff --git a/source/game/ui/console_commands.cpp b/source/game/ui/console_commands.cpp index 4ee4efb..4e9ed3f 100644 --- a/source/game/ui/console_commands.cpp +++ b/source/game/ui/console_commands.cpp @@ -707,6 +707,15 @@ static auto cmdEdit(const std::vector& args) -> std::string { // N if (args[1] == "INFO") { return MapEditor::get()->showInfo(show); } if (args[1] == "GRID") { return MapEditor::get()->showGrid(show); } } + // EDIT DRAW / EDIT COLLISION + if (args[0] == "DRAW") { + if ((MapEditor::get() == nullptr) || !MapEditor::get()->isActive()) { return "Editor not active"; } + return MapEditor::get()->setEditingCollision(false); + } + if (args[0] == "COLLISION") { + if ((MapEditor::get() == nullptr) || !MapEditor::get()->isActive()) { return "Editor not active"; } + return MapEditor::get()->setEditingCollision(true); + } // EDIT MAPBG/MAPCONN if (args[0] == "MAPBG" && args.size() >= 2) { if ((MapEditor::get() == nullptr) || !MapEditor::get()->isActive()) { return "Editor not active"; }