collision map
This commit is contained in:
@@ -75,6 +75,7 @@ assets:
|
|||||||
tilesets:
|
tilesets:
|
||||||
BITMAP:
|
BITMAP:
|
||||||
- ${PREFIX}/data/tilesets/standard.gif
|
- ${PREFIX}/data/tilesets/standard.gif
|
||||||
|
- ${PREFIX}/data/tilesets/collision.gif
|
||||||
|
|
||||||
# ENEMIES
|
# ENEMIES
|
||||||
enemies:
|
enemies:
|
||||||
|
|||||||
@@ -227,11 +227,11 @@ categories:
|
|||||||
- keyword: EDIT
|
- keyword: EDIT
|
||||||
handler: cmd_edit
|
handler: cmd_edit
|
||||||
description: "Map editor mode (GAME only)"
|
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]
|
scope: [debug, editor]
|
||||||
dynamic_completions: true
|
dynamic_completions: true
|
||||||
completions:
|
completions:
|
||||||
EDIT: [ON, OFF, REVERT, SHOW, HIDE, MAPBG, MAPCONN]
|
EDIT: [ON, OFF, REVERT, SHOW, HIDE, DRAW, COLLISION, MAPBG, MAPCONN]
|
||||||
EDIT SHOW: [INFO, GRID]
|
EDIT SHOW: [INFO, GRID]
|
||||||
EDIT HIDE: [INFO, GRID]
|
EDIT HIDE: [INFO, GRID]
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,9 @@ room:
|
|||||||
conveyorBelt: none
|
conveyorBelt: none
|
||||||
|
|
||||||
# Tilemap: 21 filas x 32 columnas @ 8px/tile
|
# Tilemap: 21 filas x 32 columnas @ 8px/tile
|
||||||
# Índices de tiles (-1 = vacío)
|
|
||||||
tilemap:
|
tilemap:
|
||||||
|
# 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]
|
- [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]
|
- [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]
|
- [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]
|
||||||
@@ -41,6 +42,29 @@ tilemap:
|
|||||||
- [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, 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]
|
- [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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, 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
|
# Enemigos en esta habitación
|
||||||
enemies:
|
enemies:
|
||||||
|
|||||||
@@ -18,8 +18,9 @@ room:
|
|||||||
conveyorBelt: none
|
conveyorBelt: none
|
||||||
|
|
||||||
# Tilemap: 21 filas x 32 columnas @ 8px/tile
|
# Tilemap: 21 filas x 32 columnas @ 8px/tile
|
||||||
# Índices de tiles (-1 = vacío)
|
|
||||||
tilemap:
|
tilemap:
|
||||||
|
# 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]
|
- [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, 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, 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]
|
||||||
@@ -41,6 +42,29 @@ 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, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
||||||
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
- [-1, -1, -1, -1, -1, -1, -1, -1, -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]
|
- [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 = solido)
|
||||||
|
collision:
|
||||||
|
- [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 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
|
# Enemigos en esta habitación
|
||||||
enemies:
|
enemies:
|
||||||
|
|||||||
@@ -18,8 +18,9 @@ room:
|
|||||||
conveyorBelt: left
|
conveyorBelt: left
|
||||||
|
|
||||||
# Tilemap: 21 filas x 32 columnas @ 8px/tile
|
# Tilemap: 21 filas x 32 columnas @ 8px/tile
|
||||||
# Índices de tiles (-1 = vacío)
|
|
||||||
tilemap:
|
tilemap:
|
||||||
|
# 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]
|
- [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]
|
- [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]
|
||||||
@@ -41,6 +42,29 @@ tilemap:
|
|||||||
- [-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, 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, 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]
|
- [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, 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, 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]
|
||||||
|
- [1, 1, 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, 1, 1]
|
||||||
|
- [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 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]
|
||||||
|
- [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]
|
||||||
|
- [1, 1, 1, 1, 1, 1, 1, 1, 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
|
# Enemigos en esta habitación
|
||||||
enemies:
|
enemies:
|
||||||
|
|||||||
@@ -18,8 +18,9 @@ room:
|
|||||||
conveyorBelt: none
|
conveyorBelt: none
|
||||||
|
|
||||||
# Tilemap: 21 filas x 32 columnas @ 8px/tile
|
# Tilemap: 21 filas x 32 columnas @ 8px/tile
|
||||||
# Índices de tiles (-1 = vacío)
|
|
||||||
tilemap:
|
tilemap:
|
||||||
|
# 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, -1, -1, -1, -1, -1, -1, -1, -1, -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, 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, 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]
|
||||||
@@ -33,7 +34,7 @@ tilemap:
|
|||||||
- [-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, 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, -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, 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, 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, -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]
|
||||||
@@ -41,3 +42,26 @@ 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, 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, -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]
|
- [-1, -1, -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,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1, 1]
|
||||||
|
|||||||
BIN
data/tilesets/collision.gif
Normal file
BIN
data/tilesets/collision.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 396 B |
Binary file not shown.
|
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.1 KiB |
@@ -40,7 +40,8 @@ namespace Resource {
|
|||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Cache::Cache(LoadingMode mode)
|
Cache::Cache(LoadingMode mode)
|
||||||
: loading_mode_(mode), loading_text_(Screen::get()->getText()) {
|
: loading_mode_(mode),
|
||||||
|
loading_text_(Screen::get()->getText()) {
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,10 @@ void Debug::loadFromFile() {
|
|||||||
auto yaml = fkyaml::node::deserialize(content);
|
auto yaml = fkyaml::node::deserialize(content);
|
||||||
// Detecta si falta alguna clave esperada para regenerar el fichero con los nuevos defaults
|
// 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"}) {
|
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")) {
|
if (yaml.contains("room")) {
|
||||||
spawn_settings_.room = yaml["room"].get_value<std::string>();
|
spawn_settings_.room = yaml["room"].get_value<std::string>();
|
||||||
|
|||||||
@@ -121,9 +121,10 @@ auto MapEditor::showGrid(bool show) -> std::string {
|
|||||||
return show ? "Grid ON" : "Grid OFF";
|
return show ? "Grid ON" : "Grid OFF";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parsea un color como índice numérico
|
auto MapEditor::setEditingCollision(bool collision) -> std::string {
|
||||||
static auto parseColor(const std::string& value) -> Uint8 {
|
editing_collision_ = collision;
|
||||||
return static_cast<Uint8>(safeStoi(value, 0));
|
brush_tile_ = NO_BRUSH; // Resetear brush al cambiar de modo
|
||||||
|
return editing_collision_ ? "Editing: collision" : "Editing: draw";
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapEditor::toggleMiniMap() {
|
void MapEditor::toggleMiniMap() {
|
||||||
@@ -225,6 +226,12 @@ void MapEditor::enter(std::shared_ptr<Room> room, std::shared_ptr<Player> player
|
|||||||
selected_item_ = -1;
|
selected_item_ = -1;
|
||||||
brush_tile_ = NO_BRUSH;
|
brush_tile_ = NO_BRUSH;
|
||||||
painting_ = false;
|
painting_ = false;
|
||||||
|
editing_collision_ = false;
|
||||||
|
|
||||||
|
// Asegurar que collision_tile_map tiene el tamaño correcto
|
||||||
|
if (room_data_.collision_tile_map.size() != static_cast<size_t>(Map::WIDTH * Map::HEIGHT)) {
|
||||||
|
room_data_.collision_tile_map.resize(Map::WIDTH * Map::HEIGHT, 0);
|
||||||
|
}
|
||||||
|
|
||||||
active_ = true;
|
active_ = true;
|
||||||
std::cout << "MapEditor: ON (room " << room_path_ << ")\n";
|
std::cout << "MapEditor: ON (room " << room_path_ << ")\n";
|
||||||
@@ -332,6 +339,15 @@ void MapEditor::update(float delta_time) {
|
|||||||
// Si estamos pintando tiles, pintar en la posición actual del ratón
|
// Si estamos pintando tiles, pintar en la posición actual del ratón
|
||||||
if (painting_ && brush_tile_ != NO_BRUSH) {
|
if (painting_ && brush_tile_ != NO_BRUSH) {
|
||||||
int tile_index = (mouse_tile_y_ * 32) + mouse_tile_x_;
|
int tile_index = (mouse_tile_y_ * 32) + mouse_tile_x_;
|
||||||
|
if (editing_collision_) {
|
||||||
|
// Pintar en el mapa de colisiones
|
||||||
|
if (tile_index >= 0 && tile_index < static_cast<int>(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<int>(room_data_.tile_map.size())) {
|
if (tile_index >= 0 && tile_index < static_cast<int>(room_data_.tile_map.size())) {
|
||||||
if (room_data_.tile_map[tile_index] != brush_tile_) {
|
if (room_data_.tile_map[tile_index] != brush_tile_) {
|
||||||
room_data_.tile_map[tile_index] = brush_tile_;
|
room_data_.tile_map[tile_index] = brush_tile_;
|
||||||
@@ -339,6 +355,7 @@ void MapEditor::update(float delta_time) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Actualizar la barra de estado
|
// Actualizar la barra de estado
|
||||||
updateStatusBarInfo();
|
updateStatusBarInfo();
|
||||||
@@ -351,6 +368,28 @@ void MapEditor::update(float delta_time) {
|
|||||||
void MapEditor::render() {
|
void MapEditor::render() {
|
||||||
// El tilemap ya ha sido renderizado por Game::renderPlaying() antes de llamar aquí
|
// 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<int>(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<float>(tile * TILE_W),
|
||||||
|
.y = 0,
|
||||||
|
.w = static_cast<float>(TILE_W),
|
||||||
|
.h = static_cast<float>(TILE_W)};
|
||||||
|
collision_surface->render(x * TILE_W, y * TILE_W, &clip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Grid (debajo de todo)
|
// Grid (debajo de todo)
|
||||||
if (settings_.grid) {
|
if (settings_.grid) {
|
||||||
renderGrid();
|
renderGrid();
|
||||||
@@ -418,13 +457,31 @@ void MapEditor::handleEvent(const SDL_Event& event) { // NOLINT(readability-fun
|
|||||||
return;
|
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<int>(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) {
|
if (event.type == SDL_EVENT_MOUSE_BUTTON_DOWN && event.button.button == SDL_BUTTON_RIGHT) {
|
||||||
// Deseleccionar entidades
|
// Deseleccionar entidades
|
||||||
selected_enemy_ = -1;
|
selected_enemy_ = -1;
|
||||||
selected_item_ = -1;
|
selected_item_ = -1;
|
||||||
|
|
||||||
// Tile bajo el cursor como tile actual del picker
|
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<int>(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("collision.gif", current, 0);
|
||||||
|
} else {
|
||||||
|
// Abrir tile picker del mapa de dibujo
|
||||||
int tile_index = (mouse_tile_y_ * 32) + mouse_tile_x_;
|
int tile_index = (mouse_tile_y_ * 32) + mouse_tile_x_;
|
||||||
int current = (tile_index >= 0 && tile_index < static_cast<int>(room_data_.tile_map.size()))
|
int current = (tile_index >= 0 && tile_index < static_cast<int>(room_data_.tile_map.size()))
|
||||||
? room_data_.tile_map[tile_index]
|
? room_data_.tile_map[tile_index]
|
||||||
@@ -434,6 +491,7 @@ void MapEditor::handleEvent(const SDL_Event& event) { // NOLINT(readability-fun
|
|||||||
brush_tile_ = tile;
|
brush_tile_ = tile;
|
||||||
};
|
};
|
||||||
tile_picker_.open(room_->getTileSetFile(), current, room_data_.bg_color);
|
tile_picker_.open(room_->getTileSetFile(), current, room_data_.bg_color);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -463,10 +521,16 @@ void MapEditor::handleEvent(const SDL_Event& event) { // NOLINT(readability-fun
|
|||||||
// Pintar tile y entrar en modo painting
|
// Pintar tile y entrar en modo painting
|
||||||
painting_ = true;
|
painting_ = true;
|
||||||
int tile_index = (mouse_tile_y_ * 32) + mouse_tile_x_;
|
int tile_index = (mouse_tile_y_ * 32) + mouse_tile_x_;
|
||||||
|
if (editing_collision_) {
|
||||||
|
if (tile_index >= 0 && tile_index < static_cast<int>(room_data_.collision_tile_map.size())) {
|
||||||
|
room_data_.collision_tile_map[tile_index] = brush_tile_;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (tile_index >= 0 && tile_index < static_cast<int>(room_data_.tile_map.size())) {
|
if (tile_index >= 0 && tile_index < static_cast<int>(room_data_.tile_map.size())) {
|
||||||
room_data_.tile_map[tile_index] = brush_tile_;
|
room_data_.tile_map[tile_index] = brush_tile_;
|
||||||
room_->setTile(tile_index, brush_tile_);
|
room_->setTile(tile_index, brush_tile_);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1329,6 +1393,7 @@ auto MapEditor::createNewRoom(const std::string& direction) -> std::string { //
|
|||||||
new_room.right_room = "0";
|
new_room.right_room = "0";
|
||||||
new_room.conveyor_belt_direction = 0;
|
new_room.conveyor_belt_direction = 0;
|
||||||
new_room.tile_map.resize(Map::WIDTH * Map::HEIGHT, -1);
|
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
|
// Conexión recíproca: la nueva room conecta de vuelta a la actual
|
||||||
if (direction == "UP") {
|
if (direction == "UP") {
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class MapEditor {
|
|||||||
// Opciones del editor (llamados desde console_commands / teclas)
|
// Opciones del editor (llamados desde console_commands / teclas)
|
||||||
auto showInfo(bool show) -> std::string;
|
auto showInfo(bool show) -> std::string;
|
||||||
auto showGrid(bool show) -> std::string;
|
auto showGrid(bool show) -> std::string;
|
||||||
|
auto setEditingCollision(bool collision) -> std::string;
|
||||||
[[nodiscard]] auto isGridEnabled() const -> bool { return settings_.grid; }
|
[[nodiscard]] auto isGridEnabled() const -> bool { return settings_.grid; }
|
||||||
void toggleMiniMap();
|
void toggleMiniMap();
|
||||||
void setReenter(bool value) { reenter_ = value; }
|
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)
|
static constexpr int ERASER_BRUSH = -1; // Brush borrador (pinta tile vacío = -1)
|
||||||
int brush_tile_{NO_BRUSH}; // Tile activo para pintar
|
int brush_tile_{NO_BRUSH}; // Tile activo para pintar
|
||||||
bool painting_{false}; // true mientras se está pintando con click izquierdo mantenido
|
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
|
// Datos de la habitación
|
||||||
Room::Data room_data_;
|
Room::Data room_data_;
|
||||||
|
|||||||
@@ -70,8 +70,11 @@ auto RoomSaver::buildYAML(const fkyaml::node& original_yaml, const Room::Data& r
|
|||||||
// --- Tilemap (MAP_HEIGHT filas × MAP_WIDTH columnas, formato flow) ---
|
// --- Tilemap (MAP_HEIGHT filas × MAP_WIDTH columnas, formato flow) ---
|
||||||
out << "\n";
|
out << "\n";
|
||||||
out << "# Tilemap: " << Map::HEIGHT << " filas x " << Map::WIDTH << " columnas @ " << Tile::SIZE << "px/tile\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";
|
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) {
|
for (int row = 0; row < Map::HEIGHT; ++row) {
|
||||||
out << " - [";
|
out << " - [";
|
||||||
for (int col = 0; col < Map::WIDTH; ++col) {
|
for (int col = 0; col < Map::WIDTH; ++col) {
|
||||||
@@ -86,6 +89,23 @@ auto RoomSaver::buildYAML(const fkyaml::node& original_yaml, const Room::Data& r
|
|||||||
out << "]\n";
|
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<int>(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 ---
|
// --- Enemigos ---
|
||||||
if (!room_data.enemies.empty()) {
|
if (!room_data.enemies.empty()) {
|
||||||
out << "\n";
|
out << "\n";
|
||||||
|
|||||||
@@ -680,15 +680,24 @@ void Player::updateVelocity(float delta_time) {
|
|||||||
target = HORIZONTAL_VELOCITY * room_->getConveyorBeltDirection();
|
target = HORIZONTAL_VELOCITY * room_->getConveyorBeltDirection();
|
||||||
} else {
|
} else {
|
||||||
switch (wanna_go_) {
|
switch (wanna_go_) {
|
||||||
case Direction::LEFT: target = -HORIZONTAL_VELOCITY; break;
|
case Direction::LEFT:
|
||||||
case Direction::RIGHT: target = HORIZONTAL_VELOCITY; break;
|
target = -HORIZONTAL_VELOCITY;
|
||||||
default: target = 0.0F; break;
|
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)
|
// Orientación del sprite según la dirección deseada (sin cambiar cuando target=0)
|
||||||
if (target > 0.0F) { sprite_->setFlip(Flip::RIGHT); }
|
if (target > 0.0F) {
|
||||||
else if (target < 0.0F) { sprite_->setFlip(Flip::LEFT); }
|
sprite_->setFlip(Flip::RIGHT);
|
||||||
|
} else if (target < 0.0F) {
|
||||||
|
sprite_->setFlip(Flip::LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
// Inercia:
|
// Inercia:
|
||||||
// - En el aire: inercia completa (arranque y frenada graduales)
|
// - En el aire: inercia completa (arranque y frenada graduales)
|
||||||
|
|||||||
@@ -8,9 +8,8 @@
|
|||||||
#include "utils/defines.hpp" // Para Collision
|
#include "utils/defines.hpp" // Para Collision
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
CollisionMap::CollisionMap(std::vector<int> tile_map, int tile_set_width, int conveyor_belt_direction)
|
CollisionMap::CollisionMap(std::vector<int> collision_tile_map, int conveyor_belt_direction)
|
||||||
: tile_map_(std::move(tile_map)),
|
: collision_tile_map_(std::move(collision_tile_map)),
|
||||||
tile_set_width_(tile_set_width),
|
|
||||||
conveyor_belt_direction_(conveyor_belt_direction) {
|
conveyor_belt_direction_(conveyor_belt_direction) {
|
||||||
// Inicializa todas las superficies de colisión
|
// Inicializa todas las superficies de colisión
|
||||||
initializeSurfaces();
|
initializeSurfaces();
|
||||||
@@ -35,43 +34,21 @@ auto CollisionMap::getTile(SDL_FPoint point) const -> Tile {
|
|||||||
return getTile(POS);
|
return getTile(POS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve el tipo de tile que hay en ese indice
|
// Devuelve el tipo de tile que hay en ese indice (lee del collision_tile_map)
|
||||||
auto CollisionMap::getTile(int index) const -> Tile { // NOLINT(readability-convert-member-functions-to-static)
|
auto CollisionMap::getTile(int index) const -> Tile {
|
||||||
const bool ON_RANGE = (index > -1) && (index < (int)tile_map_.size());
|
if (index < 0 || index >= static_cast<int>(collision_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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
// Obten la coordenada de la cuesta a partir de un punto perteneciente a ese tile
|
||||||
@@ -234,7 +211,7 @@ auto CollisionMap::collectBottomTiles() -> std::vector<int> { // NOLINT(readabi
|
|||||||
|
|
||||||
// Busca todos los tiles de tipo muro que no tengan debajo otro muro
|
// 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)
|
// 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) {
|
if (getTile(i) == Tile::WALL && getTile(i + MAP_WIDTH) != Tile::WALL) {
|
||||||
tile.push_back(i);
|
tile.push_back(i);
|
||||||
|
|
||||||
@@ -256,7 +233,7 @@ auto CollisionMap::collectTopTiles() -> std::vector<int> { // NOLINT(readabilit
|
|||||||
|
|
||||||
// Busca todos los tiles de tipo muro o pasable que no tengan encima un muro
|
// 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)
|
// 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) {
|
if ((getTile(i) == Tile::WALL || getTile(i) == Tile::PASSABLE) && getTile(i - MAP_WIDTH) != Tile::WALL) {
|
||||||
tile.push_back(i);
|
tile.push_back(i);
|
||||||
|
|
||||||
@@ -272,13 +249,12 @@ auto CollisionMap::collectTopTiles() -> std::vector<int> { // NOLINT(readabilit
|
|||||||
return tile;
|
return tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper: recopila tiles animados (para superficies automaticas/conveyor belts)
|
// Helper: recopila tiles conveyor belt
|
||||||
auto CollisionMap::collectAnimatedTiles() -> std::vector<int> { // NOLINT(readability-make-member-function-const)
|
auto CollisionMap::collectConveyorTiles() -> std::vector<int> { // NOLINT(readability-make-member-function-const)
|
||||||
std::vector<int> tile;
|
std::vector<int> tile;
|
||||||
|
|
||||||
// Busca todos los tiles de tipo animado
|
// Busca todos los tiles de tipo conveyor
|
||||||
// Hay que recorrer la habitación por filas (excepto los de la primera fila)
|
for (int i = MAP_WIDTH; i < (int)collision_tile_map_.size(); ++i) {
|
||||||
for (int i = MAP_WIDTH; i < (int)tile_map_.size(); ++i) {
|
|
||||||
if (getTile(i) == Tile::ANIMATED) {
|
if (getTile(i) == Tile::ANIMATED) {
|
||||||
tile.push_back(i);
|
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)
|
void CollisionMap::setLeftSlopes() { // NOLINT(readability-make-member-function-const)
|
||||||
// Recorre la habitación entera por filas buscando tiles de tipo t_slope_l
|
// Recorre la habitación entera por filas buscando tiles de tipo t_slope_l
|
||||||
std::vector<int> found;
|
std::vector<int> 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) {
|
if (getTile(i) == Tile::SLOPE_L) {
|
||||||
found.push_back(i);
|
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)
|
void CollisionMap::setRightSlopes() { // NOLINT(readability-make-member-function-const)
|
||||||
// Recorre la habitación entera por filas buscando tiles de tipo t_slope_r
|
// Recorre la habitación entera por filas buscando tiles de tipo t_slope_r
|
||||||
std::vector<int> found;
|
std::vector<int> 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) {
|
if (getTile(i) == Tile::SLOPE_R) {
|
||||||
found.push_back(i);
|
found.push_back(i);
|
||||||
}
|
}
|
||||||
@@ -505,6 +481,6 @@ void CollisionMap::setRightSlopes() { // NOLINT(readability-make-member-functio
|
|||||||
|
|
||||||
// Calcula las superficies automaticas (conveyor belts)
|
// Calcula las superficies automaticas (conveyor belts)
|
||||||
void CollisionMap::setAutoSurfaces() {
|
void CollisionMap::setAutoSurfaces() {
|
||||||
std::vector<int> tile = collectAnimatedTiles();
|
std::vector<int> tile = collectConveyorTiles();
|
||||||
buildHorizontalLines(tile, conveyor_belt_floors_, false);
|
buildHorizontalLines(tile, conveyor_belt_floors_, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,11 +31,10 @@ class CollisionMap {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
* @param tile_map Vector con índices de tiles de la habitación
|
* @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 tile_set_width Ancho del tileset en tiles (para calcular tipo de tile)
|
|
||||||
* @param conveyor_belt_direction Dirección de las cintas transportadoras (-1, 0, +1)
|
* @param conveyor_belt_direction Dirección de las cintas transportadoras (-1, 0, +1)
|
||||||
*/
|
*/
|
||||||
CollisionMap(std::vector<int> tile_map, int tile_set_width, int conveyor_belt_direction);
|
CollisionMap(std::vector<int> collision_tile_map, int conveyor_belt_direction);
|
||||||
~CollisionMap() = default;
|
~CollisionMap() = default;
|
||||||
|
|
||||||
// Prohibir copia y movimiento
|
// Prohibir copia y movimiento
|
||||||
@@ -89,8 +88,7 @@ class CollisionMap {
|
|||||||
static constexpr int MAP_HEIGHT = ::Map::HEIGHT; // Alto del mapa en tiles
|
static constexpr int MAP_HEIGHT = ::Map::HEIGHT; // Alto del mapa en tiles
|
||||||
|
|
||||||
// --- Datos de la habitación ---
|
// --- Datos de la habitación ---
|
||||||
std::vector<int> tile_map_; // Índices de tiles de la habitación
|
std::vector<int> collision_tile_map_; // Mapa de colisiones por tile
|
||||||
int tile_set_width_; // Ancho del tileset en tiles
|
|
||||||
int conveyor_belt_direction_; // Dirección de conveyor belts
|
int conveyor_belt_direction_; // Dirección de conveyor belts
|
||||||
|
|
||||||
// --- Geometría de colisión ---
|
// --- Geometría de colisión ---
|
||||||
@@ -108,7 +106,7 @@ class CollisionMap {
|
|||||||
// Helpers para recopilar tiles
|
// Helpers para recopilar tiles
|
||||||
auto collectBottomTiles() -> std::vector<int>; // Tiles con superficie inferior
|
auto collectBottomTiles() -> std::vector<int>; // Tiles con superficie inferior
|
||||||
auto collectTopTiles() -> std::vector<int>; // Tiles con superficie superior
|
auto collectTopTiles() -> std::vector<int>; // Tiles con superficie superior
|
||||||
auto collectAnimatedTiles() -> std::vector<int>; // Tiles animados (conveyor belts)
|
auto collectConveyorTiles() -> std::vector<int>; // Tiles conveyor belt
|
||||||
|
|
||||||
// Construcción de geometría
|
// Construcción de geometría
|
||||||
static void buildHorizontalLines(const std::vector<int>& tiles, std::vector<LineHorizontal>& lines, bool is_bottom_surface);
|
static void buildHorizontalLines(const std::vector<int>& tiles, std::vector<LineHorizontal>& lines, bool is_bottom_surface);
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ Room::Room(const std::string& room_path, std::shared_ptr<Scoreboard::Data> data)
|
|||||||
item_manager_ = std::make_unique<ItemManager>(room->number, data_);
|
item_manager_ = std::make_unique<ItemManager>(room->number, data_);
|
||||||
|
|
||||||
initializeRoom(*room);
|
initializeRoom(*room);
|
||||||
// Crea el mapa de colisiones (necesita tile_map_, tile_set_width_, conveyor_belt_direction_)
|
// Crea el mapa de colisiones desde el collision_tile_map
|
||||||
collision_map_ = std::make_unique<CollisionMap>(tile_map_, tile_set_width_, conveyor_belt_direction_);
|
collision_map_ = std::make_unique<CollisionMap>(room->collision_tile_map, conveyor_belt_direction_);
|
||||||
|
|
||||||
// Crea el renderizador del tilemap (necesita tile_map_, tile_set_width_, surface_, bg_color_, 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<TilemapRenderer>(tile_map_, tile_set_width_, surface_, bg_color_, conveyor_belt_direction_);
|
tilemap_renderer_ = std::make_unique<TilemapRenderer>(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
|
// Dibuja el mapa en pantalla
|
||||||
void Room::renderMap() {
|
void Room::renderMap() {
|
||||||
tilemap_renderer_->render();
|
tilemap_renderer_->render();
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ class Room {
|
|||||||
std::string tile_set_file; // Imagen con los gráficos para la habitación
|
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
|
int conveyor_belt_direction{0}; // Sentido en el que arrastran las superficies automáticas de la habitación
|
||||||
std::vector<int> tile_map; // Índice de los tiles a dibujar en la habitación (embebido desde YAML)
|
std::vector<int> tile_map; // Índice de los tiles a dibujar en la habitación (embebido desde YAML)
|
||||||
|
std::vector<int> collision_tile_map; // Mapa de colisiones por tile (0=vacío, 1=sólido)
|
||||||
std::vector<Enemy::Data> enemies; // Listado con los enemigos de la habitación
|
std::vector<Enemy::Data> enemies; // Listado con los enemigos de la habitación
|
||||||
std::vector<Item::Data> items; // Listado con los items que hay en la habitación
|
std::vector<Item::Data> items; // Listado con los items que hay en la habitación
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -119,20 +119,12 @@ void RoomLoader::parseRoomConnections(const fkyaml::node& conn_node, Room::Data&
|
|||||||
: "0";
|
: "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parsea el tilemap de la habitación
|
// Lee un array 2D de enteros desde un nodo YAML
|
||||||
void RoomLoader::parseTilemap(const fkyaml::node& yaml, Room::Data& room, const std::string& file_name, bool verbose) { // NOLINT(readability-convert-member-functions-to-static)
|
static auto readTilemap2D(const fkyaml::node& node) -> std::vector<std::vector<int>> {
|
||||||
if (!yaml.contains("tilemap")) {
|
|
||||||
std::cerr << "Warning: No tilemap found in " << file_name << '\n';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto& tilemap_node = yaml["tilemap"];
|
|
||||||
|
|
||||||
// Read 2D array
|
|
||||||
std::vector<std::vector<int>> tilemap_2d;
|
std::vector<std::vector<int>> tilemap_2d;
|
||||||
tilemap_2d.reserve(Map::HEIGHT);
|
tilemap_2d.reserve(Map::HEIGHT);
|
||||||
|
|
||||||
for (const auto& row_node : tilemap_node) {
|
for (const auto& row_node : node) {
|
||||||
std::vector<int> row;
|
std::vector<int> row;
|
||||||
row.reserve(Map::WIDTH);
|
row.reserve(Map::WIDTH);
|
||||||
|
|
||||||
@@ -143,11 +135,36 @@ void RoomLoader::parseTilemap(const fkyaml::node& yaml, Room::Data& room, const
|
|||||||
tilemap_2d.push_back(row);
|
tilemap_2d.push_back(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert to 1D flat array
|
return tilemap_2d;
|
||||||
room.tile_map = flattenTilemap(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) {
|
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';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,9 +95,7 @@ void Scoreboard::fillTexture() {
|
|||||||
// Valores formateados
|
// Valores formateados
|
||||||
const std::string LIVES_STR = std::to_string(data_->lives);
|
const std::string LIVES_STR = std::to_string(data_->lives);
|
||||||
const std::string ITEMS_STR = std::to_string(data_->items);
|
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)
|
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);
|
||||||
+ 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) ---
|
// --- Línea 1: vides X - objectes X - temps MM:SS (centrada) ---
|
||||||
const std::string LIVES_LABEL = Locale::get()->get("scoreboard.lives");
|
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");
|
const std::string TIME_LABEL = Locale::get()->get("scoreboard.time");
|
||||||
|
|
||||||
// Ancho total: labels proporcionales + valores monoespaciados
|
// Ancho total: labels proporcionales + valores monoespaciados
|
||||||
const int LINE1_W = text->length(LIVES_LABEL) + text->lengthMono(LIVES_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);
|
||||||
+ 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;
|
int x = (CANVAS_W - LINE1_W) / 2;
|
||||||
text->writeColored(x, LINE1_Y, LIVES_LABEL, LABEL_COLOR);
|
text->writeColored(x, LINE1_Y, LIVES_LABEL, LABEL_COLOR);
|
||||||
|
|||||||
@@ -120,7 +120,6 @@ class Game {
|
|||||||
// Variables de demo mode
|
// Variables de demo mode
|
||||||
DemoData demo_; // Variables para el modo demo
|
DemoData demo_; // Variables para el modo demo
|
||||||
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
// Variables de debug para arrastre con ratón
|
// Variables de debug para arrastre con ratón
|
||||||
bool debug_dragging_player_{false}; // Indica si estamos arrastrando al jugador con el ratón
|
bool debug_dragging_player_{false}; // Indica si estamos arrastrando al jugador con el ratón
|
||||||
|
|||||||
@@ -233,7 +233,6 @@ void Title::updateMainMenu(float delta_time) {
|
|||||||
|
|
||||||
// Actualiza el estado CHEEVOS_MENU
|
// Actualiza el estado CHEEVOS_MENU
|
||||||
void Title::updateCheevosMenu(float delta_time) {
|
void Title::updateCheevosMenu(float delta_time) {
|
||||||
|
|
||||||
// Determina la velocidad objetivo basada en el input
|
// Determina la velocidad objetivo basada en el input
|
||||||
float target_velocity = 0.0F;
|
float target_velocity = 0.0F;
|
||||||
if (Input::get()->checkAction(InputAction::RIGHT, Input::ALLOW_REPEAT)) {
|
if (Input::get()->checkAction(InputAction::RIGHT, Input::ALLOW_REPEAT)) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <array> // Para std::array
|
#include <array> // Para std::array
|
||||||
#include <memory> // Para shared_ptr
|
#include <memory> // Para shared_ptr
|
||||||
#include <string> // Para string
|
#include <string> // Para string
|
||||||
|
|
||||||
#include "game/scene_manager.hpp" // Para SceneManager::Scene
|
#include "game/scene_manager.hpp" // Para SceneManager::Scene
|
||||||
#include "utils/delta_timer.hpp" // Para DeltaTimer
|
#include "utils/delta_timer.hpp" // Para DeltaTimer
|
||||||
class Sprite; // Forward declaration
|
class Sprite; // Forward declaration
|
||||||
|
|||||||
@@ -707,6 +707,15 @@ static auto cmdEdit(const std::vector<std::string>& args) -> std::string { // N
|
|||||||
if (args[1] == "INFO") { return MapEditor::get()->showInfo(show); }
|
if (args[1] == "INFO") { return MapEditor::get()->showInfo(show); }
|
||||||
if (args[1] == "GRID") { return MapEditor::get()->showGrid(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 <color>
|
// EDIT MAPBG/MAPCONN <color>
|
||||||
if (args[0] == "MAPBG" && args.size() >= 2) {
|
if (args[0] == "MAPBG" && args.size() >= 2) {
|
||||||
if ((MapEditor::get() == nullptr) || !MapEditor::get()->isActive()) { return "Editor not active"; }
|
if ((MapEditor::get() == nullptr) || !MapEditor::get()->isActive()) { return "Editor not active"; }
|
||||||
|
|||||||
Reference in New Issue
Block a user