Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3442b9b481 | ||
|
|
8746ee9ec9 | ||
|
|
ef7fbf4027 | ||
|
|
964c32dd0d | ||
|
|
970fe2b4db | ||
|
|
f816e75cc0 | ||
|
|
2e8df45b38 | ||
|
|
643e5442c3 | ||
|
|
82ccf65ce1 | ||
|
|
1ae6912be5 | ||
|
|
c003e6665e | ||
|
|
a254fdd669 | ||
|
|
c0362abf67 | ||
|
|
d13313503c | ||
|
|
2a78c78e77 | ||
|
|
10e16d7905 | ||
|
|
ecb4625465 | ||
|
|
b4e36944d7 | ||
|
|
9b09ccb765 | ||
|
|
94213f9fd6 | ||
|
|
f591aa82fd | ||
|
|
2ef5968e0d | ||
|
|
ca03a1307e | ||
|
|
fe916d263f | ||
|
|
de7233a012 | ||
|
|
d26ecec04f | ||
|
|
fddea0c449 | ||
|
|
2c1c1a442b | ||
|
|
d1948afe4b | ||
|
|
ac06b05332 | ||
|
|
7d11dde0b1 | ||
|
|
73add013dd | ||
|
|
4e2ba827e3 | ||
|
|
9ac0c0cb74 | ||
|
|
11a909b58d | ||
|
|
17cf6e0636 | ||
|
|
7d0aca506a | ||
|
|
7cd7b4dc4f | ||
|
|
6d4f606eeb | ||
|
|
1ccd444aad | ||
|
|
3bfca35f3a | ||
|
|
3e5217066f | ||
|
|
4da50571eb | ||
|
|
d4593d0686 | ||
|
|
a53cf4b797 | ||
|
|
bcbf990a5f | ||
|
|
45514ae2f4 | ||
|
|
0847e9c544 | ||
|
|
27cf2f032d | ||
|
|
6f6aa182f7 | ||
|
|
b65eeb7aaa | ||
|
|
37fdcb4751 | ||
|
|
4739354875 | ||
|
|
2879cbdb17 | ||
|
|
38070b33aa | ||
|
|
9f0a566ffb | ||
|
|
6397f9d4eb | ||
|
|
72384c3113 | ||
|
|
9dc7ff0da3 | ||
|
|
1d43a77800 | ||
|
|
39eda56c9d | ||
|
|
a351f920ba | ||
|
|
72642dc10e | ||
|
|
404db74889 | ||
|
|
91f664c4d5 | ||
|
|
ce55aeeadc | ||
|
|
8f66961c7b | ||
|
|
121558b1fd | ||
|
|
df60709e6d | ||
|
|
d208ba02df | ||
|
|
5db3bb0bd0 | ||
|
|
9ad21eb5bb | ||
|
|
4752eb8ad7 | ||
|
|
887b8f3aa3 | ||
|
|
2f3643f09c | ||
|
|
cc529afeb2 | ||
|
|
15a7c4e18a | ||
|
|
7d725f99f4 | ||
|
|
e9ef6565a7 | ||
|
|
47bb92144e | ||
|
|
d3698a1504 | ||
|
|
42062dca55 | ||
|
|
5502191725 | ||
|
|
8e2865efbd | ||
|
|
99eb42b319 | ||
|
|
8243e95ef1 | ||
|
|
0752df0f62 | ||
|
|
98303f7ce8 | ||
|
|
7982df922b | ||
|
|
8da18a6a86 | ||
|
|
3b05704e97 | ||
|
|
00594d9eb2 | ||
|
|
af25a31639 | ||
|
|
f52e7f4682 | ||
|
|
e2f6d326aa | ||
|
|
b18bd4d021 | ||
|
|
738cde12bb | ||
|
|
b147590a39 | ||
|
|
d52cc1c509 | ||
|
|
9d4f92c98b | ||
|
|
f51fe3d820 | ||
|
|
fe17c35c67 | ||
|
|
8fd06887d1 | ||
|
|
580c13e854 | ||
|
|
645db217fa | ||
|
|
cd961cf718 | ||
|
|
c0214b233b | ||
|
|
d054d1b246 | ||
|
|
cd5bb94223 | ||
|
|
178ce486c2 | ||
|
|
811c6c482d | ||
|
|
59cd9b524c | ||
|
|
28e55a0615 | ||
|
|
5c5cd1d5da | ||
|
|
377e5d0b97 | ||
|
|
648a5932f8 | ||
|
|
b54f3fc622 | ||
|
|
63bb41425a | ||
|
|
9a2c677153 | ||
|
|
4a9a037cd8 | ||
|
|
67b06c0a10 | ||
|
|
368f9d2d6a | ||
|
|
651db50a93 |
No files matched your search
@@ -33,7 +33,10 @@ configure_file(${CMAKE_SOURCE_DIR}/source/version.h.in ${CMAKE_BINARY_DIR}/versi
|
|||||||
# Sources comuns del sistema d'entitats: s'afegeixen tant a l'executable
|
# Sources comuns del sistema d'entitats: s'afegeixen tant a l'executable
|
||||||
# principal com al smoke test. Mantenir-los en variable separada evita
|
# principal com al smoke test. Mantenir-los en variable separada evita
|
||||||
# duplicació entre els dos targets.
|
# duplicació entre els dos targets.
|
||||||
set(ENTITY_SOURCES
|
# Entitats sense dependència directa amb Player.cpp: les enllacen tant
|
||||||
|
# l'executable principal com el test_entities_smoke (que evita arrossegar
|
||||||
|
# l'stack del jugador i les seues dependències pesades).
|
||||||
|
set(ENTITY_SOURCES_BASE
|
||||||
source/game/entities/entity.cpp
|
source/game/entities/entity.cpp
|
||||||
source/game/entities/animation_component.cpp
|
source/game/entities/animation_component.cpp
|
||||||
source/game/entities/event_bus.cpp
|
source/game/entities/event_bus.cpp
|
||||||
@@ -47,21 +50,33 @@ set(ENTITY_SOURCES
|
|||||||
source/game/entities/concrete/rolling_rock.cpp
|
source/game/entities/concrete/rolling_rock.cpp
|
||||||
source/game/entities/concrete/wall_trap.cpp
|
source/game/entities/concrete/wall_trap.cpp
|
||||||
source/game/entities/concrete/floor_trap.cpp
|
source/game/entities/concrete/floor_trap.cpp
|
||||||
|
source/game/entities/concrete/hole.cpp
|
||||||
source/game/entities/concrete/dust.cpp
|
source/game/entities/concrete/dust.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Entitats que criden directament símbols de Player (com WhipAttack via
|
||||||
|
# `enterHurt`/`getBaseBox`): només van a l'executable principal.
|
||||||
|
set(ENTITY_SOURCES
|
||||||
|
${ENTITY_SOURCES_BASE}
|
||||||
|
source/game/entities/concrete/whip_attack.cpp
|
||||||
|
)
|
||||||
|
|
||||||
set(APP_SOURCES
|
set(APP_SOURCES
|
||||||
source/main.cpp
|
source/main.cpp
|
||||||
source/core/system/director.cpp
|
source/core/system/director.cpp
|
||||||
source/core/audio/audio.cpp
|
source/core/audio/audio.cpp
|
||||||
source/core/audio/audio_adapter.cpp
|
source/core/audio/audio_adapter.cpp
|
||||||
|
source/core/audio/audio_effects.cpp
|
||||||
source/core/audio/jail_audio.cpp
|
source/core/audio/jail_audio.cpp
|
||||||
|
source/core/audio/sound_effects_config.cpp
|
||||||
source/core/locale/locale.cpp
|
source/core/locale/locale.cpp
|
||||||
source/core/ui/ui_config.cpp
|
source/core/ui/ui_config.cpp
|
||||||
source/core/input/key_config.cpp
|
source/core/input/key_config.cpp
|
||||||
source/core/input/global_inputs.cpp
|
source/core/input/global_inputs.cpp
|
||||||
source/core/input/input_state.cpp
|
source/core/input/input_state.cpp
|
||||||
source/core/input/gamepad_manager.cpp
|
source/core/input/gamepad_manager.cpp
|
||||||
|
source/core/input/gamepad_bindings.cpp
|
||||||
|
source/core/input/define_buttons.cpp
|
||||||
source/core/input/mouse.cpp
|
source/core/input/mouse.cpp
|
||||||
source/core/rendering/screen.cpp
|
source/core/rendering/screen.cpp
|
||||||
source/core/rendering/canvas.cpp
|
source/core/rendering/canvas.cpp
|
||||||
@@ -76,6 +91,7 @@ set(APP_SOURCES
|
|||||||
source/core/rendering/sprite/sprite.cpp
|
source/core/rendering/sprite/sprite.cpp
|
||||||
source/core/rendering/sprite/moving_sprite.cpp
|
source/core/rendering/sprite/moving_sprite.cpp
|
||||||
source/core/rendering/sprite/animated_sprite.cpp
|
source/core/rendering/sprite/animated_sprite.cpp
|
||||||
|
source/core/rendering/sprite/animated_sprite_parser.cpp
|
||||||
source/core/rendering/sdl3gpu/sdl3gpu_shader.cpp
|
source/core/rendering/sdl3gpu/sdl3gpu_shader.cpp
|
||||||
source/core/rendering/sdl3gpu/viewport.cpp
|
source/core/rendering/sdl3gpu/viewport.cpp
|
||||||
source/core/rendering/sdl3gpu/pipelines/crtpi_pipeline.cpp
|
source/core/rendering/sdl3gpu/pipelines/crtpi_pipeline.cpp
|
||||||
@@ -95,15 +111,24 @@ set(APP_SOURCES
|
|||||||
source/game/scenes/title_scene.cpp
|
source/game/scenes/title_scene.cpp
|
||||||
source/game/scenes/intro_scene.cpp
|
source/game/scenes/intro_scene.cpp
|
||||||
source/game/scenes/game_scene.cpp
|
source/game/scenes/game_scene.cpp
|
||||||
|
source/game/scenes/room_fsm.cpp
|
||||||
source/game/entities/player.cpp
|
source/game/entities/player.cpp
|
||||||
source/game/map/map.cpp
|
source/game/map/map.cpp
|
||||||
source/game/map/tilemap.cpp
|
source/game/map/tilemap.cpp
|
||||||
source/game/map/tilemap_writer.cpp
|
source/game/map/tilemap_writer.cpp
|
||||||
|
# Writer surgical de claus dins de `geometry:` (door_col), paral·lel
|
||||||
|
# al TilemapWriter. Només Debug.
|
||||||
|
source/game/map/map_writer.cpp
|
||||||
source/game/map/paint_layer.cpp
|
source/game/map/paint_layer.cpp
|
||||||
|
source/game/levels/level_manager.cpp
|
||||||
# Mòdul editor (només activa contingut en Debug via `#ifdef _DEBUG`).
|
# Mòdul editor (només activa contingut en Debug via `#ifdef _DEBUG`).
|
||||||
# En Release el fitxer compila a un object buit i l'enllaçador no
|
# En Release els fitxers compilen a object buit i l'enllaçador no
|
||||||
# arrossega cap símbol del joc final.
|
# arrossega cap símbol del joc final.
|
||||||
source/game/editor/editor.cpp
|
source/game/editor/editor.cpp
|
||||||
|
source/game/editor/editor_config.cpp
|
||||||
|
# Writer del bloc `entities:` del YAML del nivell, paral·lel al
|
||||||
|
# TilemapWriter pero per a la persistència de l'editor d'entitats.
|
||||||
|
source/game/entities/entity_writer.cpp
|
||||||
${ENTITY_SOURCES}
|
${ENTITY_SOURCES}
|
||||||
# Fitxer només del binari principal: `loadFromLevel` depèn de
|
# Fitxer només del binari principal: `loadFromLevel` depèn de
|
||||||
# Resource::Cache (→ Surface → GIF → àudio). Separat per no arrossegar
|
# Resource::Cache (→ Surface → GIF → àudio). Separat per no arrossegar
|
||||||
@@ -162,6 +187,15 @@ endif()
|
|||||||
|
|
||||||
add_executable(${PROJECT_NAME} ${APP_SOURCES})
|
add_executable(${PROJECT_NAME} ${APP_SOURCES})
|
||||||
|
|
||||||
|
# Silencia warnings de codi de tercers (mateixa filosofia que el
|
||||||
|
# .clang-tidy de source/external/). Només afecta aquests TUs concrets;
|
||||||
|
# la resta del codi continua compilant amb -Wall -Wextra -Wpedantic.
|
||||||
|
set_source_files_properties(
|
||||||
|
source/external/stb_image_write_impl.cpp
|
||||||
|
source/external/stb_vorbis_impl.cpp
|
||||||
|
PROPERTIES COMPILE_OPTIONS "-Wno-missing-field-initializers;-Wno-deprecated-declarations"
|
||||||
|
)
|
||||||
|
|
||||||
if(NOT APPLE AND GLSLC_EXE)
|
if(NOT APPLE AND GLSLC_EXE)
|
||||||
add_dependencies(${PROJECT_NAME} shaders)
|
add_dependencies(${PROJECT_NAME} shaders)
|
||||||
endif()
|
endif()
|
||||||
@@ -322,10 +356,11 @@ option(BUILD_TESTS "Build smoke tests" ON)
|
|||||||
if(BUILD_TESTS)
|
if(BUILD_TESTS)
|
||||||
add_executable(test_entities_smoke
|
add_executable(test_entities_smoke
|
||||||
tests/test_entities_smoke.cpp
|
tests/test_entities_smoke.cpp
|
||||||
|
tests/hole_player_stubs.cpp
|
||||||
source/core/resources/resource_helper.cpp
|
source/core/resources/resource_helper.cpp
|
||||||
source/core/resources/resource_pack.cpp
|
source/core/resources/resource_pack.cpp
|
||||||
source/game/map/map.cpp
|
source/game/map/map.cpp
|
||||||
${ENTITY_SOURCES}
|
${ENTITY_SOURCES_BASE}
|
||||||
)
|
)
|
||||||
target_include_directories(test_entities_smoke PRIVATE
|
target_include_directories(test_entities_smoke PRIVATE
|
||||||
"${CMAKE_SOURCE_DIR}/source"
|
"${CMAKE_SOURCE_DIR}/source"
|
||||||
@@ -338,6 +373,30 @@ if(BUILD_TESTS)
|
|||||||
COMMAND test_entities_smoke
|
COMMAND test_entities_smoke
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||||
|
|
||||||
|
# Smoke del WhipAttack. Inclou tot l'stack d'entitats + whip_attack.cpp.
|
||||||
|
# `whip_attack_player_stubs.cpp` proveeix símbols mínims de Player per
|
||||||
|
# satisfer el linker sense arrossegar audio/gamepad/screen — els tests
|
||||||
|
# del whip s'enfoquen a hitbox + Mummy, no a friendly fire.
|
||||||
|
add_executable(test_whip_attack
|
||||||
|
tests/test_whip_attack.cpp
|
||||||
|
tests/whip_attack_player_stubs.cpp
|
||||||
|
tests/hole_player_stubs.cpp
|
||||||
|
source/core/resources/resource_helper.cpp
|
||||||
|
source/core/resources/resource_pack.cpp
|
||||||
|
source/game/map/map.cpp
|
||||||
|
${ENTITY_SOURCES_BASE}
|
||||||
|
source/game/entities/concrete/whip_attack.cpp
|
||||||
|
)
|
||||||
|
target_include_directories(test_whip_attack PRIVATE
|
||||||
|
"${CMAKE_SOURCE_DIR}/source"
|
||||||
|
"${CMAKE_BINARY_DIR}"
|
||||||
|
)
|
||||||
|
target_link_libraries(test_whip_attack PRIVATE SDL3::SDL3)
|
||||||
|
target_compile_options(test_whip_attack PRIVATE -Wall -Wextra -Wpedantic)
|
||||||
|
add_test(NAME whip_attack
|
||||||
|
COMMAND test_whip_attack
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||||
|
|
||||||
# Smoke del flux d'escenes i del parser de debug.yaml. Stand-alone:
|
# Smoke del flux d'escenes i del parser de debug.yaml. Stand-alone:
|
||||||
# només enllaça els helpers purs (debug_config, placeholder_input,
|
# només enllaça els helpers purs (debug_config, placeholder_input,
|
||||||
# key_config) perquè la integració completa dels placeholders arrossegaria
|
# key_config) perquè la integració completa dels placeholders arrossegaria
|
||||||
@@ -374,4 +433,45 @@ if(BUILD_TESTS)
|
|||||||
add_test(NAME tilemap_writer
|
add_test(NAME tilemap_writer
|
||||||
COMMAND test_tilemap_writer
|
COMMAND test_tilemap_writer
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||||
|
|
||||||
|
# Smoke de la FSM de sala (RoomFsm). Cobreix loadConfig (timings i
|
||||||
|
# corbes des de YAML), advance (transicions entre estats), i
|
||||||
|
# formatRoomTitle (locale + substitució `{n}`). Stand-alone: no
|
||||||
|
# arrossega Audio/Screen/Player/EntityManager — només els helpers
|
||||||
|
# purs de la FSM, Locale i UiConfig.
|
||||||
|
add_executable(test_game_fsm
|
||||||
|
tests/test_game_fsm.cpp
|
||||||
|
source/game/scenes/room_fsm.cpp
|
||||||
|
source/core/locale/locale.cpp
|
||||||
|
source/core/ui/ui_config.cpp
|
||||||
|
source/core/resources/resource_helper.cpp
|
||||||
|
source/core/resources/resource_pack.cpp
|
||||||
|
source/utils/easing.cpp
|
||||||
|
)
|
||||||
|
target_include_directories(test_game_fsm PRIVATE
|
||||||
|
"${CMAKE_SOURCE_DIR}/source"
|
||||||
|
"${CMAKE_BINARY_DIR}"
|
||||||
|
)
|
||||||
|
target_link_libraries(test_game_fsm PRIVATE SDL3::SDL3)
|
||||||
|
target_compile_options(test_game_fsm PRIVATE -Wall -Wextra -Wpedantic)
|
||||||
|
add_test(NAME game_fsm
|
||||||
|
COMMAND test_game_fsm
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||||
|
|
||||||
|
# Smoke del parser d'animacions amb suport de flip H/V. Stand-alone:
|
||||||
|
# només enllaça `animated_sprite_parser.cpp`, que és la part del motor
|
||||||
|
# que NO depèn de Resource::Cache ni de Surface — el parser és pure
|
||||||
|
# YAML-in / dades-out, així que no cal arrossegar tot l'stack.
|
||||||
|
add_executable(test_animated_sprite_flip
|
||||||
|
tests/test_animated_sprite_flip.cpp
|
||||||
|
source/core/rendering/sprite/animated_sprite_parser.cpp
|
||||||
|
)
|
||||||
|
target_include_directories(test_animated_sprite_flip PRIVATE
|
||||||
|
"${CMAKE_SOURCE_DIR}/source"
|
||||||
|
)
|
||||||
|
target_link_libraries(test_animated_sprite_flip PRIVATE SDL3::SDL3)
|
||||||
|
target_compile_options(test_animated_sprite_flip PRIVATE -Wall -Wextra -Wpedantic)
|
||||||
|
add_test(NAME animated_sprite_flip
|
||||||
|
COMMAND test_animated_sprite_flip
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||||
endif()
|
endif()
|
||||||
@@ -1,13 +1,43 @@
|
|||||||
PROJECT := aee_2026
|
PROJECT := aee_2026
|
||||||
BUILDDIR := build
|
BUILDDIR := build
|
||||||
JOBS ?= $(shell nproc 2>/dev/null || echo 4)
|
|
||||||
|
|
||||||
# VERSION (única font de veritat: source/utils/defines.hpp)
|
# Detecció de plataforma. En Windows CMake defaulteja a "NMake Makefiles"
|
||||||
VERSION := v$(shell grep 'constexpr const char\* VERSION' source/utils/defines.hpp | sed -E 's/.*VERSION = "([^"]+)".*/\1/')
|
# (que requereix Visual Studio); forcem MinGW Makefiles per usar el g++ de
|
||||||
|
# MinGW. nproc tampoc existeix en cmd.exe → fem servir NUMBER_OF_PROCESSORS.
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
# Si Make corre dins MSYS2/Git Bash/MinGW, $(shell ...) usa sh.exe i
|
||||||
|
# "NUL" NO és dispositiu — un redirect "2>NUL" crearia un fitxer literal
|
||||||
|
# anomenat NUL al cwd (i en Windows es complica esborrar-lo). Detectem
|
||||||
|
# MSYSTEM per usar /dev/null en aquests entorns; només cmd.exe pur necessita NUL.
|
||||||
|
ifneq ($(MSYSTEM),)
|
||||||
|
NULDEV := /dev/null
|
||||||
|
else
|
||||||
|
NULDEV := NUL
|
||||||
|
endif
|
||||||
|
JOBS ?= $(NUMBER_OF_PROCESSORS)
|
||||||
|
# Si Ninja està al PATH, l'usem (més ràpid i paral·lelitza millor).
|
||||||
|
# Si no, caiem a MinGW Makefiles. Sense aquesta selecció CMake
|
||||||
|
# defaultejaria a "NMake Makefiles", que requereix Visual Studio.
|
||||||
|
HAS_NINJA := $(shell ninja --version 2>$(NULDEV))
|
||||||
|
ifneq ($(HAS_NINJA),)
|
||||||
|
CMAKE_GEN := -G "Ninja"
|
||||||
|
else
|
||||||
|
CMAKE_GEN := -G "MinGW Makefiles"
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
NULDEV := /dev/null
|
||||||
|
JOBS ?= $(shell nproc 2>/dev/null || echo 4)
|
||||||
|
CMAKE_GEN :=
|
||||||
|
endif
|
||||||
|
|
||||||
|
# VERSION (única font de veritat: source/utils/defines.hpp).
|
||||||
|
# Lazy (=): només es calcula quan s'invoca un target que la usa
|
||||||
|
# (show-version/help). Evita executar grep/sed des de cmd.exe en `make debug`.
|
||||||
|
VERSION = v$(shell grep 'constexpr const char\* VERSION' source/utils/defines.hpp | sed -E 's/.*VERSION = "([^"]+)".*/\1/')
|
||||||
|
|
||||||
# GIT_HASH calculat al host i passat a CMake (evita problemes si CMake corre en
|
# GIT_HASH calculat al host i passat a CMake (evita problemes si CMake corre en
|
||||||
# entorns sense accés a git, p.ex. Docker/emscripten).
|
# entorns sense accés a git, p.ex. Docker/emscripten).
|
||||||
GIT_HASH := $(shell git rev-parse --short=7 HEAD 2>/dev/null)
|
GIT_HASH := $(shell git rev-parse --short=7 HEAD 2>$(NULDEV))
|
||||||
ifeq ($(GIT_HASH),)
|
ifeq ($(GIT_HASH),)
|
||||||
GIT_HASH := unknown
|
GIT_HASH := unknown
|
||||||
endif
|
endif
|
||||||
@@ -26,11 +56,11 @@ CMAKE_DEFS := -DGIT_HASH=$(GIT_HASH)
|
|||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
all:
|
all:
|
||||||
@cmake -S . -B $(BUILDDIR) -DCMAKE_BUILD_TYPE=Release $(CMAKE_DEFS)
|
@cmake -S . -B $(BUILDDIR) $(CMAKE_GEN) -DCMAKE_BUILD_TYPE=Release $(CMAKE_DEFS)
|
||||||
@cmake --build $(BUILDDIR) -j$(JOBS)
|
@cmake --build $(BUILDDIR) -j$(JOBS)
|
||||||
|
|
||||||
debug:
|
debug:
|
||||||
@cmake -S . -B $(BUILDDIR) -DCMAKE_BUILD_TYPE=Debug $(CMAKE_DEFS)
|
@cmake -S . -B $(BUILDDIR) $(CMAKE_GEN) -DCMAKE_BUILD_TYPE=Debug $(CMAKE_DEFS)
|
||||||
@cmake --build $(BUILDDIR) -j$(JOBS)
|
@cmake --build $(BUILDDIR) -j$(JOBS)
|
||||||
|
|
||||||
run: all
|
run: all
|
||||||
@@ -57,7 +87,7 @@ rebuild: clean all
|
|||||||
# del pack encara que res no hagi canviat dins data/. L'empaquetat també es fa
|
# del pack encara que res no hagi canviat dins data/. L'empaquetat també es fa
|
||||||
# automàticament a cada `make`/`make debug` via el target CMake `resource_pack`.
|
# automàticament a cada `make`/`make debug` via el target CMake `resource_pack`.
|
||||||
pack:
|
pack:
|
||||||
@cmake -S . -B $(BUILDDIR) -DCMAKE_BUILD_TYPE=Release $(CMAKE_DEFS)
|
@cmake -S . -B $(BUILDDIR) $(CMAKE_GEN) -DCMAKE_BUILD_TYPE=Release $(CMAKE_DEFS)
|
||||||
@cmake --build $(BUILDDIR) --target pack_resources
|
@cmake --build $(BUILDDIR) --target pack_resources
|
||||||
@./$(BUILDDIR)/pack_resources data $(BUILDDIR)/resources.pack
|
@./$(BUILDDIR)/pack_resources data $(BUILDDIR)/resources.pack
|
||||||
|
|
||||||
@@ -74,23 +104,23 @@ controllerdb:
|
|||||||
# CODE QUALITY (delegados a cmake)
|
# CODE QUALITY (delegados a cmake)
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
format:
|
format:
|
||||||
@cmake -S . -B $(BUILDDIR) -DCMAKE_BUILD_TYPE=Release $(CMAKE_DEFS)
|
@cmake -S . -B $(BUILDDIR) $(CMAKE_GEN) -DCMAKE_BUILD_TYPE=Release $(CMAKE_DEFS)
|
||||||
@cmake --build $(BUILDDIR) --target format
|
@cmake --build $(BUILDDIR) --target format
|
||||||
|
|
||||||
format-check:
|
format-check:
|
||||||
@cmake -S . -B $(BUILDDIR) -DCMAKE_BUILD_TYPE=Release $(CMAKE_DEFS)
|
@cmake -S . -B $(BUILDDIR) $(CMAKE_GEN) -DCMAKE_BUILD_TYPE=Release $(CMAKE_DEFS)
|
||||||
@cmake --build $(BUILDDIR) --target format-check
|
@cmake --build $(BUILDDIR) --target format-check
|
||||||
|
|
||||||
tidy:
|
tidy:
|
||||||
@cmake -S . -B $(BUILDDIR) -DCMAKE_BUILD_TYPE=Release $(CMAKE_DEFS)
|
@cmake -S . -B $(BUILDDIR) $(CMAKE_GEN) -DCMAKE_BUILD_TYPE=Release $(CMAKE_DEFS)
|
||||||
@cmake --build $(BUILDDIR) --target tidy
|
@cmake --build $(BUILDDIR) --target tidy
|
||||||
|
|
||||||
tidy-fix:
|
tidy-fix:
|
||||||
@cmake -S . -B $(BUILDDIR) -DCMAKE_BUILD_TYPE=Release $(CMAKE_DEFS)
|
@cmake -S . -B $(BUILDDIR) $(CMAKE_GEN) -DCMAKE_BUILD_TYPE=Release $(CMAKE_DEFS)
|
||||||
@cmake --build $(BUILDDIR) --target tidy-fix
|
@cmake --build $(BUILDDIR) --target tidy-fix
|
||||||
|
|
||||||
cppcheck:
|
cppcheck:
|
||||||
@cmake -S . -B $(BUILDDIR) -DCMAKE_BUILD_TYPE=Release $(CMAKE_DEFS)
|
@cmake -S . -B $(BUILDDIR) $(CMAKE_GEN) -DCMAKE_BUILD_TYPE=Release $(CMAKE_DEFS)
|
||||||
@cmake --build $(BUILDDIR) --target cppcheck
|
@cmake --build $(BUILDDIR) --target cppcheck
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Tema visual de l'editor de tilemap (només Debug). Carregat per
|
||||||
|
# EditorConfig a l'arrencada; les claus absents cauen als valors compilats
|
||||||
|
# a Defaults::Editor (veure source/utils/defaults.hpp).
|
||||||
|
|
||||||
|
picker:
|
||||||
|
margin: 8 # px entre canvas i caixa del picker
|
||||||
|
spacing: 1 # px de separació entre tiles dins del picker
|
||||||
|
|
||||||
|
# Colors ARGB en hex. Accepta enter (0xFF2244FF) o cadena ("#FF2244FF").
|
||||||
|
colors:
|
||||||
|
border: "0xFF2244FF" # vora 1 px que envolta canvas i picker
|
||||||
|
picker_bg: "0xFF101824" # fons del picker
|
||||||
|
picker_hover: "0xFFFFFFFF" # vora 1 px del tile sota el cursor
|
||||||
@@ -1,10 +1,19 @@
|
|||||||
name: door
|
name: door
|
||||||
type: interactable
|
type: interactable
|
||||||
|
editable: true
|
||||||
sprite:
|
sprite:
|
||||||
path: door.gif
|
path: door.gif
|
||||||
size: [48, 32]
|
size: [48, 32]
|
||||||
tile_size: [3, 2]
|
tile_size: [3, 2]
|
||||||
collision:
|
collision:
|
||||||
|
# Caixa de col·lisió: 16×24 centrada al sprite 48×32. Coincideix amb el
|
||||||
|
# tile central transitable (els 16 px del passadís de sortida) i es
|
||||||
|
# restringeix a la franja del mur trasser (24 px d'alçada). Així
|
||||||
|
# `checkPlayerCollisions` només dispara `onPlayerContact` quan el
|
||||||
|
# jugador entra al forat real, no als marcs flanquejants ni als 8 px
|
||||||
|
# superiors que queden tapats pel HUD.
|
||||||
|
size: [16, 24]
|
||||||
|
offset: [16, 8]
|
||||||
# Porta = mur infranquejable. Igual que el sarc, alçada efectiva
|
# Porta = mur infranquejable. Igual que el sarc, alçada efectiva
|
||||||
# infinita per impedir que un jugador la salte per damunt.
|
# infinita per impedir que un jugador la salte per damunt.
|
||||||
height: 999
|
height: 999
|
||||||
|
|||||||
|
After Width: | Height: | Size: 182 B |
@@ -0,0 +1,27 @@
|
|||||||
|
name: hole
|
||||||
|
type: static_hazard
|
||||||
|
editable: true
|
||||||
|
sprite:
|
||||||
|
path: hole.gif
|
||||||
|
size: [16, 16]
|
||||||
|
tile_size: [1, 1]
|
||||||
|
collision:
|
||||||
|
# Forat: ocupa el tile sencer (16×16). `height: 0` deixa que un salt
|
||||||
|
# AIRBORNE el creui sense disparar el contacte (el filtre d'altura de
|
||||||
|
# `checkPlayerCollisions` el descarta quan `jump_z_ > height`). El
|
||||||
|
# bucle de contacte admet l'entitat per `flags.triggers_on_overlap`,
|
||||||
|
# encara que `flags.collides` sigui false.
|
||||||
|
size: [16, 16]
|
||||||
|
height: 0
|
||||||
|
flags:
|
||||||
|
collides: false
|
||||||
|
interactable: false
|
||||||
|
# Avui el loader no llig el bloc `flags:` (és declaratiu); el flag
|
||||||
|
# real es fixa al constructor C++ de `Hole`. Mantenim el camp per
|
||||||
|
# coherència amb la resta de plantilles i per quan es cablege la
|
||||||
|
# lectura genèrica de flags.
|
||||||
|
triggers_on_overlap: true
|
||||||
|
animations:
|
||||||
|
idle: { frames: [0], fps: 1, loop: true }
|
||||||
|
stats:
|
||||||
|
damage: 0
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
name: mummy
|
name: mummy
|
||||||
type: dynamic_hazard
|
type: dynamic_hazard
|
||||||
|
editable: true
|
||||||
sprite:
|
sprite:
|
||||||
path: mummy.gif
|
path: mummy.gif
|
||||||
size: [16, 32]
|
size: [16, 32]
|
||||||
@@ -18,23 +19,42 @@ collision:
|
|||||||
# jugador amb jump_z > height no col·lisiona amb la momia (la salta
|
# jugador amb jump_z > height no col·lisiona amb la momia (la salta
|
||||||
# per damunt). Amb impulse=240 + gravity=600 el pic ronda els 48 px,
|
# per damunt). Amb impulse=240 + gravity=600 el pic ronda els 48 px,
|
||||||
# així que 24 deixa marge per esquivar amb un salt no perfecte.
|
# així que 24 deixa marge per esquivar amb un salt no perfecte.
|
||||||
height: 24
|
height: 12
|
||||||
flags:
|
flags:
|
||||||
collides: true
|
collides: true
|
||||||
interactable: false
|
interactable: false
|
||||||
# Strip de 12 frames en graella 4×3 (mateix esquema que el jugador):
|
# Strip de 12 frames en graella 4×3 (mateix esquema que el jugador):
|
||||||
# 0..3 → walk_down (cara avall)
|
# 0..3 → walk_south (cara avall)
|
||||||
# 4..7 → walk_up (cara amunt)
|
# 4..7 → walk_north (cara amunt)
|
||||||
# 8..11 → walk (lateral; flip horitzontal segons el sentit)
|
# 8..11 → walk_east (lateral cap a l'est)
|
||||||
|
# La variant `walk_west` reaprofita els frames de l'est amb `flip_h: true`:
|
||||||
|
# el motor d'animació aplica el flip al sprite, així el codi de la mòmia
|
||||||
|
# no decideix flip per direcció (només selecciona quina animació mostrar).
|
||||||
# La momia no té variants `stand_*` perquè mai no para.
|
# La momia no té variants `stand_*` perquè mai no para.
|
||||||
animations:
|
animations:
|
||||||
walk_down: { frames: [0, 1, 2, 3], fps: 8, loop: true }
|
walk_south: { frames: [0, 1, 2, 3], fps: 8, loop: true }
|
||||||
walk_up: { frames: [4, 5, 6, 7], fps: 8, loop: true }
|
walk_north: { frames: [4, 5, 6, 7], fps: 8, loop: true }
|
||||||
walk: { frames: [8, 9, 10, 11], fps: 8, loop: true }
|
walk_east: { frames: [8, 9, 10, 11], fps: 8, loop: true }
|
||||||
|
walk_west: { frames: [8, 9, 10, 11], fps: 8, loop: true, flip_h: true }
|
||||||
ai:
|
ai:
|
||||||
type: corridor_wanderer
|
type: corridor_wanderer
|
||||||
direction_choice: random
|
direction_choice: random
|
||||||
initial_direction: right
|
initial_direction: east
|
||||||
stats:
|
stats:
|
||||||
speed: 30
|
speed: 30
|
||||||
damage: 1
|
damage: 1
|
||||||
|
# Quan true, el contacte amb el jugador no aplica `hurt` ni knockback:
|
||||||
|
# mata d'un sol toc i dispara el cicle DYING → respawn. El path `hurt`
|
||||||
|
# del jugador segueix funcionant per a futurs hazards no-letals (avui
|
||||||
|
# no n'hi ha cap que el dispari).
|
||||||
|
kills_outright: true
|
||||||
|
|
||||||
|
# Estat HURT: post-fuetada, fugint en línia recta. Si la direcció
|
||||||
|
# preferida (la del whip) està bloquejada, prova perpendiculars; si totes
|
||||||
|
# ho estan, queda quieta tot el `duration_ms` i després torna a ROAMING.
|
||||||
|
# `speed` opcional: si no apareix, s'usa `stats.speed`. El `whippable`
|
||||||
|
# habilita la reacció al látigo (false ⇒ el whip la ignora).
|
||||||
|
hurt:
|
||||||
|
duration_ms: 600
|
||||||
|
speed: 60
|
||||||
|
whippable: true
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
name: sarcophagus
|
name: sarcophagus
|
||||||
type: interactable
|
type: interactable
|
||||||
|
editable: true
|
||||||
sprite:
|
sprite:
|
||||||
path: sarcophagus.gif
|
path: sarcophagus.gif
|
||||||
size: [48, 32]
|
size: [48, 32]
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
name: torch
|
name: torch
|
||||||
type: decoration
|
type: decoration
|
||||||
|
editable: true
|
||||||
sprite:
|
sprite:
|
||||||
path: torch.gif
|
path: torch.gif
|
||||||
size: [16, 16]
|
size: [16, 16]
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
name: whip_attack
|
||||||
|
|
||||||
|
# Quatre sprites distints, un per cardinal. El sistema d'animació actual
|
||||||
|
# només permet UNA mida de frame per surface, i els sprites del látigo
|
||||||
|
# tenen aspect ratios distints segons direcció. Per això són 4 fitxers
|
||||||
|
# en lloc d'una sola sheet compartida amb flips.
|
||||||
|
#
|
||||||
|
# Mides (= `draw_rect` del WhipAttack, que NO es retalla per
|
||||||
|
# bloquejadors):
|
||||||
|
# E/W → 80×32 px per frame: 16 px de wind-up darrere del jugador
|
||||||
|
# + 16 px de solapament + 48 px d'atac
|
||||||
|
# frontal. Cobreix tota l'altura del jugador.
|
||||||
|
# N/S → 16×96 px per frame: 48 px d'atac + 32 px solapant amb el jugador
|
||||||
|
# + 16 px de wind-up "darrere".
|
||||||
|
#
|
||||||
|
# La caja de DANY és independent i més petita (48×16 / 16×48), pegada
|
||||||
|
# al borde del jugador i retallada per murs/sarcs. La calcula
|
||||||
|
# `WhipAttack::configure` a partir del `owner_box` del payload.
|
||||||
|
sprites:
|
||||||
|
east: { path: whip_east.gif, size: [80, 32] }
|
||||||
|
west: { path: whip_west.gif, size: [80, 32] }
|
||||||
|
north: { path: whip_north.gif, size: [16, 96] }
|
||||||
|
south: { path: whip_south.gif, size: [16, 96] }
|
||||||
|
|
||||||
|
# Animació compartida entre les 4 direccions: la seqüència de frames i les
|
||||||
|
# durades són idèntiques; només canvia quina surface/mida es clipa.
|
||||||
|
# - `frames` : índex de tile dins l'spritesheet (graella deduïda).
|
||||||
|
# - `frame_ms` : durada uniforme per frame; 50 ms × 4 ≈ 200 ms swing.
|
||||||
|
# - `loop: false` : el látigo viu una animació i mor (`markDead`).
|
||||||
|
# - `active_frames` : valors dins de `frames` durant els quals la
|
||||||
|
# hitbox aplica dany. Wind-up (0) i recovery (3) no
|
||||||
|
# danyen — només els frames "actius" 1 i 2.
|
||||||
|
animations:
|
||||||
|
swing:
|
||||||
|
frames: [0, 1, 2, 3]
|
||||||
|
frame_ms: 50
|
||||||
|
loop: false
|
||||||
|
active_frames: [1, 2]
|
||||||
|
After Width: | Height: | Size: 313 B |
|
After Width: | Height: | Size: 378 B |
|
After Width: | Height: | Size: 369 B |
|
After Width: | Height: | Size: 313 B |
@@ -0,0 +1,132 @@
|
|||||||
|
# Font: CaesarDressing-Regular — generado desde CaesarDressing-Regular.ttf size 24
|
||||||
|
# Generado con font_gen.py
|
||||||
|
|
||||||
|
box_width 18
|
||||||
|
box_height 28
|
||||||
|
columns 15
|
||||||
|
|
||||||
|
# codepoint_decimal ancho_visual
|
||||||
|
32 8 # U+0020
|
||||||
|
33 5 # !
|
||||||
|
34 6 # "
|
||||||
|
35 14 # #
|
||||||
|
36 7 # $
|
||||||
|
37 17 # %
|
||||||
|
38 9 # &
|
||||||
|
39 3 # '
|
||||||
|
40 10 # (
|
||||||
|
41 8 # )
|
||||||
|
42 10 # *
|
||||||
|
43 11 # +
|
||||||
|
44 5 # ,
|
||||||
|
45 10 # -
|
||||||
|
46 3 # .
|
||||||
|
47 9 # /
|
||||||
|
48 12 # 0
|
||||||
|
49 6 # 1
|
||||||
|
50 10 # 2
|
||||||
|
51 9 # 3
|
||||||
|
52 12 # 4
|
||||||
|
53 11 # 5
|
||||||
|
54 13 # 6
|
||||||
|
55 11 # 7
|
||||||
|
56 13 # 8
|
||||||
|
57 13 # 9
|
||||||
|
58 5 # :
|
||||||
|
59 4 # ;
|
||||||
|
60 11 # <
|
||||||
|
61 11 # =
|
||||||
|
62 11 # >
|
||||||
|
63 11 # ?
|
||||||
|
64 14 # @
|
||||||
|
65 14 # A
|
||||||
|
66 12 # B
|
||||||
|
67 11 # C
|
||||||
|
68 12 # D
|
||||||
|
69 10 # E
|
||||||
|
70 10 # F
|
||||||
|
71 15 # G
|
||||||
|
72 12 # H
|
||||||
|
73 9 # I
|
||||||
|
74 9 # J
|
||||||
|
75 13 # K
|
||||||
|
76 10 # L
|
||||||
|
77 18 # M
|
||||||
|
78 12 # N
|
||||||
|
79 13 # O
|
||||||
|
80 12 # P
|
||||||
|
81 12 # Q
|
||||||
|
82 13 # R
|
||||||
|
83 9 # S
|
||||||
|
84 12 # T
|
||||||
|
85 11 # U
|
||||||
|
86 12 # V
|
||||||
|
87 17 # W
|
||||||
|
88 11 # X
|
||||||
|
89 12 # Y
|
||||||
|
90 10 # Z
|
||||||
|
91 8 # [
|
||||||
|
92 8 # \
|
||||||
|
93 7 # ]
|
||||||
|
94 11 # ^
|
||||||
|
95 13 # _
|
||||||
|
96 7 # `
|
||||||
|
97 13 # a
|
||||||
|
98 12 # b
|
||||||
|
99 11 # c
|
||||||
|
100 12 # d
|
||||||
|
101 10 # e
|
||||||
|
102 10 # f
|
||||||
|
103 15 # g
|
||||||
|
104 12 # h
|
||||||
|
105 5 # i
|
||||||
|
106 9 # j
|
||||||
|
107 13 # k
|
||||||
|
108 10 # l
|
||||||
|
109 18 # m
|
||||||
|
110 12 # n
|
||||||
|
111 13 # o
|
||||||
|
112 12 # p
|
||||||
|
113 12 # q
|
||||||
|
114 12 # r
|
||||||
|
115 10 # s
|
||||||
|
116 12 # t
|
||||||
|
117 11 # u
|
||||||
|
118 12 # v
|
||||||
|
119 17 # w
|
||||||
|
120 11 # x
|
||||||
|
121 12 # y
|
||||||
|
122 10 # z
|
||||||
|
123 9 # {
|
||||||
|
124 5 # |
|
||||||
|
125 9 # }
|
||||||
|
126 14 # ~
|
||||||
|
192 14 # À
|
||||||
|
193 14 # Á
|
||||||
|
200 10 # È
|
||||||
|
201 10 # É
|
||||||
|
204 9 # Ì
|
||||||
|
205 9 # Í
|
||||||
|
210 13 # Ò
|
||||||
|
211 13 # Ó
|
||||||
|
217 11 # Ù
|
||||||
|
218 11 # Ú
|
||||||
|
209 12 # Ñ
|
||||||
|
199 11 # Ç
|
||||||
|
224 13 # à
|
||||||
|
225 13 # á
|
||||||
|
232 10 # è
|
||||||
|
233 11 # é
|
||||||
|
236 7 # ì
|
||||||
|
237 8 # í
|
||||||
|
242 13 # ò
|
||||||
|
243 13 # ó
|
||||||
|
249 11 # ù
|
||||||
|
250 11 # ú
|
||||||
|
241 12 # ñ
|
||||||
|
231 11 # ç
|
||||||
|
161 5 # ¡
|
||||||
|
191 10 # ¿
|
||||||
|
171 11 # «
|
||||||
|
187 11 # »
|
||||||
|
183 3 # ·
|
||||||
|
After Width: | Height: | Size: 3.6 KiB |
@@ -44,9 +44,27 @@ keys:
|
|||||||
- id: editor_toggle
|
- id: editor_toggle
|
||||||
code: "9"
|
code: "9"
|
||||||
desc: "Entra/surt del mode editor (només Debug)"
|
desc: "Entra/surt del mode editor (només Debug)"
|
||||||
- id: editor_picker
|
- id: editor_tile_picker
|
||||||
code: "T"
|
code: "T"
|
||||||
desc: "Obri/tanca el tilepicker dins de l'editor"
|
desc: "Obri/tanca el tilepicker dins de l'editor"
|
||||||
|
- id: editor_entity_picker
|
||||||
|
code: "E"
|
||||||
|
desc: "Obri/tanca l'entity picker dins de l'editor"
|
||||||
|
- id: editor_hand
|
||||||
|
code: "H"
|
||||||
|
desc: "Activa el mode mà de l'editor (selecciona/mou/borra entitats)"
|
||||||
|
- id: editor_delete
|
||||||
|
code: "Delete"
|
||||||
|
desc: "Esborra l'entitat seleccionada en mode mà"
|
||||||
|
- id: prev_room
|
||||||
|
code: "["
|
||||||
|
desc: "Salta a la sala anterior del levels.yaml (només Debug)"
|
||||||
|
- id: next_room
|
||||||
|
code: "]"
|
||||||
|
desc: "Salta a la sala següent del levels.yaml (només Debug)"
|
||||||
|
- id: open_door
|
||||||
|
code: "Keypad 1"
|
||||||
|
desc: "Força l'obertura de la porta de la sala (només Debug)"
|
||||||
- id: exit
|
- id: exit
|
||||||
code: "Escape"
|
code: "Escape"
|
||||||
desc: "Eixir (confirmar amb segona pulsació)"
|
desc: "Eixir (confirmar amb segona pulsació)"
|
||||||
@@ -27,6 +27,9 @@ input:
|
|||||||
editor_on: "Editor ON"
|
editor_on: "Editor ON"
|
||||||
editor_off: "Editor OFF"
|
editor_off: "Editor OFF"
|
||||||
editor_save_error: "Editor: error guardant el mapa"
|
editor_save_error: "Editor: error guardant el mapa"
|
||||||
|
editor_keep_door: "Editor: cal almenys una porta"
|
||||||
|
editor_keep_sarc: "Editor: cal almenys un sarcòfag"
|
||||||
|
editor_invalid_level: "Editor: nivell incomplet (porta i sarcs)"
|
||||||
|
|
||||||
hud:
|
hud:
|
||||||
p1: "P1"
|
p1: "P1"
|
||||||
@@ -36,6 +39,17 @@ hud:
|
|||||||
pyramid: "Piramide"
|
pyramid: "Piramide"
|
||||||
room: "Sala"
|
room: "Sala"
|
||||||
|
|
||||||
|
# Textos de la transició d'entrada/sortida de sala (FSM de GameScene).
|
||||||
|
# Tant l'INTRO com l'OUTRO es renderitzen com a dues línies separades
|
||||||
|
# (cadascuna amb la seua animació). L'INTRO accepta els placeholders
|
||||||
|
# `{p}` (piràmide) i `{r}` (sala); l'OUTRO no en té cap — són les
|
||||||
|
# dues paraules del rètol "fase completada".
|
||||||
|
game:
|
||||||
|
room_intro_pyramid: "Piramide {p}"
|
||||||
|
room_intro_room: "Sala {r}"
|
||||||
|
room_complete_line1: "Fase"
|
||||||
|
room_complete_line2: "Completada"
|
||||||
|
|
||||||
menu:
|
menu:
|
||||||
titles:
|
titles:
|
||||||
root: "Menú de servei"
|
root: "Menú de servei"
|
||||||
@@ -60,8 +74,13 @@ menu:
|
|||||||
move_down: "Avall"
|
move_down: "Avall"
|
||||||
move_left: "Esquerra"
|
move_left: "Esquerra"
|
||||||
move_right: "Dreta"
|
move_right: "Dreta"
|
||||||
|
jump: "Saltar"
|
||||||
|
attack: "Atacar"
|
||||||
|
service: "Opcions"
|
||||||
gamepad_p1: "Comandament P1"
|
gamepad_p1: "Comandament P1"
|
||||||
gamepad_p2: "Comandament P2"
|
gamepad_p2: "Comandament P2"
|
||||||
|
define_buttons_p1: "Definir botons P1"
|
||||||
|
define_buttons_p2: "Definir botons P2"
|
||||||
zoom: "Zoom"
|
zoom: "Zoom"
|
||||||
screen: "Pantalla completa"
|
screen: "Pantalla completa"
|
||||||
vsync: "VSync"
|
vsync: "VSync"
|
||||||
@@ -93,3 +112,7 @@ menu:
|
|||||||
render_info_bottom: "Baix"
|
render_info_bottom: "Baix"
|
||||||
gamepad_none: "Cap"
|
gamepad_none: "Cap"
|
||||||
gamepad_disconnected: "Desconnectat"
|
gamepad_disconnected: "Desconnectat"
|
||||||
|
press_key: "Polsa una tecla"
|
||||||
|
press_button: "Polsa un botó"
|
||||||
|
define_buttons_complete: "Configuració completa"
|
||||||
|
define_buttons_no_pad: "Cap mando assignat"
|
||||||
@@ -27,6 +27,9 @@ input:
|
|||||||
editor_on: "Editor ON"
|
editor_on: "Editor ON"
|
||||||
editor_off: "Editor OFF"
|
editor_off: "Editor OFF"
|
||||||
editor_save_error: "Editor: map save failed"
|
editor_save_error: "Editor: map save failed"
|
||||||
|
editor_keep_door: "Editor: at least one door required"
|
||||||
|
editor_keep_sarc: "Editor: at least one sarcophagus required"
|
||||||
|
editor_invalid_level: "Editor: level incomplete (door and sarcs)"
|
||||||
|
|
||||||
hud:
|
hud:
|
||||||
p1: "P1"
|
p1: "P1"
|
||||||
@@ -36,6 +39,16 @@ hud:
|
|||||||
pyramid: "Pyramid"
|
pyramid: "Pyramid"
|
||||||
room: "Room"
|
room: "Room"
|
||||||
|
|
||||||
|
# Room transition texts (GameScene FSM intro/outro). Both INTRO and
|
||||||
|
# OUTRO render as two independent lines with their own animation.
|
||||||
|
# INTRO uses `{p}` (pyramid) and `{r}` (room) placeholders; OUTRO has
|
||||||
|
# no placeholders — it's the two words of the "stage complete" label.
|
||||||
|
game:
|
||||||
|
room_intro_pyramid: "Pyramid {p}"
|
||||||
|
room_intro_room: "Room {r}"
|
||||||
|
room_complete_line1: "Stage"
|
||||||
|
room_complete_line2: "Complete"
|
||||||
|
|
||||||
menu:
|
menu:
|
||||||
titles:
|
titles:
|
||||||
root: "Service menu"
|
root: "Service menu"
|
||||||
@@ -47,6 +60,7 @@ menu:
|
|||||||
system: "System"
|
system: "System"
|
||||||
labels:
|
labels:
|
||||||
player_1: "Player 1"
|
player_1: "Player 1"
|
||||||
|
player_2: "Player 2"
|
||||||
gamepad_unavailable: "Not available"
|
gamepad_unavailable: "Not available"
|
||||||
items:
|
items:
|
||||||
video_submenu: "Video"
|
video_submenu: "Video"
|
||||||
@@ -59,6 +73,13 @@ menu:
|
|||||||
move_down: "Down"
|
move_down: "Down"
|
||||||
move_left: "Left"
|
move_left: "Left"
|
||||||
move_right: "Right"
|
move_right: "Right"
|
||||||
|
jump: "Jump"
|
||||||
|
attack: "Attack"
|
||||||
|
service: "Options"
|
||||||
|
gamepad_p1: "Gamepad P1"
|
||||||
|
gamepad_p2: "Gamepad P2"
|
||||||
|
define_buttons_p1: "Define buttons P1"
|
||||||
|
define_buttons_p2: "Define buttons P2"
|
||||||
zoom: "Zoom"
|
zoom: "Zoom"
|
||||||
screen: "Fullscreen"
|
screen: "Fullscreen"
|
||||||
vsync: "VSync"
|
vsync: "VSync"
|
||||||
@@ -88,3 +109,9 @@ menu:
|
|||||||
render_info_off: "Off"
|
render_info_off: "Off"
|
||||||
render_info_top: "Top"
|
render_info_top: "Top"
|
||||||
render_info_bottom: "Bottom"
|
render_info_bottom: "Bottom"
|
||||||
|
gamepad_none: "None"
|
||||||
|
gamepad_disconnected: "Disconnected"
|
||||||
|
press_key: "Press a key"
|
||||||
|
press_button: "Press a button"
|
||||||
|
define_buttons_complete: "Configuration complete"
|
||||||
|
define_buttons_no_pad: "No gamepad assigned"
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# Índex ordenat de les 30 sales del joc (5 piràmides × 6 sales). El
|
||||||
|
# LevelManager carrega aquesta llista a l'arrencada i la fa servir com a
|
||||||
|
# font de veritat per a `currentPath()`, `advance()`, `setIndex()` i la
|
||||||
|
# resta de consultes que li facin la GameScene, l'Editor i els salts de
|
||||||
|
# debug. Per reordenar la progressió, canvia l'ordre d'aquesta seqüència
|
||||||
|
# (no cal renombrar fitxers). Per afegir una sala, crea el YAML i posa
|
||||||
|
# una entrada nova; els camps `pyramid` i `room` són purament informatius
|
||||||
|
# (apareixen als logs i al text d'intro de sala) — l'únic camp que
|
||||||
|
# realment carrega l'engine és `file`.
|
||||||
|
#
|
||||||
|
# Convenció de nomenclatura del fitxer: `data/maps/p<N>/r<M>.yaml` per
|
||||||
|
# dins la piràmide N, sala M. La carpeta `p<N>/` agruparà més endavant
|
||||||
|
# les metadades comunes de la piràmide (tileset, paleta, música).
|
||||||
|
|
||||||
|
sequence:
|
||||||
|
- { pyramid: 1, room: 1, file: data/maps/p1/r1.yaml }
|
||||||
|
- { pyramid: 1, room: 2, file: data/maps/p1/r2.yaml }
|
||||||
|
- { pyramid: 1, room: 3, file: data/maps/p1/r3.yaml }
|
||||||
|
- { pyramid: 1, room: 4, file: data/maps/p1/r4.yaml }
|
||||||
|
- { pyramid: 1, room: 5, file: data/maps/p1/r5.yaml }
|
||||||
|
- { pyramid: 1, room: 6, file: data/maps/p1/r6.yaml }
|
||||||
|
- { pyramid: 2, room: 1, file: data/maps/p2/r1.yaml }
|
||||||
|
- { pyramid: 2, room: 2, file: data/maps/p2/r2.yaml }
|
||||||
|
- { pyramid: 2, room: 3, file: data/maps/p2/r3.yaml }
|
||||||
|
- { pyramid: 2, room: 4, file: data/maps/p2/r4.yaml }
|
||||||
|
- { pyramid: 2, room: 5, file: data/maps/p2/r5.yaml }
|
||||||
|
- { pyramid: 2, room: 6, file: data/maps/p2/r6.yaml }
|
||||||
|
- { pyramid: 3, room: 1, file: data/maps/p3/r1.yaml }
|
||||||
|
- { pyramid: 3, room: 2, file: data/maps/p3/r2.yaml }
|
||||||
|
- { pyramid: 3, room: 3, file: data/maps/p3/r3.yaml }
|
||||||
|
- { pyramid: 3, room: 4, file: data/maps/p3/r4.yaml }
|
||||||
|
- { pyramid: 3, room: 5, file: data/maps/p3/r5.yaml }
|
||||||
|
- { pyramid: 3, room: 6, file: data/maps/p3/r6.yaml }
|
||||||
|
- { pyramid: 4, room: 1, file: data/maps/p4/r1.yaml }
|
||||||
|
- { pyramid: 4, room: 2, file: data/maps/p4/r2.yaml }
|
||||||
|
- { pyramid: 4, room: 3, file: data/maps/p4/r3.yaml }
|
||||||
|
- { pyramid: 4, room: 4, file: data/maps/p4/r4.yaml }
|
||||||
|
- { pyramid: 4, room: 5, file: data/maps/p4/r5.yaml }
|
||||||
|
- { pyramid: 4, room: 6, file: data/maps/p4/r6.yaml }
|
||||||
|
- { pyramid: 5, room: 1, file: data/maps/p5/r1.yaml }
|
||||||
|
- { pyramid: 5, room: 2, file: data/maps/p5/r2.yaml }
|
||||||
|
- { pyramid: 5, room: 3, file: data/maps/p5/r3.yaml }
|
||||||
|
- { pyramid: 5, room: 4, file: data/maps/p5/r4.yaml }
|
||||||
|
- { pyramid: 5, room: 5, file: data/maps/p5/r5.yaml }
|
||||||
|
- { pyramid: 5, room: 6, file: data/maps/p5/r6.yaml }
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_1.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 1
|
||||||
|
room: 1
|
||||||
|
tileset: data/tilesets/pyramid_1.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 11
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: hole
|
||||||
|
position: [4, 7]
|
||||||
|
- type: hole
|
||||||
|
position: [8, 11]
|
||||||
|
- type: hole
|
||||||
|
position: [15, 11]
|
||||||
|
- type: hole
|
||||||
|
position: [15, 5]
|
||||||
|
- type: hole
|
||||||
|
position: [8, 5]
|
||||||
|
- type: door
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_1.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 1
|
||||||
|
room: 2
|
||||||
|
tileset: data/tilesets/pyramid_1.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_1.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 1
|
||||||
|
room: 3
|
||||||
|
tileset: data/tilesets/pyramid_1.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_1.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 1
|
||||||
|
room: 4
|
||||||
|
tileset: data/tilesets/pyramid_1.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_1.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 1
|
||||||
|
room: 5
|
||||||
|
tileset: data/tilesets/pyramid_1.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_1.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 1
|
||||||
|
room: 6
|
||||||
|
tileset: data/tilesets/pyramid_1.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_2.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 2
|
||||||
|
room: 1
|
||||||
|
tileset: data/tilesets/pyramid_2.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_2.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 2
|
||||||
|
room: 2
|
||||||
|
tileset: data/tilesets/pyramid_2.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_2.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 2
|
||||||
|
room: 3
|
||||||
|
tileset: data/tilesets/pyramid_2.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_2.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 2
|
||||||
|
room: 4
|
||||||
|
tileset: data/tilesets/pyramid_2.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_2.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 2
|
||||||
|
room: 5
|
||||||
|
tileset: data/tilesets/pyramid_2.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_2.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 2
|
||||||
|
room: 6
|
||||||
|
tileset: data/tilesets/pyramid_2.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_3.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 3
|
||||||
|
room: 1
|
||||||
|
tileset: data/tilesets/pyramid_3.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_3.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 3
|
||||||
|
room: 2
|
||||||
|
tileset: data/tilesets/pyramid_3.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_3.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 3
|
||||||
|
room: 3
|
||||||
|
tileset: data/tilesets/pyramid_3.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_3.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 3
|
||||||
|
room: 4
|
||||||
|
tileset: data/tilesets/pyramid_3.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_3.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 3
|
||||||
|
room: 5
|
||||||
|
tileset: data/tilesets/pyramid_3.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_3.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 3
|
||||||
|
room: 6
|
||||||
|
tileset: data/tilesets/pyramid_3.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_4.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 4
|
||||||
|
room: 1
|
||||||
|
tileset: data/tilesets/pyramid_4.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_4.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 4
|
||||||
|
room: 2
|
||||||
|
tileset: data/tilesets/pyramid_4.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_4.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 4
|
||||||
|
room: 3
|
||||||
|
tileset: data/tilesets/pyramid_4.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_4.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 4
|
||||||
|
room: 4
|
||||||
|
tileset: data/tilesets/pyramid_4.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_4.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 4
|
||||||
|
room: 5
|
||||||
|
tileset: data/tilesets/pyramid_4.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_4.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 4
|
||||||
|
room: 6
|
||||||
|
tileset: data/tilesets/pyramid_4.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_5.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 5
|
||||||
|
room: 1
|
||||||
|
tileset: data/tilesets/pyramid_5.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_5.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 5
|
||||||
|
room: 2
|
||||||
|
tileset: data/tilesets/pyramid_5.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_5.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 5
|
||||||
|
room: 3
|
||||||
|
tileset: data/tilesets/pyramid_5.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_5.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 5
|
||||||
|
room: 4
|
||||||
|
tileset: data/tilesets/pyramid_5.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_5.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 5
|
||||||
|
room: 5
|
||||||
|
tileset: data/tilesets/pyramid_5.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
# Mapa de la piràmide: graella 21×15 de tiles 16×16 sobre pyramid_5.gif.
|
||||||
|
# Overscan horitzontal: 8 px per banda (les parets laterals ocupen 2 tiles
|
||||||
|
# en el tilemap però només 1.5 visibles al canvas, així que la textura es
|
||||||
|
# dibuixa amb un origen de x=-8). Vertical no cal overscan: 15·16 = 240.
|
||||||
|
#
|
||||||
|
# Format del tilemap:
|
||||||
|
# `data` és una llista de files; cada fila és una llista d'índexs del
|
||||||
|
# tileset (lineal esq→dre, dalt→baix). Amb un tileset de 512×256 i tiles
|
||||||
|
# de 16×16 hi ha 32 tiles per fila. Un valor negatiu (p.ex. -1) deixa
|
||||||
|
# la cel·la buida (transparent), útil per caselles que ocuparà un actor.
|
||||||
|
|
||||||
|
pyramid: 5
|
||||||
|
room: 6
|
||||||
|
tileset: data/tilesets/pyramid_5.gif
|
||||||
|
tile_size: 16
|
||||||
|
origin: [-8, 0]
|
||||||
|
|
||||||
|
# Índex de tile amb què cada jugador deixa rastre en trepitjar un sòl
|
||||||
|
# pintable. Un índex per jugador perquè a multijugador local el recorregut
|
||||||
|
# es distingeix a simple vista. Provisional fins que l'art del pintat
|
||||||
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
|
# per desactivar el pintat per a aquest jugador.
|
||||||
|
player1_paint_tile: 0
|
||||||
|
player2_paint_tile: 1
|
||||||
|
|
||||||
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
|
# ell mateix es ralentitza per mantenir el grup). En head-on, ambdós
|
||||||
|
# s'anul·len (sense push, sense moviment).
|
||||||
|
push_factor: 0.30
|
||||||
|
|
||||||
|
# Geometria lògica de la piràmide (separada del render visual del tileset).
|
||||||
|
# La graella de sarcòfags, el pitch entre ells i les amplades dels murs
|
||||||
|
# decideixen els límits del jugador i les seues caixes de col·lisió. Abans
|
||||||
|
# vivien com a `static constexpr` a map.hpp; ara cada piràmide pot definir
|
||||||
|
# la seua pròpia forma sense recompilar.
|
||||||
|
geometry:
|
||||||
|
grid_cols: 4
|
||||||
|
grid_rows: 5
|
||||||
|
sarc_w: 48
|
||||||
|
sarc_h: 16
|
||||||
|
pitch_x: 64
|
||||||
|
pitch_y: 32
|
||||||
|
hud_h: 24
|
||||||
|
back_wall_h: 24
|
||||||
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
|
data:
|
||||||
|
- [11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13]
|
||||||
|
- [11,30,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,31,13]
|
||||||
|
- [11,13,27,28,15,22,28,28,28,28,28,28,28,28,28,28,15,28, 6,11,13]
|
||||||
|
- [11,13, 8, 8,16, 8,17, 8,10, 8,17, 8, 8, 8,17, 8, 8, 8, 8,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 9, 2, 8,10, 8, 8, 8, 8,10, 8, 8,26, 8, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 2, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8, 8,26, 8, 8, 9, 8, 8, 8, 8, 8,10, 8,16, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8, 8, 2, 8, 8, 8, 9, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2,16, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13,17, 8,10, 8, 8,10, 2, 8, 8,26, 8, 8, 8, 8,10, 8,17,11,13]
|
||||||
|
- [11,13, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8, 2, 2, 2, 8,11,13]
|
||||||
|
- [11,13, 8,10,16,16,17, 8, 8, 8,17, 8, 9, 8,17, 8, 2, 8, 8,11,13]
|
||||||
|
- [11,38, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,39,13]
|
||||||
|
|
||||||
|
# Spawns d'entitats per a aquest nivell. Es llegeixen des de
|
||||||
|
# EntityManager::loadFromLevel al GameScene. Convencions:
|
||||||
|
# - sarcophagus → `sarc_position: [sarc_col, sarc_row]` en la graella de
|
||||||
|
# sarcòfags (4×5). EntityManager calcula el rect píxel via
|
||||||
|
# Map::getSarcRect i l'ancoratge de tile per al perímetre.
|
||||||
|
# - la resta (torch, door, mummy, rolling_rock, wall_trap, floor_trap)
|
||||||
|
# → `position: [tile_col, tile_row]` en coordenades del tilemap
|
||||||
|
# (origen `[-8, 0]` per defecte). Pixel = tile*16 + tilemap_origin.
|
||||||
|
#
|
||||||
|
# Dos sarcòfags en cantonades oposades → perímetres aïllats (cap tile en
|
||||||
|
# comú). La porta va al centre inferior, on el tilemap té els tiles
|
||||||
|
# d'obertura (262/263). La momia al corredor central. L'antorxa al costat
|
||||||
|
# superior esquerre per verificar render d'una entitat decorativa.
|
||||||
|
entities:
|
||||||
|
- type: torch
|
||||||
|
position: [4, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [8, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [12, 2]
|
||||||
|
- type: torch
|
||||||
|
position: [16, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 0]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 1]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 2]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 3]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [0, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [1, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [2, 4]
|
||||||
|
- type: sarcophagus
|
||||||
|
sarc_position: [3, 4]
|
||||||
|
- type: door
|
||||||
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
|
- type: mummy
|
||||||
|
position: [10, 7]
|
||||||
|
- type: mummy
|
||||||
|
position: [7, 9]
|
||||||
@@ -19,7 +19,7 @@ origin: [-8, 0]
|
|||||||
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
# estigui definit; canviar aquí l'índex és tot el que cal. Omet el camp
|
||||||
# per desactivar el pintat per a aquest jugador.
|
# per desactivar el pintat per a aquest jugador.
|
||||||
player1_paint_tile: 0
|
player1_paint_tile: 0
|
||||||
player2_paint_tile: 4
|
player2_paint_tile: 1
|
||||||
|
|
||||||
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
# Física del contacte entre jugadors. Quan un jugador està quiet i l'altre
|
||||||
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
# el topa, el segon l'empenta a aquesta fracció de la velocitat normal (i
|
||||||
@@ -42,6 +42,12 @@ geometry:
|
|||||||
hud_h: 24
|
hud_h: 24
|
||||||
back_wall_h: 24
|
back_wall_h: 24
|
||||||
side_wall_w: 24
|
side_wall_w: 24
|
||||||
|
# Columna central del tile transitable de la porta. La porta es renderitza
|
||||||
|
# com a sprite 48×32 (3 tiles d'amplada) centrat sobre aquesta columna; els
|
||||||
|
# 16 px centrals (just aquesta columna) són el "forat" del mur trasser per
|
||||||
|
# on el jugador surt de la sala. Les 2 columnes flanquejants segueixen sent
|
||||||
|
# mur visible. El spawn dels jugadors també s'alinea amb aquesta columna.
|
||||||
|
door_col: 10
|
||||||
|
|
||||||
data:
|
data:
|
||||||
- [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
|
- [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
|
||||||
@@ -123,7 +129,9 @@ entities:
|
|||||||
- type: sarcophagus
|
- type: sarcophagus
|
||||||
sarc_position: [3, 4]
|
sarc_position: [3, 4]
|
||||||
- type: door
|
- type: door
|
||||||
position: [9, 1]
|
# Sense `position`: la porta sempre viu al mur trasser. La columna
|
||||||
|
# transitable la dicta `geometry.door_col`; el render i la caixa
|
||||||
|
# de col·lisió es deriven d'aquesta dada al loadFromLevel.
|
||||||
- type: mummy
|
- type: mummy
|
||||||
position: [10, 7]
|
position: [10, 7]
|
||||||
- type: mummy
|
- type: mummy
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 3.2 KiB |
@@ -1,113 +1,104 @@
|
|||||||
# player animation
|
|
||||||
sprite:
|
sprite:
|
||||||
path: morcus.gif
|
path: morcus.gif
|
||||||
size: [16, 32]
|
size: [16, 32]
|
||||||
|
|
||||||
# Geometria de col·lisió del jugador (independent de l'animació):
|
# Geometria de col·lisió. `size` és la caixa contra murs/sarcs;
|
||||||
# size → costat del quadrat de col·lisió (16×16)
|
# `hit_size`, la caixa contra altres actors (més petita); `height`,
|
||||||
# base_size → costat del quadrat visual inferior del sprite (els "peus");
|
# l'alçada que un salt ha de superar per passar per damunt.
|
||||||
# s'usa per centrar la caixa de col·lisió sobre ell.
|
|
||||||
collision:
|
collision:
|
||||||
size: 16
|
size: 16
|
||||||
base_size: 16
|
base_size: 16
|
||||||
# Caixa de contacte actor-actor (jugador↔jugador, jugador↔momia/trampa).
|
|
||||||
# Més petita que `size` perquè els contactes d'acció siguin precisos;
|
|
||||||
# `size` es reserva per a la col·lisió amb murs/sarcòfags i per enfilar
|
|
||||||
# els passadissos. Centrada en el mateix punt que la caixa base.
|
|
||||||
hit_size: 8
|
hit_size: 8
|
||||||
# Alçada del cos en píxels. Funció DOBLE segons amb què col·lisione:
|
|
||||||
# · Contra entitats (mummy, rolling_rock, sarc): si `jump_z > height`
|
|
||||||
# d'aquella entitat, no hi ha col·lisió. Igual que als YAMLs
|
|
||||||
# d'entitats.
|
|
||||||
# · Contra altres jugadors: la col·lisió és binària per estat aeri.
|
|
||||||
# Si un està en l'aire i l'altre no → cap col·lisió. Si tots dos
|
|
||||||
# estan en l'aire, llavors `body_height` decideix si els rangs
|
|
||||||
# verticals solapen i s'aplica el rebot mid-aire. `0` = sense cos
|
|
||||||
# (ni rebot quan tots dos volen).
|
|
||||||
height: 12
|
height: 12
|
||||||
|
|
||||||
# Animacions en mapa (clau = nom). Camps per animació:
|
|
||||||
# frames → llista d'índexs dins de l'spritesheet.
|
|
||||||
# frame_ms → durada de cada frame en ms. Escalar = uniforme; llista =
|
|
||||||
# per-frame (mateixa mida que `frames`).
|
|
||||||
# loop → true per defecte. `loop: false` = un sol tret (es queda al
|
|
||||||
# darrer frame i `animationIsCompleted()` passa a true).
|
|
||||||
# loop_from → rebota a aquest índex en passar del final (implica loop).
|
|
||||||
animations:
|
animations:
|
||||||
stand_down: { frames: [0] }
|
# Les variants `*_west` reaprofiten els frames de l'est i declaren
|
||||||
stand_up: { frames: [4] }
|
# `flip_h: true` perquè el motor d'animació apliqui el flip al sprite —
|
||||||
stand: { frames: [8] }
|
# el codi del joc no toca mai `flip_` directament.
|
||||||
jump_down: { frames: [12] }
|
stand_south: { frames: [0] }
|
||||||
jump_up: { frames: [13] }
|
stand_north: { frames: [4] }
|
||||||
jump: { frames: [14] }
|
stand_east: { frames: [8] }
|
||||||
stun_down: { frames: [16] }
|
stand_west: { frames: [8], flip_h: true }
|
||||||
stun_up: { frames: [17] }
|
|
||||||
stun: { frames: [18] }
|
|
||||||
|
|
||||||
walk_down:
|
jump_south: { frames: [12] }
|
||||||
frames: [0, 1, 2, 3]
|
jump_north: { frames: [13] }
|
||||||
frame_ms: 100
|
jump_east: { frames: [14] }
|
||||||
|
jump_west: { frames: [14], flip_h: true }
|
||||||
|
|
||||||
walk_up:
|
stun_south: { frames: [16] }
|
||||||
frames: [4, 5, 6, 7]
|
stun_north: { frames: [17] }
|
||||||
frame_ms: 100
|
stun_east: { frames: [18] }
|
||||||
|
stun_west: { frames: [18], flip_h: true }
|
||||||
|
|
||||||
walk:
|
walk_south: { frames: [0, 1, 2, 3], frame_ms: 100 }
|
||||||
frames: [8, 9, 10, 11]
|
walk_north: { frames: [4, 5, 6, 7], frame_ms: 100 }
|
||||||
frame_ms: 100
|
walk_east: { frames: [8, 9, 10, 11], frame_ms: 100 }
|
||||||
|
walk_west: { frames: [8, 9, 10, 11], frame_ms: 100, flip_h: true }
|
||||||
|
|
||||||
hurt_down:
|
hurt_south: { frames: [0, 1, 2, 3], frame_ms: 100 }
|
||||||
frames: [0, 1, 2, 3]
|
hurt_north: { frames: [4, 5, 6, 7], frame_ms: 100 }
|
||||||
frame_ms: 100
|
hurt_east: { frames: [8, 9, 10, 11], frame_ms: 100 }
|
||||||
|
hurt_west: { frames: [8, 9, 10, 11], frame_ms: 100, flip_h: true }
|
||||||
|
|
||||||
hurt_up:
|
attack_south: { frames: [20, 21, 22, 23], frame_ms: 50 }
|
||||||
frames: [4, 5, 6, 7]
|
attack_north: { frames: [24, 25, 26, 27], frame_ms: 50 }
|
||||||
frame_ms: 100
|
attack_east: { frames: [28, 29, 30, 31], frame_ms: 50 }
|
||||||
|
attack_west: { frames: [28, 29, 30, 31], frame_ms: 50, flip_h: true }
|
||||||
|
|
||||||
hurt:
|
recover_south: { frames: [23] }
|
||||||
frames: [8, 9, 10, 11]
|
recover_north: { frames: [27] }
|
||||||
frame_ms: 100
|
recover_east: { frames: [31] }
|
||||||
|
recover_west: { frames: [31], flip_h: true }
|
||||||
|
|
||||||
# Inèrcia només de frenada. L'acceleració és sempre instantània (soltar
|
# Animació de mort: 3 voltes horàries començant pel sud (south →
|
||||||
# el teclat + prémer una direcció = velocitat plena); en canvi, quan es
|
# west → north → east, repetit 3×). Reaprofita els frames stand_*; el
|
||||||
# solta la direcció el jugador decau linealment a 0 en `brake_time_ms`.
|
# west és l'east amb `flip_h: true` declarat per-frame (mapping form,
|
||||||
# El `threshold_ms` filtra els tocs curts: si el temps acumulat de
|
# no hereta del nivell d'anim). `frame_ms` per-frame creix linealment
|
||||||
# moviment continu no ha arribat al llindar, la parada és instantània
|
# per donar la sensació de desaccelerar fins a aturar-se. `loop: false`
|
||||||
# (permet "passets" d'un tile sense rellisquera). L'acumulador es
|
# → es queda al darrer frame i marca completed.
|
||||||
# reseteja només quan no hi ha ni input ni velocitat residual, així
|
death_spinning:
|
||||||
# els canvis de direcció enmig del coast no rearmen el llindar.
|
frames:
|
||||||
# `brake_time_ms: 0` o absència del bloc = inèrcia desactivada.
|
- 0
|
||||||
|
- { index: 8, flip_h: true }
|
||||||
|
- 4
|
||||||
|
- 8
|
||||||
|
- 0
|
||||||
|
- { index: 8, flip_h: true }
|
||||||
|
- 4
|
||||||
|
- 8
|
||||||
|
- 0
|
||||||
|
- { index: 8, flip_h: true }
|
||||||
|
- 4
|
||||||
|
- 8
|
||||||
|
frame_ms: [60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280]
|
||||||
|
loop: false
|
||||||
|
|
||||||
|
# Mort per caiguda a un agujero (DeathCause::HOLE). `loop: false` perquè
|
||||||
|
# `animationIsCompleted()` dispari el respawn timer determinísticament.
|
||||||
|
death_hole:
|
||||||
|
frames: [15]
|
||||||
|
frame_ms: 60
|
||||||
|
loop: false
|
||||||
|
|
||||||
|
# Inèrcia de frenada en soltar la direcció. `threshold_ms` filtra
|
||||||
|
# tocs curts (passets d'un tile sense rellisquera).
|
||||||
inertia:
|
inertia:
|
||||||
brake_time_ms: 150
|
brake_time_ms: 150
|
||||||
threshold_ms: 300
|
threshold_ms: 300
|
||||||
|
|
||||||
# Gir de 180°: mentre dura, el facing queda fixat a la direcció
|
# Gir de 180°: durant `duration_ms` el facing es fixa a la direcció
|
||||||
# intermèdia (efecte purament visual; el moviment continua sense
|
# intermèdia indicada (purament visual).
|
||||||
# alterar-se). Els girs de 90° no passen per cap intermedi.
|
|
||||||
turn:
|
turn:
|
||||||
duration_ms: 80
|
duration_ms: 80
|
||||||
# Direcció intermèdia per a cada gir de 180° (sentit horari).
|
|
||||||
transitions:
|
transitions:
|
||||||
west_to_east: down # passa per baix (stand_down)
|
west_to_east: south
|
||||||
east_to_west: up # passa per dalt (stand_up)
|
east_to_west: north
|
||||||
north_to_south: east # passa per la dreta (stand, sense flip)
|
north_to_south: east
|
||||||
south_to_north: west # passa per l'esquerra (stand, amb flip)
|
south_to_north: west
|
||||||
|
|
||||||
# Salt vertical (px verticals "visuals", no afecta la posició al món).
|
# Salt vertical (px de z, no toca la posició al món).
|
||||||
# impulse → velocitat vertical inicial (px/s) en deixar el sòl.
|
# `shadow_y_offset`: puja la sombra per compensar la franja
|
||||||
# gravity → acceleració descendent constant (px/s²).
|
# transparent sota els peus del sprite.
|
||||||
# landing_stun_ms → temps en què el jugador queda paralitzat en aterrar
|
|
||||||
# (no es pot moure ni tornar a saltar).
|
|
||||||
# shadow_y_offset → desplaçament vertical de la sombra (px, positiu =
|
|
||||||
# puja). Compensa la franja transparent que els
|
|
||||||
# sprites del jugador tenen sota els peus reals
|
|
||||||
# perquè camine "pel mig del passadís" (3 px aquí).
|
|
||||||
# sound → fitxer .wav reproduït al despegue (relatiu a
|
|
||||||
# data/sounds/). Buit o absent = sense so.
|
|
||||||
# land_sound → fitxer .wav reproduït en aterrar.
|
|
||||||
# L'alçada del cos viu al bloc `collision:` (`height`), igual que la resta
|
|
||||||
# d'entitats: és una propietat de col·lisió, no de la física del salt.
|
|
||||||
# Amb impulse=240 i gravity=600: pic ≈ 48 px, temps total en l'aire ≈ 0.8 s.
|
|
||||||
jump:
|
jump:
|
||||||
impulse: 200
|
impulse: 200
|
||||||
gravity: 600
|
gravity: 600
|
||||||
@@ -116,14 +107,27 @@ jump:
|
|||||||
sound: jump.wav
|
sound: jump.wav
|
||||||
land_sound: land.wav
|
land_sound: land.wav
|
||||||
|
|
||||||
# Estat HURT: el jugador queda projectat sense control per un impacte
|
# Projecció post-impacte: surt cap a la direcció amb més recorregut
|
||||||
# (algú que cau al damunt; en el futur també fuetada de l'altre jugador).
|
# lliure i frena fins a 0 en `brake_time_ms`.
|
||||||
# `enterHurt` tria automàticament la direcció amb més recorregut lliure
|
|
||||||
# entre els 4 cardinals, posa la velocitat inicial a `speed` i la fa
|
|
||||||
# decaure linealment fins a 0 en `brake_time_ms`. Si pel camí xoca amb
|
|
||||||
# un mur, para en sec. En tornar a velocitat 0, recupera l'estat
|
|
||||||
# GROUNDED i el control. Mentre dura, no col·lisiona amb altres jugadors.
|
|
||||||
# Amb speed=120 i brake_time=500ms ⇒ recorregut ≈ 30 px (≈2 tiles).
|
|
||||||
hurt:
|
hurt:
|
||||||
speed: 120
|
speed: 120
|
||||||
brake_time_ms: 500
|
brake_time_ms: 500
|
||||||
|
sound: hurt.wav
|
||||||
|
|
||||||
|
# Atac amb làtigo. `range_tiles` és la longitud abans de retallar
|
||||||
|
# contra murs/sarcs; `cooldown_ms` allarga ATTACKING amb una
|
||||||
|
# recuperació en què la hitbox ja no fa dany.
|
||||||
|
whip:
|
||||||
|
range_tiles: 3
|
||||||
|
swing_ms: 200
|
||||||
|
cooldown_ms: 200
|
||||||
|
damage: 1
|
||||||
|
sound: whip.wav
|
||||||
|
|
||||||
|
# Mort + respawn. `respawn_delay_ms` és la pausa entre la fi de
|
||||||
|
# `death_spinning` i la reaparició al spawn. `lives` és el comptador
|
||||||
|
# inicial d'intents (estil Mario): cada respawn el decrementa en 1, pot
|
||||||
|
# anar a negatius (no hi ha game over).
|
||||||
|
death:
|
||||||
|
respawn_delay_ms: 500
|
||||||
|
lives: 3
|
||||||
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 3.2 KiB |
@@ -1,113 +1,104 @@
|
|||||||
# player animation
|
|
||||||
sprite:
|
sprite:
|
||||||
path: sam.gif
|
path: sam.gif
|
||||||
size: [16, 32]
|
size: [16, 32]
|
||||||
|
|
||||||
# Geometria de col·lisió del jugador (independent de l'animació):
|
# Geometria de col·lisió. `size` és la caixa contra murs/sarcs;
|
||||||
# size → costat del quadrat de col·lisió (16×16)
|
# `hit_size`, la caixa contra altres actors (més petita); `height`,
|
||||||
# base_size → costat del quadrat visual inferior del sprite (els "peus");
|
# l'alçada que un salt ha de superar per passar per damunt.
|
||||||
# s'usa per centrar la caixa de col·lisió sobre ell.
|
|
||||||
collision:
|
collision:
|
||||||
size: 16
|
size: 16
|
||||||
base_size: 16
|
base_size: 16
|
||||||
# Caixa de contacte actor-actor (jugador↔jugador, jugador↔momia/trampa).
|
|
||||||
# Més petita que `size` perquè els contactes d'acció siguin precisos;
|
|
||||||
# `size` es reserva per a la col·lisió amb murs/sarcòfags i per enfilar
|
|
||||||
# els passadissos. Centrada en el mateix punt que la caixa base.
|
|
||||||
hit_size: 8
|
hit_size: 8
|
||||||
# Alçada del cos en píxels. Funció DOBLE segons amb què col·lisione:
|
|
||||||
# · Contra entitats (mummy, rolling_rock, sarc): si `jump_z > height`
|
|
||||||
# d'aquella entitat, no hi ha col·lisió. Igual que als YAMLs
|
|
||||||
# d'entitats.
|
|
||||||
# · Contra altres jugadors: la col·lisió és binària per estat aeri.
|
|
||||||
# Si un està en l'aire i l'altre no → cap col·lisió. Si tots dos
|
|
||||||
# estan en l'aire, llavors `body_height` decideix si els rangs
|
|
||||||
# verticals solapen i s'aplica el rebot mid-aire. `0` = sense cos
|
|
||||||
# (ni rebot quan tots dos volen).
|
|
||||||
height: 12
|
height: 12
|
||||||
|
|
||||||
# Animacions en mapa (clau = nom). Camps per animació:
|
|
||||||
# frames → llista d'índexs dins de l'spritesheet.
|
|
||||||
# frame_ms → durada de cada frame en ms. Escalar = uniforme; llista =
|
|
||||||
# per-frame (mateixa mida que `frames`).
|
|
||||||
# loop → true per defecte. `loop: false` = un sol tret (es queda al
|
|
||||||
# darrer frame i `animationIsCompleted()` passa a true).
|
|
||||||
# loop_from → rebota a aquest índex en passar del final (implica loop).
|
|
||||||
animations:
|
animations:
|
||||||
stand_down: { frames: [1] }
|
# Les variants `*_west` reaprofiten els frames de l'est i declaren
|
||||||
stand_up: { frames: [5] }
|
# `flip_h: true` perquè el motor d'animació apliqui el flip al sprite —
|
||||||
stand: { frames: [9] }
|
# el codi del joc no toca mai `flip_` directament.
|
||||||
jump_down: { frames: [12] }
|
stand_south: { frames: [0] }
|
||||||
jump_up: { frames: [13] }
|
stand_north: { frames: [4] }
|
||||||
jump: { frames: [14] }
|
stand_east: { frames: [8] }
|
||||||
stun_down: { frames: [16] }
|
stand_west: { frames: [8], flip_h: true }
|
||||||
stun_up: { frames: [17] }
|
|
||||||
stun: { frames: [18] }
|
|
||||||
|
|
||||||
walk_down:
|
jump_south: { frames: [12] }
|
||||||
frames: [0, 1, 2, 3]
|
jump_north: { frames: [13] }
|
||||||
frame_ms: 100
|
jump_east: { frames: [14] }
|
||||||
|
jump_west: { frames: [14], flip_h: true }
|
||||||
|
|
||||||
walk_up:
|
stun_south: { frames: [16] }
|
||||||
frames: [4, 5, 6, 7]
|
stun_north: { frames: [17] }
|
||||||
frame_ms: 100
|
stun_east: { frames: [18] }
|
||||||
|
stun_west: { frames: [18], flip_h: true }
|
||||||
|
|
||||||
walk:
|
walk_south: { frames: [0, 1, 2, 3], frame_ms: 100 }
|
||||||
frames: [8, 9, 10, 11]
|
walk_north: { frames: [4, 5, 6, 7], frame_ms: 100 }
|
||||||
frame_ms: 100
|
walk_east: { frames: [8, 9, 10, 11], frame_ms: 100 }
|
||||||
|
walk_west: { frames: [8, 9, 10, 11], frame_ms: 100, flip_h: true }
|
||||||
|
|
||||||
hurt_down:
|
hurt_south: { frames: [0, 1, 2, 3], frame_ms: 100 }
|
||||||
frames: [0, 1, 2, 3]
|
hurt_north: { frames: [4, 5, 6, 7], frame_ms: 100 }
|
||||||
frame_ms: 100
|
hurt_east: { frames: [8, 9, 10, 11], frame_ms: 100 }
|
||||||
|
hurt_west: { frames: [8, 9, 10, 11], frame_ms: 100, flip_h: true }
|
||||||
|
|
||||||
hurt_up:
|
attack_south: { frames: [20, 21, 22, 23], frame_ms: 50 }
|
||||||
frames: [4, 5, 6, 7]
|
attack_north: { frames: [24, 25, 26, 27], frame_ms: 50 }
|
||||||
frame_ms: 100
|
attack_east: { frames: [28, 29, 30, 31], frame_ms: 50 }
|
||||||
|
attack_west: { frames: [28, 29, 30, 31], frame_ms: 50, flip_h: true }
|
||||||
|
|
||||||
hurt:
|
recover_south: { frames: [23] }
|
||||||
frames: [8, 9, 10, 11]
|
recover_north: { frames: [27] }
|
||||||
frame_ms: 100
|
recover_east: { frames: [31] }
|
||||||
|
recover_west: { frames: [31], flip_h: true }
|
||||||
|
|
||||||
# Inèrcia només de frenada. L'acceleració és sempre instantània (soltar
|
# Animació de mort: 3 voltes horàries començant pel sud (south →
|
||||||
# el teclat + prémer una direcció = velocitat plena); en canvi, quan es
|
# west → north → east, repetit 3×). Reaprofita els frames stand_*; el
|
||||||
# solta la direcció el jugador decau linealment a 0 en `brake_time_ms`.
|
# west és l'east amb `flip_h: true` declarat per-frame (mapping form,
|
||||||
# El `threshold_ms` filtra els tocs curts: si el temps acumulat de
|
# no hereta del nivell d'anim). `frame_ms` per-frame creix linealment
|
||||||
# moviment continu no ha arribat al llindar, la parada és instantània
|
# per donar la sensació de desaccelerar fins a aturar-se. `loop: false`
|
||||||
# (permet "passets" d'un tile sense rellisquera). L'acumulador es
|
# → es queda al darrer frame i marca completed.
|
||||||
# reseteja només quan no hi ha ni input ni velocitat residual, així
|
death_spinning:
|
||||||
# els canvis de direcció enmig del coast no rearmen el llindar.
|
frames:
|
||||||
# `brake_time_ms: 0` o absència del bloc = inèrcia desactivada.
|
- 0
|
||||||
|
- { index: 8, flip_h: true }
|
||||||
|
- 4
|
||||||
|
- 8
|
||||||
|
- 0
|
||||||
|
- { index: 8, flip_h: true }
|
||||||
|
- 4
|
||||||
|
- 8
|
||||||
|
- 0
|
||||||
|
- { index: 8, flip_h: true }
|
||||||
|
- 4
|
||||||
|
- 8
|
||||||
|
frame_ms: [60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280]
|
||||||
|
loop: false
|
||||||
|
|
||||||
|
# Mort per caiguda a un agujero (DeathCause::HOLE). `loop: false` perquè
|
||||||
|
# `animationIsCompleted()` dispari el respawn timer determinísticament.
|
||||||
|
death_hole:
|
||||||
|
frames: [15]
|
||||||
|
frame_ms: 60
|
||||||
|
loop: false
|
||||||
|
|
||||||
|
# Inèrcia de frenada en soltar la direcció. `threshold_ms` filtra
|
||||||
|
# tocs curts (passets d'un tile sense rellisquera).
|
||||||
inertia:
|
inertia:
|
||||||
brake_time_ms: 150
|
brake_time_ms: 150
|
||||||
threshold_ms: 300
|
threshold_ms: 300
|
||||||
|
|
||||||
# Gir de 180°: mentre dura, el facing queda fixat a la direcció
|
# Gir de 180°: durant `duration_ms` el facing es fixa a la direcció
|
||||||
# intermèdia (efecte purament visual; el moviment continua sense
|
# intermèdia indicada (purament visual).
|
||||||
# alterar-se). Els girs de 90° no passen per cap intermedi.
|
|
||||||
turn:
|
turn:
|
||||||
duration_ms: 80
|
duration_ms: 80
|
||||||
# Direcció intermèdia per a cada gir de 180° (sentit horari).
|
|
||||||
transitions:
|
transitions:
|
||||||
west_to_east: down # passa per baix (stand_down)
|
west_to_east: south
|
||||||
east_to_west: up # passa per dalt (stand_up)
|
east_to_west: north
|
||||||
north_to_south: east # passa per la dreta (stand, sense flip)
|
north_to_south: east
|
||||||
south_to_north: west # passa per l'esquerra (stand, amb flip)
|
south_to_north: west
|
||||||
|
|
||||||
# Salt vertical (px verticals "visuals", no afecta la posició al món).
|
# Salt vertical (px de z, no toca la posició al món).
|
||||||
# impulse → velocitat vertical inicial (px/s) en deixar el sòl.
|
# `shadow_y_offset`: puja la sombra per compensar la franja
|
||||||
# gravity → acceleració descendent constant (px/s²).
|
# transparent sota els peus del sprite.
|
||||||
# landing_stun_ms → temps en què el jugador queda paralitzat en aterrar
|
|
||||||
# (no es pot moure ni tornar a saltar).
|
|
||||||
# shadow_y_offset → desplaçament vertical de la sombra (px, positiu =
|
|
||||||
# puja). Compensa la franja transparent que els
|
|
||||||
# sprites del jugador tenen sota els peus reals
|
|
||||||
# perquè camine "pel mig del passadís" (3 px aquí).
|
|
||||||
# sound → fitxer .wav reproduït al despegue (relatiu a
|
|
||||||
# data/sounds/). Buit o absent = sense so.
|
|
||||||
# land_sound → fitxer .wav reproduït en aterrar.
|
|
||||||
# L'alçada del cos viu al bloc `collision:` (`height`), igual que la resta
|
|
||||||
# d'entitats: és una propietat de col·lisió, no de la física del salt.
|
|
||||||
# Amb impulse=240 i gravity=600: pic ≈ 48 px, temps total en l'aire ≈ 0.8 s.
|
|
||||||
jump:
|
jump:
|
||||||
impulse: 200
|
impulse: 200
|
||||||
gravity: 600
|
gravity: 600
|
||||||
@@ -116,14 +107,27 @@ jump:
|
|||||||
sound: jump.wav
|
sound: jump.wav
|
||||||
land_sound: land.wav
|
land_sound: land.wav
|
||||||
|
|
||||||
# Estat HURT: el jugador queda projectat sense control per un impacte
|
# Projecció post-impacte: surt cap a la direcció amb més recorregut
|
||||||
# (algú que cau al damunt; en el futur també fuetada de l'altre jugador).
|
# lliure i frena fins a 0 en `brake_time_ms`.
|
||||||
# `enterHurt` tria automàticament la direcció amb més recorregut lliure
|
|
||||||
# entre els 4 cardinals, posa la velocitat inicial a `speed` i la fa
|
|
||||||
# decaure linealment fins a 0 en `brake_time_ms`. Si pel camí xoca amb
|
|
||||||
# un mur, para en sec. En tornar a velocitat 0, recupera l'estat
|
|
||||||
# GROUNDED i el control. Mentre dura, no col·lisiona amb altres jugadors.
|
|
||||||
# Amb speed=120 i brake_time=500ms ⇒ recorregut ≈ 30 px (≈2 tiles).
|
|
||||||
hurt:
|
hurt:
|
||||||
speed: 120
|
speed: 120
|
||||||
brake_time_ms: 500
|
brake_time_ms: 500
|
||||||
|
sound: hurt.wav
|
||||||
|
|
||||||
|
# Atac amb làtigo. `range_tiles` és la longitud abans de retallar
|
||||||
|
# contra murs/sarcs; `cooldown_ms` allarga ATTACKING amb una
|
||||||
|
# recuperació en què la hitbox ja no fa dany.
|
||||||
|
whip:
|
||||||
|
range_tiles: 3
|
||||||
|
swing_ms: 200
|
||||||
|
cooldown_ms: 200
|
||||||
|
damage: 1
|
||||||
|
sound: whip.wav
|
||||||
|
|
||||||
|
# Mort + respawn. `respawn_delay_ms` és la pausa entre la fi de
|
||||||
|
# `death_spinning` i la reaparició al spawn. `lives` és el comptador
|
||||||
|
# inicial d'intents (estil Mario): cada respawn el decrementa en 1, pot
|
||||||
|
# anar a negatius (no hi ha game over).
|
||||||
|
death:
|
||||||
|
respawn_delay_ms: 500
|
||||||
|
lives: 3
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
# Configuració de la GameScene: timings i corbes de la FSM de sala
|
||||||
|
# (ROOM_INTRO i ROOM_OUTRO). Tots els valors són ms i tota la geometria
|
||||||
|
# i font del text es reutilitzen del tema UI (data/ui.yaml > pause +
|
||||||
|
# notification). Si manca el fitxer o alguna clau, GameScene cau als
|
||||||
|
# fallbacks compilats; veure `readSceneConfig` a game_scene.cpp.
|
||||||
|
|
||||||
|
room_intro:
|
||||||
|
fade_in_ms: 500 # negre opac → món visible
|
||||||
|
text_delay_ms: 500 # espera amb el món net abans de sortir el text
|
||||||
|
text_enter_ms: 400 # text esquerra → centre
|
||||||
|
text_hold_ms: 2000 # text quiet al centre
|
||||||
|
text_exit_ms: 400 # text centre → fora per l'esquerra
|
||||||
|
line_gap_px: -4 # px extra entre les dues línies (piràmide / sala)
|
||||||
|
# Delays d'spawn aeri **mesurats des de la fi de la música d'INTRO**
|
||||||
|
# (callback `Audio::setOnMusicEnded`). 0 = cau al moment exacte que
|
||||||
|
# `room_intro.ogg` acaba; valors > 0 escalonen els jugadors. En mode
|
||||||
|
# single-player s'usa només `player_spawn_delay_ms`.
|
||||||
|
player_spawn_delay_ms: 0
|
||||||
|
player2_spawn_delay_ms: 300
|
||||||
|
# Preset de reverb (catàleg a `data/sounds.yaml`) aplicat al primer
|
||||||
|
# LAND de cada jugador durant la cinemàtica d'entrada. La sala dona
|
||||||
|
# "més detall" sonor a l'INTRO; els salts del joc i els respawns
|
||||||
|
# post-mort cauen al so sec. Buit o absent = sense reverb.
|
||||||
|
land_reverb: stone_hall
|
||||||
|
|
||||||
|
room_outro:
|
||||||
|
text_enter_ms: 400
|
||||||
|
text_hold_ms: 2000
|
||||||
|
text_exit_ms: 400
|
||||||
|
fade_out_ms: 500 # món visible → negre opac
|
||||||
|
line_gap_px: -4 # px extra entre les dues línies (fase / completada)
|
||||||
|
black_hold_ms: 500 # pausa en negre abans d'entrar a la pròxima sala
|
||||||
|
|
||||||
|
text:
|
||||||
|
# Noms d'easing tal com els resol UiConfig::curveByName (vegeu
|
||||||
|
# `data/ui.yaml`). El text entra suau i surt accelerant.
|
||||||
|
enter_curve: outCubic
|
||||||
|
exit_curve: inCubic
|
||||||
|
|
||||||
|
# Panel translúcid pintat sota el rètol de transició (INTRO i OUTRO).
|
||||||
|
# Va centrat verticalment al centre del playfield i ocupa tota
|
||||||
|
# l'amplada del canvas. Creix d'altura amb la mateixa enter_curve del
|
||||||
|
# text i decreix amb l'exit_curve. `color` són tres canals RGB (0..255);
|
||||||
|
# `alpha` és la transparència del blend (0 = invisible, 255 = opac).
|
||||||
|
text_panel:
|
||||||
|
color: [36, 182, 170]
|
||||||
|
alpha: 128
|
||||||
|
height_px: 32
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
# Presets d'efectes per a sons puntuals. Les crides
|
||||||
|
# Audio::playSoundWithEcho(name, preset, group) i
|
||||||
|
# Audio::playSoundWithReverb(name, preset, group) referencien aquests
|
||||||
|
# presets pel seu nom (camp `preset`). Si el nom no existeix, el so es
|
||||||
|
# reprodueix sec amb un avís a stderr.
|
||||||
|
#
|
||||||
|
# Camps:
|
||||||
|
# echo:
|
||||||
|
# delay_ms → temps fins al primer rebot, en mil·lisegons.
|
||||||
|
# feedback → reinjecció (0..0.95). >0.7 sona "metàl·lic".
|
||||||
|
# wet → mescla del senyal humit (0..1). 1 = només eco.
|
||||||
|
# reverb:
|
||||||
|
# room_size → mida percebuda de la sala (0..1).
|
||||||
|
# damping → atenuació de freqüències altes en cada rebot (0..1).
|
||||||
|
# wet → mescla humida (0..1).
|
||||||
|
#
|
||||||
|
# Els processadors limiten la cua a 800 ms (echo) i 1500 ms (reverb).
|
||||||
|
|
||||||
|
echo:
|
||||||
|
cave:
|
||||||
|
delay_ms: 220
|
||||||
|
feedback: 0.45
|
||||||
|
wet: 0.35
|
||||||
|
short:
|
||||||
|
delay_ms: 80
|
||||||
|
feedback: 0.30
|
||||||
|
wet: 0.25
|
||||||
|
|
||||||
|
reverb:
|
||||||
|
stone_hall:
|
||||||
|
room_size: 0.78
|
||||||
|
damping: 0.50
|
||||||
|
wet: 0.40
|
||||||
|
small_room:
|
||||||
|
room_size: 0.40
|
||||||
|
damping: 0.70
|
||||||
|
wet: 0.30
|
||||||
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
@@ -20,6 +20,12 @@ colors:
|
|||||||
hud_label: 58
|
hud_label: 58
|
||||||
hud_value: 187
|
hud_value: 187
|
||||||
hud_flash: 237
|
hud_flash: 237
|
||||||
|
# Rètol de transició de sala (ROOM_INTRO i ROOM_OUTRO). Independents
|
||||||
|
# de notification_* perquè la fase i les notificacions són dos canals
|
||||||
|
# visuals distints: ací pots canviar el color del rètol sense tocar
|
||||||
|
# els missatges del HUD.
|
||||||
|
room_text: 160
|
||||||
|
room_text_outline: 253
|
||||||
|
|
||||||
timings:
|
timings:
|
||||||
notification_ms: 4000
|
notification_ms: 4000
|
||||||
@@ -36,6 +42,12 @@ fonts:
|
|||||||
gif: "data/fonts/ari-w9500-condensed-display.gif"
|
gif: "data/fonts/ari-w9500-condensed-display.gif"
|
||||||
fnt: "data/fonts/ari-w9500-condensed-display.fnt"
|
fnt: "data/fonts/ari-w9500-condensed-display.fnt"
|
||||||
kerning: 1
|
kerning: 1
|
||||||
|
# Font del rètol de transició de sala (ROOM_INTRO i ROOM_OUTRO).
|
||||||
|
room_text:
|
||||||
|
name: "CaesarDressing-Regular"
|
||||||
|
gif: "data/fonts/CaesarDressing-Regular.gif"
|
||||||
|
fnt: "data/fonts/CaesarDressing-Regular.fnt"
|
||||||
|
kerning: 1
|
||||||
menu_title:
|
menu_title:
|
||||||
name: "ari-w9500-display"
|
name: "ari-w9500-display"
|
||||||
gif: "data/fonts/ari-w9500-display.gif"
|
gif: "data/fonts/ari-w9500-display.gif"
|
||||||
@@ -48,11 +60,27 @@ fonts:
|
|||||||
kerning: 0
|
kerning: 0
|
||||||
|
|
||||||
hud:
|
hud:
|
||||||
bg_enabled: true
|
bg_enabled: false
|
||||||
entry_ms: 800 # durada de l'animació d'entrada dels tres blocs
|
entry_ms: 800 # durada de l'animació d'entrada dels tres blocs
|
||||||
flash_ms: 250 # durada del flash quan un jugador rep un hit
|
flash_ms: 250 # durada del flash quan un jugador rep un hit
|
||||||
shake_ms: 300 # durada del shake que acompanya el flash
|
shake_ms: 300 # durada del shake que acompanya el flash
|
||||||
|
|
||||||
|
# Geometria del popup superior (Notifier). En píxels del canvas, llevat de
|
||||||
|
# slide_ms (durada en ms de l'animació d'entrada i d'eixida; constant
|
||||||
|
# independentment de la mida de la caixa). El padding vertical és asimètric a
|
||||||
|
# propòsit: padding_top > padding_bottom puja una mica el text dins la caixa.
|
||||||
|
# Corbes disponibles: linear, outQuad, inQuad, inOutQuad, outCubic, inCubic.
|
||||||
|
notifier:
|
||||||
|
padding_h: 6
|
||||||
|
padding_top: 4
|
||||||
|
padding_bottom: 3
|
||||||
|
line_gap: 1
|
||||||
|
margin_top: 3
|
||||||
|
border_px: 1
|
||||||
|
slide_ms: 300
|
||||||
|
slide_in_curve: outCubic
|
||||||
|
slide_out_curve: inCubic
|
||||||
|
|
||||||
# Pausa graduada de la GameScene: el món no para d'un colp, s'atura amb
|
# Pausa graduada de la GameScene: el món no para d'un colp, s'atura amb
|
||||||
# easing i torna a arrancar amb una altra corba. Els timings es poden
|
# easing i torna a arrancar amb una altra corba. Els timings es poden
|
||||||
# afinar independentment, i les corbes permeten estils diferents entrant
|
# afinar independentment, i les corbes permeten estils diferents entrant
|
||||||
@@ -63,3 +91,10 @@ pause:
|
|||||||
exit_ms: 250
|
exit_ms: 250
|
||||||
enter_curve: outCubic
|
enter_curve: outCubic
|
||||||
exit_curve: inCubic
|
exit_curve: inCubic
|
||||||
|
|
||||||
|
# Sons del menú de servei. Els fitxers viuen a data/sounds/. SELECT
|
||||||
|
# acompanya navegació (amunt/avall) i back; ACCEPT acompanya modificació
|
||||||
|
# d'opció (esquerra/dreta/retorn) o entrada a un submenú.
|
||||||
|
sounds:
|
||||||
|
menu_select: "menu_select.wav"
|
||||||
|
menu_accept: "menu_accept.wav"
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "core/audio/audio_adapter.hpp" // Per a AudioResource::getMusic/getSound
|
#include "core/audio/audio_adapter.hpp" // Per a AudioResource::getMusic/getSound
|
||||||
#include "core/audio/jail_audio.hpp" // Per a Ja::* (motor jailgames)
|
#include "core/audio/jail_audio.hpp" // Per a Ja::* (motor jailgames)
|
||||||
|
#include "core/audio/sound_effects_config.hpp" // Per a SoundEffectsConfig
|
||||||
#include "utils/defaults.hpp" // Per a Defaults::Audio::FREQUENCY
|
#include "utils/defaults.hpp" // Per a Defaults::Audio::FREQUENCY
|
||||||
|
|
||||||
// Invariant compile-time: tots els valors d'Audio::Group han de cabre als slots
|
// Invariant compile-time: tots els valors d'Audio::Group han de cabre als slots
|
||||||
@@ -128,6 +129,47 @@ void Audio::playSound(Ja::Sound* sound, Group group) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reprodueix un so processat per un eco definit a sounds.yaml. Si el preset no
|
||||||
|
// existeix o l'engine retorna -1 (cap de canals d'efecte plé), cau a playSound
|
||||||
|
// sec — l'usuari sent el so encara que la cua no s'apliqui.
|
||||||
|
// NOLINTNEXTLINE(readability-make-member-function-const) — muta estat via engine_
|
||||||
|
void Audio::playSoundWithEcho(const std::string& name, const std::string& preset_name, Group group) {
|
||||||
|
if (!sound_enabled_) { return; }
|
||||||
|
auto* sound = AudioResource::getSound(name);
|
||||||
|
if (sound == nullptr) { return; }
|
||||||
|
|
||||||
|
const auto* params = SoundEffectsConfig::get().findEcho(preset_name);
|
||||||
|
if (params == nullptr) {
|
||||||
|
std::fprintf(stderr, "Audio: preset d'eco '%s' desconegut — so '%s' es reprodueix sec\n", preset_name.c_str(), name.c_str());
|
||||||
|
engine_->playSound(sound, 0, static_cast<int>(group));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (engine_->playSoundWithEcho(sound, *params, static_cast<int>(group)) < 0) {
|
||||||
|
engine_->playSound(sound, 0, static_cast<int>(group));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reprodueix un so processat per un reverb definit a sounds.yaml. Mateix
|
||||||
|
// fallback que playSoundWithEcho.
|
||||||
|
// NOLINTNEXTLINE(readability-make-member-function-const) — muta estat via engine_
|
||||||
|
void Audio::playSoundWithReverb(const std::string& name, const std::string& preset_name, Group group) {
|
||||||
|
if (!sound_enabled_) { return; }
|
||||||
|
auto* sound = AudioResource::getSound(name);
|
||||||
|
if (sound == nullptr) { return; }
|
||||||
|
|
||||||
|
const auto* params = SoundEffectsConfig::get().findReverb(preset_name);
|
||||||
|
if (params == nullptr) {
|
||||||
|
std::fprintf(stderr, "Audio: preset de reverb '%s' desconegut — so '%s' es reprodueix sec\n", preset_name.c_str(), name.c_str());
|
||||||
|
engine_->playSound(sound, 0, static_cast<int>(group));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (engine_->playSoundWithReverb(sound, *params, static_cast<int>(group)) < 0) {
|
||||||
|
engine_->playSound(sound, 0, static_cast<int>(group));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Atura tots els sons
|
// Atura tots els sons
|
||||||
// NOLINTNEXTLINE(readability-make-member-function-const) — muta estat via engine_; unique_ptr::operator-> no propaga const
|
// NOLINTNEXTLINE(readability-make-member-function-const) — muta estat via engine_; unique_ptr::operator-> no propaga const
|
||||||
void Audio::stopAllSounds() {
|
void Audio::stopAllSounds() {
|
||||||
|
|||||||
@@ -80,6 +80,12 @@ class Audio {
|
|||||||
// --- Control de sons ---
|
// --- Control de sons ---
|
||||||
void playSound(const std::string& name, Group group = Group::GAME); // Reproduir so puntual per nom (muta globals de Ja)
|
void playSound(const std::string& name, Group group = Group::GAME); // Reproduir so puntual per nom (muta globals de Ja)
|
||||||
void playSound(Ja::Sound* sound, Group group = Group::GAME); // Reproduir so puntual per punter (muta globals de Ja)
|
void playSound(Ja::Sound* sound, Group group = Group::GAME); // Reproduir so puntual per punter (muta globals de Ja)
|
||||||
|
// Reprodueix un so processat per un efecte definit a data/sounds.yaml
|
||||||
|
// (preset_name busca a SoundEffectsConfig). Si el preset no existeix
|
||||||
|
// o el motor està al cap de canals amb efecte, fa fallback a playSound
|
||||||
|
// sec — l'usuari sent el so igualment, sense la cua.
|
||||||
|
void playSoundWithEcho(const std::string& name, const std::string& preset_name, Group group = Group::GAME);
|
||||||
|
void playSoundWithReverb(const std::string& name, const std::string& preset_name, Group group = Group::GAME);
|
||||||
void stopAllSounds(); // Aturar tots els sons (muta globals de Ja)
|
void stopAllSounds(); // Aturar tots els sons (muta globals de Ja)
|
||||||
|
|
||||||
// --- Control de volum (API interna: float 0.0..1.0) ---
|
// --- Control de volum (API interna: float 0.0..1.0) ---
|
||||||
|
|||||||
@@ -0,0 +1,250 @@
|
|||||||
|
#include "core/audio/audio_effects.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstring>
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "core/audio/jail_audio.hpp"
|
||||||
|
|
||||||
|
namespace AudioEffects {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
// --- Caps de cua ---
|
||||||
|
constexpr float ECHO_TAIL_MS = 800.0F;
|
||||||
|
constexpr float REVERB_TAIL_MS = 1500.0F;
|
||||||
|
|
||||||
|
// --- Constants Freeverb ---
|
||||||
|
// Delays de comb i allpass tunats per a 44.1 kHz; els reescalem per
|
||||||
|
// freqüència real de la font.
|
||||||
|
constexpr int COMB_REFERENCE_RATE = 44100;
|
||||||
|
constexpr std::array<int, 8> COMB_DELAYS_L = {1116, 1188, 1277, 1356, 1422, 1491, 1557, 1617};
|
||||||
|
constexpr std::array<int, 4> ALLPASS_DELAYS_L = {556, 441, 341, 225};
|
||||||
|
constexpr int STEREO_SPREAD = 23;
|
||||||
|
|
||||||
|
// Mapeig de Schroeder/Dattorro/Freeverb estàndard.
|
||||||
|
constexpr float FIXED_GAIN = 0.015F;
|
||||||
|
constexpr float SCALE_ROOM = 0.28F;
|
||||||
|
constexpr float OFFSET_ROOM = 0.7F;
|
||||||
|
constexpr float SCALE_DAMP = 0.4F;
|
||||||
|
|
||||||
|
// --- Decodificació a float -1..1 ---
|
||||||
|
// Suporta U8/S16, mono/estèreo. Mono es duplica a L i R (la cadena
|
||||||
|
// d'efectes treballa sempre amb dos canals per simplicitat).
|
||||||
|
auto decodeToStereoFloat(const Ja::Sound& src, std::vector<float>& left, std::vector<float>& right) -> bool {
|
||||||
|
const auto& spec = src.spec;
|
||||||
|
const Uint8* buf = src.buffer.get();
|
||||||
|
if (buf == nullptr || src.length == 0) { return false; }
|
||||||
|
|
||||||
|
int bytes_per_sample = 0;
|
||||||
|
if (spec.format == SDL_AUDIO_S16) {
|
||||||
|
bytes_per_sample = 2;
|
||||||
|
} else if (spec.format == SDL_AUDIO_U8) {
|
||||||
|
bytes_per_sample = 1;
|
||||||
|
} else {
|
||||||
|
std::cerr << "AudioEffects: format de so no suportat (només U8 o S16)\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (spec.channels < 1 || spec.channels > 2) {
|
||||||
|
std::cerr << "AudioEffects: el so ha de ser mono o estèreo\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::size_t TOTAL_FRAMES = src.length / static_cast<std::size_t>(bytes_per_sample * spec.channels);
|
||||||
|
left.resize(TOTAL_FRAMES);
|
||||||
|
right.resize(TOTAL_FRAMES);
|
||||||
|
|
||||||
|
for (std::size_t i = 0; i < TOTAL_FRAMES; ++i) {
|
||||||
|
float sample_l = 0.0F;
|
||||||
|
float sample_r = 0.0F;
|
||||||
|
if (spec.format == SDL_AUDIO_S16) {
|
||||||
|
const auto* p = reinterpret_cast<const std::int16_t*>(buf + (i * spec.channels * 2));
|
||||||
|
sample_l = static_cast<float>(p[0]) / 32768.0F;
|
||||||
|
sample_r = (spec.channels == 2) ? static_cast<float>(p[1]) / 32768.0F : sample_l;
|
||||||
|
} else { // U8
|
||||||
|
const Uint8* p = buf + (i * spec.channels);
|
||||||
|
sample_l = (static_cast<float>(p[0]) - 128.0F) / 128.0F;
|
||||||
|
sample_r = (spec.channels == 2) ? (static_cast<float>(p[1]) - 128.0F) / 128.0F : sample_l;
|
||||||
|
}
|
||||||
|
left[i] = sample_l;
|
||||||
|
right[i] = sample_r;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Empaqueta dos canals float (-1..1) a S16 entrellaçat.
|
||||||
|
void encodeStereoS16(const std::vector<float>& left, const std::vector<float>& right, std::vector<std::uint8_t>& out) {
|
||||||
|
const std::size_t LEN = left.size();
|
||||||
|
out.resize(LEN * 2 * sizeof(std::int16_t));
|
||||||
|
auto* dst = reinterpret_cast<std::int16_t*>(out.data());
|
||||||
|
for (std::size_t i = 0; i < LEN; ++i) {
|
||||||
|
const float L = std::clamp(left[i], -1.0F, 1.0F);
|
||||||
|
const float R = std::clamp(right[i], -1.0F, 1.0F);
|
||||||
|
dst[(i * 2) + 0] = static_cast<std::int16_t>(std::lround(L * 32767.0F));
|
||||||
|
dst[(i * 2) + 1] = static_cast<std::int16_t>(std::lround(R * 32767.0F));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reescala un delay de la taula de Freeverb per a la freqüència real.
|
||||||
|
auto scaledDelay(int reference_delay, int rate) -> int {
|
||||||
|
const long SCALED = std::lround(static_cast<double>(reference_delay) * static_cast<double>(rate) / static_cast<double>(COMB_REFERENCE_RATE));
|
||||||
|
return std::max(1, static_cast<int>(SCALED));
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Filtres bàsics ---
|
||||||
|
struct Comb {
|
||||||
|
std::vector<float> buf;
|
||||||
|
std::size_t idx{0};
|
||||||
|
float feedback{0.0F};
|
||||||
|
float damp1{0.0F};
|
||||||
|
float damp2{1.0F};
|
||||||
|
float store{0.0F};
|
||||||
|
|
||||||
|
void init(int delay, float fb, float damping) {
|
||||||
|
buf.assign(static_cast<std::size_t>(delay), 0.0F);
|
||||||
|
idx = 0;
|
||||||
|
feedback = fb;
|
||||||
|
damp1 = damping;
|
||||||
|
damp2 = 1.0F - damping;
|
||||||
|
store = 0.0F;
|
||||||
|
}
|
||||||
|
auto tick(float in) -> float {
|
||||||
|
const float OUT = buf[idx];
|
||||||
|
store = (OUT * damp2) + (store * damp1);
|
||||||
|
buf[idx] = in + (store * feedback);
|
||||||
|
idx = (idx + 1) % buf.size();
|
||||||
|
return OUT;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Allpass {
|
||||||
|
std::vector<float> buf;
|
||||||
|
std::size_t idx{0};
|
||||||
|
|
||||||
|
void init(int delay) {
|
||||||
|
buf.assign(static_cast<std::size_t>(delay), 0.0F);
|
||||||
|
idx = 0;
|
||||||
|
}
|
||||||
|
auto tick(float in) -> float {
|
||||||
|
const float BUFOUT = buf[idx];
|
||||||
|
const float OUT = -in + BUFOUT;
|
||||||
|
buf[idx] = in + (BUFOUT * 0.5F);
|
||||||
|
idx = (idx + 1) % buf.size();
|
||||||
|
return OUT;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
auto applyEcho(const Ja::Sound& src, const Ja::EchoParams& params) -> std::optional<ProcessedSound> {
|
||||||
|
std::vector<float> left;
|
||||||
|
std::vector<float> right;
|
||||||
|
if (!decodeToStereoFloat(src, left, right)) { return std::nullopt; }
|
||||||
|
|
||||||
|
const int RATE = src.spec.freq;
|
||||||
|
const int DELAY_SAMPLES = std::max(1, static_cast<int>(std::lround(params.delay_ms * 0.001F * static_cast<float>(RATE))));
|
||||||
|
const auto TAIL_SAMPLES = static_cast<std::size_t>(std::lround(ECHO_TAIL_MS * 0.001F * static_cast<float>(RATE)));
|
||||||
|
|
||||||
|
const float FEEDBACK = std::clamp(params.feedback, 0.0F, 0.95F);
|
||||||
|
const float WET = std::clamp(params.wet, 0.0F, 1.0F);
|
||||||
|
const float DRY = 1.0F - WET;
|
||||||
|
|
||||||
|
const std::size_t INPUT_LEN = left.size();
|
||||||
|
const std::size_t TOTAL_LEN = INPUT_LEN + TAIL_SAMPLES;
|
||||||
|
|
||||||
|
std::vector<float> ring_l(static_cast<std::size_t>(DELAY_SAMPLES), 0.0F);
|
||||||
|
std::vector<float> ring_r(static_cast<std::size_t>(DELAY_SAMPLES), 0.0F);
|
||||||
|
std::size_t cursor = 0;
|
||||||
|
|
||||||
|
std::vector<float> out_l(TOTAL_LEN);
|
||||||
|
std::vector<float> out_r(TOTAL_LEN);
|
||||||
|
|
||||||
|
for (std::size_t i = 0; i < TOTAL_LEN; ++i) {
|
||||||
|
const float IN_L = (i < INPUT_LEN) ? left[i] : 0.0F;
|
||||||
|
const float IN_R = (i < INPUT_LEN) ? right[i] : 0.0F;
|
||||||
|
|
||||||
|
const float DELAYED_L = ring_l[cursor];
|
||||||
|
const float DELAYED_R = ring_r[cursor];
|
||||||
|
|
||||||
|
out_l[i] = (DRY * IN_L) + (WET * DELAYED_L);
|
||||||
|
out_r[i] = (DRY * IN_R) + (WET * DELAYED_R);
|
||||||
|
|
||||||
|
ring_l[cursor] = IN_L + (DELAYED_L * FEEDBACK);
|
||||||
|
ring_r[cursor] = IN_R + (DELAYED_R * FEEDBACK);
|
||||||
|
cursor = (cursor + 1) % static_cast<std::size_t>(DELAY_SAMPLES);
|
||||||
|
}
|
||||||
|
|
||||||
|
ProcessedSound result;
|
||||||
|
result.spec = SDL_AudioSpec{.format = SDL_AUDIO_S16, .channels = 2, .freq = RATE};
|
||||||
|
encodeStereoS16(out_l, out_r, result.bytes);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto applyReverb(const Ja::Sound& src, const Ja::ReverbParams& params) -> std::optional<ProcessedSound> {
|
||||||
|
std::vector<float> left;
|
||||||
|
std::vector<float> right;
|
||||||
|
if (!decodeToStereoFloat(src, left, right)) { return std::nullopt; }
|
||||||
|
|
||||||
|
const int RATE = src.spec.freq;
|
||||||
|
const auto TAIL_SAMPLES = static_cast<std::size_t>(std::lround(REVERB_TAIL_MS * 0.001F * static_cast<float>(RATE)));
|
||||||
|
|
||||||
|
const float ROOM_SIZE = std::clamp(params.room_size, 0.0F, 1.0F);
|
||||||
|
const float DAMPING = std::clamp(params.damping, 0.0F, 1.0F);
|
||||||
|
const float WET = std::clamp(params.wet, 0.0F, 1.0F);
|
||||||
|
const float DRY = 1.0F - WET;
|
||||||
|
|
||||||
|
const float FEEDBACK = (ROOM_SIZE * SCALE_ROOM) + OFFSET_ROOM; // 0.7..0.98
|
||||||
|
const float DAMP1 = DAMPING * SCALE_DAMP; // 0..0.4
|
||||||
|
|
||||||
|
// Inicialitza els 8 comb filters per cada canal i els 4 allpass.
|
||||||
|
std::array<Comb, 8> comb_l;
|
||||||
|
std::array<Comb, 8> comb_r;
|
||||||
|
for (std::size_t i = 0; i < COMB_DELAYS_L.size(); ++i) {
|
||||||
|
comb_l[i].init(scaledDelay(COMB_DELAYS_L[i], RATE), FEEDBACK, DAMP1);
|
||||||
|
comb_r[i].init(scaledDelay(COMB_DELAYS_L[i] + STEREO_SPREAD, RATE), FEEDBACK, DAMP1);
|
||||||
|
}
|
||||||
|
std::array<Allpass, 4> allpass_l;
|
||||||
|
std::array<Allpass, 4> allpass_r;
|
||||||
|
for (std::size_t i = 0; i < ALLPASS_DELAYS_L.size(); ++i) {
|
||||||
|
allpass_l[i].init(scaledDelay(ALLPASS_DELAYS_L[i], RATE));
|
||||||
|
allpass_r[i].init(scaledDelay(ALLPASS_DELAYS_L[i] + STEREO_SPREAD, RATE));
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::size_t INPUT_LEN = left.size();
|
||||||
|
const std::size_t TOTAL_LEN = INPUT_LEN + TAIL_SAMPLES;
|
||||||
|
std::vector<float> out_l(TOTAL_LEN);
|
||||||
|
std::vector<float> out_r(TOTAL_LEN);
|
||||||
|
|
||||||
|
for (std::size_t i = 0; i < TOTAL_LEN; ++i) {
|
||||||
|
const float IN_L = (i < INPUT_LEN) ? left[i] : 0.0F;
|
||||||
|
const float IN_R = (i < INPUT_LEN) ? right[i] : 0.0F;
|
||||||
|
const float MONO_INPUT = (IN_L + IN_R) * FIXED_GAIN;
|
||||||
|
|
||||||
|
// 8 comb filters en paral·lel, sumats.
|
||||||
|
float wet_l = 0.0F;
|
||||||
|
float wet_r = 0.0F;
|
||||||
|
for (std::size_t k = 0; k < comb_l.size(); ++k) {
|
||||||
|
wet_l += comb_l[k].tick(MONO_INPUT);
|
||||||
|
wet_r += comb_r[k].tick(MONO_INPUT);
|
||||||
|
}
|
||||||
|
// 4 allpass en sèrie.
|
||||||
|
for (std::size_t k = 0; k < allpass_l.size(); ++k) {
|
||||||
|
wet_l = allpass_l[k].tick(wet_l);
|
||||||
|
wet_r = allpass_r[k].tick(wet_r);
|
||||||
|
}
|
||||||
|
|
||||||
|
out_l[i] = (DRY * IN_L) + (WET * wet_l);
|
||||||
|
out_r[i] = (DRY * IN_R) + (WET * wet_r);
|
||||||
|
}
|
||||||
|
|
||||||
|
ProcessedSound result;
|
||||||
|
result.spec = SDL_AudioSpec{.format = SDL_AUDIO_S16, .channels = 2, .freq = RATE};
|
||||||
|
encodeStereoS16(out_l, out_r, result.bytes);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace AudioEffects
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <optional>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
// Forward-declaració per no incloure jail_audio.hpp (cicle d'inclusió: aquest
|
||||||
|
// header viu sota els params declarats a jail_audio.hpp, i alhora jail_audio
|
||||||
|
// usa applyEcho/applyReverb).
|
||||||
|
namespace Ja {
|
||||||
|
struct Sound;
|
||||||
|
struct EchoParams;
|
||||||
|
struct ReverbParams;
|
||||||
|
} // namespace Ja
|
||||||
|
|
||||||
|
// Processadors d'efectes per a sons puntuals. Reben un Ja::Sound (qualsevol
|
||||||
|
// format suportat pel decodificador WAV: U8/S16, mono o estèreo) i tornen un
|
||||||
|
// buffer PCM en S16 + el seu spec, llest per empenyer a un SDL_AudioStream.
|
||||||
|
//
|
||||||
|
// El buffer de sortida inclou la cua (decay) generada per l'efecte: per al
|
||||||
|
// reverb, fins a 1500 ms; per a l'eco, fins a 800 ms. Aquests caps eviten
|
||||||
|
// allargar indefinidament la reproducció quan els paràmetres reinjecten molt.
|
||||||
|
//
|
||||||
|
// Si el format del so d'origen no es pot processar, retornen std::nullopt
|
||||||
|
// (el caller ha de fer fallback a reproducció seca).
|
||||||
|
namespace AudioEffects {
|
||||||
|
|
||||||
|
struct ProcessedSound {
|
||||||
|
std::vector<std::uint8_t> bytes; // PCM S16 entrellaçat (LRLRLR... si stereo)
|
||||||
|
SDL_AudioSpec spec; // Format/canals/freqüència del buffer
|
||||||
|
};
|
||||||
|
|
||||||
|
[[nodiscard]] auto applyEcho(const Ja::Sound& src, const Ja::EchoParams& params) -> std::optional<ProcessedSound>;
|
||||||
|
[[nodiscard]] auto applyReverb(const Ja::Sound& src, const Ja::ReverbParams& params) -> std::optional<ProcessedSound>;
|
||||||
|
|
||||||
|
} // namespace AudioEffects
|
||||||
@@ -4,6 +4,10 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "core/audio/audio_effects.hpp"
|
||||||
|
|
||||||
// Només declaracions de stb_vorbis: STB_VORBIS_HEADER_ONLY omet el bloc
|
// Només declaracions de stb_vorbis: STB_VORBIS_HEADER_ONLY omet el bloc
|
||||||
// d'implementació. Les definicions les aporta source/external/stb_vorbis_impl.cpp
|
// d'implementació. Les definicions les aporta source/external/stb_vorbis_impl.cpp
|
||||||
@@ -397,13 +401,17 @@ namespace Ja {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Engine::stopChannel(const int channel) {
|
void Engine::stopChannel(const int channel) {
|
||||||
forEachTargetChannel(channel, [](Channel& ch) {
|
forEachTargetChannel(channel, [this](Channel& ch) {
|
||||||
if (ch.state != ChannelState::FREE) {
|
if (ch.state != ChannelState::FREE) {
|
||||||
if (ch.stream != nullptr) { SDL_DestroyAudioStream(ch.stream); }
|
if (ch.stream != nullptr) { SDL_DestroyAudioStream(ch.stream); }
|
||||||
ch.stream = nullptr;
|
ch.stream = nullptr;
|
||||||
ch.state = ChannelState::FREE;
|
ch.state = ChannelState::FREE;
|
||||||
ch.pos = 0;
|
ch.pos = 0;
|
||||||
ch.sound = nullptr;
|
ch.sound = nullptr;
|
||||||
|
if (ch.has_effect) {
|
||||||
|
ch.has_effect = false;
|
||||||
|
if (effect_channels_active_ > 0) { --effect_channels_active_; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -438,6 +446,55 @@ namespace Ja {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto Engine::playProcessedOnFreeChannel(const std::vector<std::uint8_t>& bytes, const SDL_AudioSpec& spec, const int group) -> int {
|
||||||
|
// El cap de canals amb efecte es valida abans de reservar slot —
|
||||||
|
// així evitem crear i destruir un stream només per descartar el play.
|
||||||
|
if (effect_channels_active_ >= MAX_EFFECT_CHANNELS) { return -1; }
|
||||||
|
|
||||||
|
int channel = 0;
|
||||||
|
while (channel < MAX_SIMULTANEOUS_CHANNELS && channels_[channel].state != ChannelState::FREE) { ++channel; }
|
||||||
|
if (channel == MAX_SIMULTANEOUS_CHANNELS) { channel = 0; }
|
||||||
|
|
||||||
|
stopChannel(channel);
|
||||||
|
|
||||||
|
// El stream es crea contra l'spec del buffer processat (S16, ...)
|
||||||
|
// perquè SDL faci el resampling cap a audio_spec_ del device.
|
||||||
|
channels_[channel].stream = SDL_CreateAudioStream(&spec, &audio_spec_);
|
||||||
|
if (channels_[channel].stream == nullptr) {
|
||||||
|
std::fprintf(stderr, "Ja::Engine::playProcessedOnFreeChannel: Failed to create audio stream!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
channels_[channel].sound = nullptr; // El buffer no és propietat de cap Ja::Sound.
|
||||||
|
channels_[channel].times = 0;
|
||||||
|
channels_[channel].pos = 0;
|
||||||
|
const int CLAMPED_GROUP = (group >= 0 && group < MAX_GROUPS) ? group : 0;
|
||||||
|
channels_[channel].group = CLAMPED_GROUP;
|
||||||
|
channels_[channel].state = ChannelState::PLAYING;
|
||||||
|
channels_[channel].has_effect = true;
|
||||||
|
++effect_channels_active_;
|
||||||
|
|
||||||
|
SDL_PutAudioStreamData(channels_[channel].stream, bytes.data(), static_cast<int>(bytes.size()));
|
||||||
|
SDL_SetAudioStreamGain(channels_[channel].stream, sound_volume_[CLAMPED_GROUP]);
|
||||||
|
SDL_BindAudioStream(sdl_audio_device_, channels_[channel].stream);
|
||||||
|
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Engine::playSoundWithEcho(const Sound* sound, const EchoParams& params, const int group) -> int {
|
||||||
|
if (sound == nullptr) { return -1; }
|
||||||
|
auto processed = AudioEffects::applyEcho(*sound, params);
|
||||||
|
if (!processed) { return -1; }
|
||||||
|
return playProcessedOnFreeChannel(processed->bytes, processed->spec, group);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Engine::playSoundWithReverb(const Sound* sound, const ReverbParams& params, const int group) -> int {
|
||||||
|
if (sound == nullptr) { return -1; }
|
||||||
|
auto processed = AudioEffects::applyReverb(*sound, params);
|
||||||
|
if (!processed) { return -1; }
|
||||||
|
return playProcessedOnFreeChannel(processed->bytes, processed->spec, group);
|
||||||
|
}
|
||||||
|
|
||||||
// --- Factories i destructors (permanents) ---
|
// --- Factories i destructors (permanents) ---
|
||||||
|
|
||||||
auto loadMusic(const Uint8* buffer, Uint32 length) -> Music* {
|
auto loadMusic(const Uint8* buffer, Uint32 length) -> Music* {
|
||||||
|
|||||||
@@ -48,6 +48,26 @@ namespace Ja {
|
|||||||
// --- Constants ---
|
// --- Constants ---
|
||||||
inline constexpr int MAX_SIMULTANEOUS_CHANNELS = 20;
|
inline constexpr int MAX_SIMULTANEOUS_CHANNELS = 20;
|
||||||
inline constexpr int MAX_GROUPS = 2;
|
inline constexpr int MAX_GROUPS = 2;
|
||||||
|
// Cap superior de canals que poden estar simultàniament reproduint un so
|
||||||
|
// amb efecte (eco/reverb). Si està al límit, les noves crides amb efecte
|
||||||
|
// cauen al camí sec — l'usuari sent el so igualment, sense la cua.
|
||||||
|
inline constexpr int MAX_EFFECT_CHANNELS = 4;
|
||||||
|
|
||||||
|
// --- Paràmetres d'efectes ---
|
||||||
|
// Els camps els fixa el caller (Audio) llegint sounds.yaml; el motor només
|
||||||
|
// els passa a AudioEffects::applyEcho/applyReverb. Els defaults són
|
||||||
|
// sensats però els presets els sobreescriuen.
|
||||||
|
struct EchoParams {
|
||||||
|
float delay_ms{220.0F}; // Temps fins al primer rebot.
|
||||||
|
float feedback{0.45F}; // Reinjecció (0..0.95).
|
||||||
|
float wet{0.35F}; // Mescla humida (0..1).
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ReverbParams {
|
||||||
|
float room_size{0.7F}; // Mida percebuda (0..1).
|
||||||
|
float damping{0.5F}; // Atenuació d'aguts per rebot (0..1).
|
||||||
|
float wet{0.4F}; // Mescla humida (0..1).
|
||||||
|
};
|
||||||
|
|
||||||
// Spec de fallback del dispositiu. S'aplica abans que l'Engine s'iniciï i
|
// Spec de fallback del dispositiu. S'aplica abans que l'Engine s'iniciï i
|
||||||
// com a valor inicial de Sound/Music. L'spec real d'ús l'imposa el ctor
|
// com a valor inicial de Sound/Music. L'spec real d'ús l'imposa el ctor
|
||||||
@@ -72,6 +92,10 @@ namespace Ja {
|
|||||||
int times{0};
|
int times{0};
|
||||||
int group{0};
|
int group{0};
|
||||||
ChannelState state{ChannelState::FREE};
|
ChannelState state{ChannelState::FREE};
|
||||||
|
// Marca si aquest canal va arrencar amb so processat per un efecte.
|
||||||
|
// El motor compta canals actius amb efecte per fer complir
|
||||||
|
// MAX_EFFECT_CHANNELS i alliberar el comptador en parar.
|
||||||
|
bool has_effect{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Music {
|
struct Music {
|
||||||
@@ -147,6 +171,12 @@ namespace Ja {
|
|||||||
// --- So ---
|
// --- So ---
|
||||||
auto playSound(Sound* sound, int loop = 0, int group = 0) -> int;
|
auto playSound(Sound* sound, int loop = 0, int group = 0) -> int;
|
||||||
auto playSoundOnChannel(Sound* sound, int channel, int loop = 0, int group = 0) -> int;
|
auto playSoundOnChannel(Sound* sound, int channel, int loop = 0, int group = 0) -> int;
|
||||||
|
// Reproducció amb so processat per un efecte. Retorna el canal
|
||||||
|
// assignat o -1 si no queden slots d'efecte (MAX_EFFECT_CHANNELS).
|
||||||
|
// El sound original només s'usa per consultar el spec/buffer; el
|
||||||
|
// canal manipula el buffer ja processat (no reapunta a `sound`).
|
||||||
|
auto playSoundWithEcho(const Sound* sound, const EchoParams& params, int group = 0) -> int;
|
||||||
|
auto playSoundWithReverb(const Sound* sound, const ReverbParams& params, int group = 0) -> int;
|
||||||
void pauseChannel(int channel);
|
void pauseChannel(int channel);
|
||||||
void resumeChannel(int channel);
|
void resumeChannel(int channel);
|
||||||
void stopChannel(int channel);
|
void stopChannel(int channel);
|
||||||
@@ -161,6 +191,10 @@ namespace Ja {
|
|||||||
void updateIncomingFade();
|
void updateIncomingFade();
|
||||||
void updateCurrentMusic();
|
void updateCurrentMusic();
|
||||||
void updateSoundChannels();
|
void updateSoundChannels();
|
||||||
|
// Empenta un buffer ja processat (S16) a un canal lliure i el deixa
|
||||||
|
// sonar sense bucle. Camí comú dels dos overloads playSoundWith*.
|
||||||
|
// Retorna el canal o -1 si no queden slots.
|
||||||
|
auto playProcessedOnFreeChannel(const std::vector<std::uint8_t>& bytes, const SDL_AudioSpec& spec, int group) -> int;
|
||||||
|
|
||||||
template <typename Fn>
|
template <typename Fn>
|
||||||
void forEachTargetChannel(int channel, Fn&& fn);
|
void forEachTargetChannel(int channel, Fn&& fn);
|
||||||
@@ -174,6 +208,9 @@ namespace Ja {
|
|||||||
OutgoingMusic outgoing_music_;
|
OutgoingMusic outgoing_music_;
|
||||||
FadeState incoming_fade_;
|
FadeState incoming_fade_;
|
||||||
std::function<void()> on_music_ended_;
|
std::function<void()> on_music_ended_;
|
||||||
|
// Comptador derivat de Channel::has_effect — evita haver-lo de
|
||||||
|
// recalcular cada vegada que algú demana un play amb efecte.
|
||||||
|
int effect_channels_active_{0};
|
||||||
|
|
||||||
// NOLINTNEXTLINE(readability-identifier-naming) — convenció projecte: private static amb sufix _
|
// NOLINTNEXTLINE(readability-identifier-naming) — convenció projecte: private static amb sufix _
|
||||||
static Engine* active_;
|
static Engine* active_;
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
#include "core/audio/sound_effects_config.hpp"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "core/resources/resource_helper.hpp"
|
||||||
|
#include "external/fkyaml_node.hpp"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
// Lector de camp amb fallback: deixa el destí intacte si la clau no
|
||||||
|
// existeix (els defaults dels Ja::*Params s'inicialitzen al ctor del
|
||||||
|
// struct, així que el comportament és "preset parcial = preset complet
|
||||||
|
// amb defaults per als camps que falten").
|
||||||
|
template <typename T>
|
||||||
|
void readField(const fkyaml::node& node, const char* key, T& dst) {
|
||||||
|
if (node.contains(key)) { dst = node[key].get_value<T>(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
auto SoundEffectsConfig::get() -> SoundEffectsConfig& {
|
||||||
|
static SoundEffectsConfig instance_;
|
||||||
|
return instance_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SoundEffectsConfig::load(const std::string& file_path) {
|
||||||
|
auto bytes = Resource::Helper::loadFile(file_path);
|
||||||
|
if (bytes.empty()) {
|
||||||
|
std::cerr << "SoundEffectsConfig: no s'ha pogut obrir " << file_path << " — cap preset d'efecte disponible\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const auto* begin = reinterpret_cast<const char*>(bytes.data());
|
||||||
|
const auto* end = begin + bytes.size();
|
||||||
|
auto yaml = fkyaml::node::deserialize(begin, end);
|
||||||
|
|
||||||
|
if (yaml.contains("echo") && yaml["echo"].is_mapping()) {
|
||||||
|
for (auto it = yaml["echo"].begin(); it != yaml["echo"].end(); ++it) {
|
||||||
|
const auto NAME = it.key().get_value<std::string>();
|
||||||
|
const auto& node = it.value();
|
||||||
|
Ja::EchoParams params{};
|
||||||
|
readField(node, "delay_ms", params.delay_ms);
|
||||||
|
readField(node, "feedback", params.feedback);
|
||||||
|
readField(node, "wet", params.wet);
|
||||||
|
echoes_[NAME] = params;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (yaml.contains("reverb") && yaml["reverb"].is_mapping()) {
|
||||||
|
for (auto it = yaml["reverb"].begin(); it != yaml["reverb"].end(); ++it) {
|
||||||
|
const auto NAME = it.key().get_value<std::string>();
|
||||||
|
const auto& node = it.value();
|
||||||
|
Ja::ReverbParams params{};
|
||||||
|
readField(node, "room_size", params.room_size);
|
||||||
|
readField(node, "damping", params.damping);
|
||||||
|
readField(node, "wet", params.wet);
|
||||||
|
reverbs_[NAME] = params;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "SoundEffectsConfig: " << echoes_.size() << " preset(s) d'eco i " << reverbs_.size() << " de reverb des de " << file_path << '\n';
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
std::cerr << "SoundEffectsConfig: error parsejant " << file_path << ": " << e.what() << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto SoundEffectsConfig::findEcho(const std::string& name) const -> const Ja::EchoParams* {
|
||||||
|
const auto IT = echoes_.find(name);
|
||||||
|
return (IT == echoes_.end()) ? nullptr : &IT->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto SoundEffectsConfig::findReverb(const std::string& name) const -> const Ja::ReverbParams* {
|
||||||
|
const auto IT = reverbs_.find(name);
|
||||||
|
return (IT == reverbs_.end()) ? nullptr : &IT->second;
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include "core/audio/jail_audio.hpp" // Per a Ja::EchoParams / Ja::ReverbParams
|
||||||
|
|
||||||
|
// Catàleg de presets d'efectes carregat des de data/sounds.yaml. La capa
|
||||||
|
// Audio (playSoundWithEcho/playSoundWithReverb) hi accedeix per nom: si el
|
||||||
|
// preset no existeix, el so es reprodueix sec amb un avís a stderr.
|
||||||
|
//
|
||||||
|
// Patró Meyers idèntic a UiConfig/Locale: un sol load() a l'arrencada, sense
|
||||||
|
// hot-reload. Si el fitxer no existeix, el catàleg queda buit (cap preset
|
||||||
|
// disponible) i tots els playSoundWith* es comporten com playSound dry.
|
||||||
|
class SoundEffectsConfig {
|
||||||
|
public:
|
||||||
|
static auto get() -> SoundEffectsConfig&;
|
||||||
|
|
||||||
|
SoundEffectsConfig(const SoundEffectsConfig&) = delete;
|
||||||
|
SoundEffectsConfig(SoundEffectsConfig&&) = delete;
|
||||||
|
auto operator=(const SoundEffectsConfig&) -> SoundEffectsConfig& = delete;
|
||||||
|
auto operator=(SoundEffectsConfig&&) -> SoundEffectsConfig& = delete;
|
||||||
|
|
||||||
|
void load(const std::string& file_path);
|
||||||
|
|
||||||
|
// Retorna nullptr si el preset no existeix.
|
||||||
|
[[nodiscard]] auto findEcho(const std::string& name) const -> const Ja::EchoParams*;
|
||||||
|
[[nodiscard]] auto findReverb(const std::string& name) const -> const Ja::ReverbParams*;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SoundEffectsConfig() = default;
|
||||||
|
~SoundEffectsConfig() = default;
|
||||||
|
|
||||||
|
std::unordered_map<std::string, Ja::EchoParams> echoes_;
|
||||||
|
std::unordered_map<std::string, Ja::ReverbParams> reverbs_;
|
||||||
|
};
|
||||||
@@ -0,0 +1,238 @@
|
|||||||
|
#include "core/input/define_buttons.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include "core/locale/locale.hpp"
|
||||||
|
#include "core/rendering/screen.hpp"
|
||||||
|
#include "core/rendering/text.hpp"
|
||||||
|
#include "core/ui/ui_config.hpp"
|
||||||
|
#include "utils/defines.hpp"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
// Threshold per als triggers L2/R2 — equivalent a CC (16384 ≈ 50%).
|
||||||
|
constexpr Sint16 TRIGGER_THRESHOLD = 16384;
|
||||||
|
|
||||||
|
// Geometria de l'overlay (canvas lògic 320×240).
|
||||||
|
constexpr int BOX_WIDTH = 240;
|
||||||
|
constexpr int PAD_Y = 8;
|
||||||
|
constexpr int LINE_GAP = 4;
|
||||||
|
constexpr Uint8 BG_ALPHA = 230;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
void DefineButtons::init(std::shared_ptr<Text> title_font,
|
||||||
|
std::shared_ptr<Text> items_font,
|
||||||
|
const Palette& ui_palette) {
|
||||||
|
title_font_ = std::move(title_font);
|
||||||
|
items_font_ = std::move(items_font);
|
||||||
|
ui_palette_ = ui_palette;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto DefineButtons::enable(SDL_Gamepad* pad, std::string name, std::string path) -> bool {
|
||||||
|
if (pad == nullptr) { return false; }
|
||||||
|
pad_ = pad;
|
||||||
|
pad_name_ = std::move(name);
|
||||||
|
pad_path_ = std::move(path);
|
||||||
|
enabled_ = true;
|
||||||
|
finished_ = false;
|
||||||
|
closing_ = false;
|
||||||
|
message_shown_ = false;
|
||||||
|
message_timer_ms_ = 0;
|
||||||
|
l2_was_pressed_ = false;
|
||||||
|
r2_was_pressed_ = false;
|
||||||
|
resetSequence();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefineButtons::disable() {
|
||||||
|
enabled_ = false;
|
||||||
|
finished_ = false;
|
||||||
|
closing_ = false;
|
||||||
|
message_shown_ = false;
|
||||||
|
message_timer_ms_ = 0;
|
||||||
|
l2_was_pressed_ = false;
|
||||||
|
r2_was_pressed_ = false;
|
||||||
|
pad_ = nullptr;
|
||||||
|
pad_name_.clear();
|
||||||
|
pad_path_.clear();
|
||||||
|
sequence_.clear();
|
||||||
|
index_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefineButtons::resetSequence() {
|
||||||
|
// Ordre: ATTACK, JUMP, SERVICE — replica l'estructura de
|
||||||
|
// `clearButtons()` de coffee_crisis_arcade_edition (seqüència ordenada
|
||||||
|
// d'accions amb la SERVICE al final) adaptada al joc actual. La label
|
||||||
|
// de SERVICE va a una clau pròpia (`menu.items.service`) per no
|
||||||
|
// reutilitzar la del submenú dels mandos.
|
||||||
|
sequence_.clear();
|
||||||
|
sequence_.push_back({"menu.items.attack", GamepadBindings::Action::ATTACK, static_cast<int>(SDL_GAMEPAD_BUTTON_INVALID)});
|
||||||
|
sequence_.push_back({"menu.items.jump", GamepadBindings::Action::JUMP, static_cast<int>(SDL_GAMEPAD_BUTTON_INVALID)});
|
||||||
|
sequence_.push_back({"menu.items.service", GamepadBindings::Action::SERVICE, static_cast<int>(SDL_GAMEPAD_BUTTON_INVALID)});
|
||||||
|
index_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto DefineButtons::isInUse(int button) const -> bool {
|
||||||
|
return std::ranges::any_of(sequence_, [button](const ButtonAssignment& a) {
|
||||||
|
return a.button == button;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
auto DefineButtons::isReadyToClose() const -> bool {
|
||||||
|
// Llest per tancar quan: la seqüència ha acabat, ja s'ha mostrat el
|
||||||
|
// missatge, està en mode tancament, i el timer ha expirat. Replica el
|
||||||
|
// patró de `coffee_crisis_arcade_edition::DefineButtons::isReadyToClose`,
|
||||||
|
// simplificat perquè ací no tenim animació de WindowMessage.
|
||||||
|
return finished_ && message_shown_ && closing_ && message_timer_ms_ <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefineButtons::update(int delta_ms) {
|
||||||
|
if (!enabled_) { return; }
|
||||||
|
if (finished_ && message_shown_) {
|
||||||
|
message_timer_ms_ -= delta_ms;
|
||||||
|
if (message_timer_ms_ <= 0 && !closing_) {
|
||||||
|
closing_ = true;
|
||||||
|
message_timer_ms_ = 0; // anchor a 0 per a `isReadyToClose`.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefineButtons::handleEvent(const SDL_Event& ev) {
|
||||||
|
if (!enabled_) { return; }
|
||||||
|
switch (ev.type) {
|
||||||
|
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
||||||
|
handleButtonDown(ev.gbutton);
|
||||||
|
break;
|
||||||
|
case SDL_EVENT_GAMEPAD_BUTTON_UP:
|
||||||
|
onButtonUp();
|
||||||
|
break;
|
||||||
|
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
|
||||||
|
handleAxisMotion(ev.gaxis);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefineButtons::assignAndAdvance(int button) {
|
||||||
|
if (finished_ || isInUse(button)) { return; }
|
||||||
|
sequence_.at(index_).button = button;
|
||||||
|
if (index_ + 1 < sequence_.size()) {
|
||||||
|
++index_;
|
||||||
|
} else {
|
||||||
|
finished_ = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefineButtons::processTrigger(int virtual_button, bool& was_pressed, bool now) {
|
||||||
|
if (now && !was_pressed) { assignAndAdvance(virtual_button); }
|
||||||
|
if (!now && was_pressed) { onButtonUp(); }
|
||||||
|
was_pressed = now;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefineButtons::handleButtonDown(const SDL_GamepadButtonEvent& ev) {
|
||||||
|
// Filtra: només acceptem events del mando que estem configurant.
|
||||||
|
// (Per l'instance_id no podem comparar directament; obtenim el handle
|
||||||
|
// i el comparem.)
|
||||||
|
const SDL_Gamepad* source = SDL_GetGamepadFromID(ev.which);
|
||||||
|
if (source != pad_) { return; }
|
||||||
|
assignAndAdvance(static_cast<int>(ev.button));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefineButtons::handleAxisMotion(const SDL_GamepadAxisEvent& ev) {
|
||||||
|
const SDL_Gamepad* source = SDL_GetGamepadFromID(ev.which);
|
||||||
|
if (source != pad_) { return; }
|
||||||
|
|
||||||
|
// Triggers L2/R2 com a "botons" amb edge-detect (transició inactiu →
|
||||||
|
// actiu). Replica `doControllerAxisMotion` de
|
||||||
|
// coffee_crisis_arcade_edition.
|
||||||
|
const bool NOW = ev.value > TRIGGER_THRESHOLD;
|
||||||
|
if (ev.axis == SDL_GAMEPAD_AXIS_LEFT_TRIGGER) {
|
||||||
|
processTrigger(GamepadBindings::TRIGGER_L2_AS_BUTTON, l2_was_pressed_, NOW);
|
||||||
|
} else if (ev.axis == SDL_GAMEPAD_AXIS_RIGHT_TRIGGER) {
|
||||||
|
processTrigger(GamepadBindings::TRIGGER_R2_AS_BUTTON, r2_was_pressed_, NOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefineButtons::onButtonUp() {
|
||||||
|
if (!finished_ || message_shown_) { return; }
|
||||||
|
persistAndShowComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefineButtons::persistAndShowComplete() {
|
||||||
|
std::unordered_map<GamepadBindings::Action, int> mapping;
|
||||||
|
for (const auto& a : sequence_) {
|
||||||
|
mapping[a.action] = a.button;
|
||||||
|
}
|
||||||
|
GamepadBindings::get().setBindings(pad_name_, pad_path_, mapping);
|
||||||
|
message_shown_ = true;
|
||||||
|
message_timer_ms_ = MESSAGE_DISPLAY_DURATION_MS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefineButtons::render() const {
|
||||||
|
if (!enabled_ || !title_font_ || !items_font_) { return; }
|
||||||
|
|
||||||
|
const int TITLE_H = title_font_->getLineHeight();
|
||||||
|
const int ITEM_H = items_font_->getLineHeight();
|
||||||
|
const int TITLE_KERNING = title_font_->getDefaultKerning();
|
||||||
|
const int ITEM_KERNING = items_font_->getDefaultKerning();
|
||||||
|
|
||||||
|
// Calcular l'alçada total: títol + 2 línies (instrucció + label).
|
||||||
|
int box_h = (PAD_Y * 2) + TITLE_H + LINE_GAP + (ITEM_H * 2) + LINE_GAP;
|
||||||
|
int box_x = (GameCanvas::WIDTH - BOX_WIDTH) / 2;
|
||||||
|
int box_y = (GameCanvas::HEIGHT - box_h) / 2;
|
||||||
|
|
||||||
|
const auto BG_ARGB = ui_palette_[UiConfig::get().menuBg()];
|
||||||
|
const auto BORDER_ARGB = ui_palette_[UiConfig::get().menuBorder()];
|
||||||
|
Screen::get().blendRect(box_x, box_y, BOX_WIDTH, box_h, BG_ARGB, BG_ALPHA);
|
||||||
|
Screen::get().fillRect(box_x, box_y, BOX_WIDTH, 1, BORDER_ARGB);
|
||||||
|
Screen::get().fillRect(box_x, box_y + box_h - 1, BOX_WIDTH, 1, BORDER_ARGB);
|
||||||
|
Screen::get().fillRect(box_x, box_y, 1, box_h, BORDER_ARGB);
|
||||||
|
Screen::get().fillRect(box_x + BOX_WIDTH - 1, box_y, 1, box_h, BORDER_ARGB);
|
||||||
|
|
||||||
|
int cursor_y = box_y + PAD_Y;
|
||||||
|
const int CENTER_X = box_x + (BOX_WIDTH / 2);
|
||||||
|
|
||||||
|
// Títol: nom del mando.
|
||||||
|
const std::string TITLE = pad_name_;
|
||||||
|
title_font_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG,
|
||||||
|
CENTER_X,
|
||||||
|
cursor_y,
|
||||||
|
TITLE,
|
||||||
|
TITLE_KERNING,
|
||||||
|
UiConfig::get().menuTitle());
|
||||||
|
cursor_y += TITLE_H + LINE_GAP;
|
||||||
|
|
||||||
|
if (message_shown_) {
|
||||||
|
// Pantalla final: missatge de configuració completa.
|
||||||
|
items_font_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG,
|
||||||
|
CENTER_X,
|
||||||
|
cursor_y,
|
||||||
|
Locale::get().text("menu.values.define_buttons_complete"),
|
||||||
|
ITEM_KERNING,
|
||||||
|
UiConfig::get().menuValue());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Instrucció + acció pendent. Replica visualment el WindowMessage de
|
||||||
|
// coffee_crisis_arcade_edition.
|
||||||
|
items_font_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG,
|
||||||
|
CENTER_X,
|
||||||
|
cursor_y,
|
||||||
|
Locale::get().text("menu.values.press_button"),
|
||||||
|
ITEM_KERNING,
|
||||||
|
UiConfig::get().menuLabel());
|
||||||
|
cursor_y += ITEM_H + LINE_GAP;
|
||||||
|
|
||||||
|
if (index_ < sequence_.size()) {
|
||||||
|
const auto& current = sequence_[index_];
|
||||||
|
items_font_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG,
|
||||||
|
CENTER_X,
|
||||||
|
cursor_y,
|
||||||
|
Locale::get().text(current.label_key),
|
||||||
|
ITEM_KERNING,
|
||||||
|
UiConfig::get().menuCursor());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "core/input/gamepad_bindings.hpp"
|
||||||
|
#include "core/rendering/surface.hpp" // Palette
|
||||||
|
|
||||||
|
class Text;
|
||||||
|
|
||||||
|
// Sub-mòdul de captura seqüencial de botons per a un mando concret.
|
||||||
|
// Replica `DefineButtons` de coffee_crisis_arcade_edition: l'usuari obre el
|
||||||
|
// menú de servei, escull "Definir botons P1" / "P2", i el sub-mòdul li
|
||||||
|
// demana un per un els botons per a cada acció (JUMP → ATTACK → SERVICE).
|
||||||
|
//
|
||||||
|
// Cicle de vida:
|
||||||
|
// 1. `enable(pad, name, path)`: arrenca la seqüència. `index_` = 0.
|
||||||
|
// 2. Cada SDL_EVENT_GAMEPAD_BUTTON_DOWN (o transició de L2/R2 via
|
||||||
|
// AXIS_MOTION) que NO duplique cap botó ja assignat dins la sessió
|
||||||
|
// avança `index_`. Si `index_` arriba a la mida de la seqüència,
|
||||||
|
// `finished_` es posa a true i, al pròxim BUTTON_UP, escrivim el mapeig
|
||||||
|
// complet a `GamepadBindings`, mostrem "Configuració completa" durant
|
||||||
|
// `MESSAGE_DISPLAY_DURATION_MS`, i posem `closing_`. Quan tot l'overlay
|
||||||
|
// ja no és visible, `isReadyToClose()` torna `true` i el caller ens
|
||||||
|
// fa `disable()`.
|
||||||
|
//
|
||||||
|
// El layer runtime de l'aplicació viu a `GamepadBindings`: aquesta classe
|
||||||
|
// només decideix què s'escriu i quan.
|
||||||
|
class DefineButtons {
|
||||||
|
public:
|
||||||
|
DefineButtons() = default;
|
||||||
|
~DefineButtons() = default;
|
||||||
|
DefineButtons(const DefineButtons&) = delete;
|
||||||
|
DefineButtons(DefineButtons&&) = delete;
|
||||||
|
auto operator=(const DefineButtons&) -> DefineButtons& = delete;
|
||||||
|
auto operator=(DefineButtons&&) -> DefineButtons& = delete;
|
||||||
|
|
||||||
|
// Injecta les fonts i la paleta UI; cridat des de `ServiceMenu::init`
|
||||||
|
// perquè comparteixin tipografia i colors de tema.
|
||||||
|
void init(std::shared_ptr<Text> title_font,
|
||||||
|
std::shared_ptr<Text> items_font,
|
||||||
|
const Palette& ui_palette);
|
||||||
|
|
||||||
|
// Arranca la sessió per al mando indicat. `pad` ha de ser un handle
|
||||||
|
// viu obtingut de `GamepadManager`. Retorna false si `pad` és nullptr.
|
||||||
|
auto enable(SDL_Gamepad* pad, std::string name, std::string path) -> bool;
|
||||||
|
|
||||||
|
// Atura la sessió (sense persistir) i neteja l'estat.
|
||||||
|
void disable();
|
||||||
|
|
||||||
|
[[nodiscard]] auto isEnabled() const -> bool { return enabled_; }
|
||||||
|
[[nodiscard]] auto isReadyToClose() const -> bool;
|
||||||
|
|
||||||
|
// Avança el timer de tancament (ms) — replica el `update` de
|
||||||
|
// coffee_crisis_arcade_edition. No fa res si no està actiu.
|
||||||
|
void update(int delta_ms);
|
||||||
|
|
||||||
|
// Pinta l'overlay sobre el canvas actual (centrat). No fa res si no
|
||||||
|
// està actiu.
|
||||||
|
void render() const;
|
||||||
|
|
||||||
|
// Punt d'entrada d'events: BUTTON_DOWN / BUTTON_UP / AXIS_MOTION del
|
||||||
|
// mando objectiu. La resta s'ignoren.
|
||||||
|
void handleEvent(const SDL_Event& ev);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static constexpr int MESSAGE_DISPLAY_DURATION_MS = 2000;
|
||||||
|
|
||||||
|
struct ButtonAssignment {
|
||||||
|
std::string label_key;
|
||||||
|
GamepadBindings::Action action;
|
||||||
|
int button; // SDL_GamepadButton o trigger virtual; INVALID = sense assignar.
|
||||||
|
};
|
||||||
|
|
||||||
|
// Reinicialitza la seqüència ordenada (JUMP → ATTACK → SERVICE) amb
|
||||||
|
// tots els botons sense assignar. Cridat a `enable`.
|
||||||
|
void resetSequence();
|
||||||
|
|
||||||
|
// Comprova si un botó ja ha estat assignat dins de la sessió actual.
|
||||||
|
// Replica `checkButtonNotInUse` / `checkTriggerNotInUse`.
|
||||||
|
[[nodiscard]] auto isInUse(int button) const -> bool;
|
||||||
|
|
||||||
|
void handleButtonDown(const SDL_GamepadButtonEvent& ev);
|
||||||
|
void handleAxisMotion(const SDL_GamepadAxisEvent& ev);
|
||||||
|
|
||||||
|
// Helper de la lògica comuna a button-down i als triggers L2/R2:
|
||||||
|
// assigna `button` a l'acció pendent i avança l'índex (o marca
|
||||||
|
// finished_ si era l'última). No fa res si `button` ja està en ús.
|
||||||
|
void assignAndAdvance(int button);
|
||||||
|
|
||||||
|
// Tracta una transició de trigger (L2 o R2) com a botó virtual amb
|
||||||
|
// edge-detect. `virtual_button` és `TRIGGER_L?_AS_BUTTON`,
|
||||||
|
// `was_pressed` és l'estat anterior (mutat per referència).
|
||||||
|
void processTrigger(int virtual_button, bool& was_pressed, bool now);
|
||||||
|
|
||||||
|
// Crida `onSequenceEnd()` quan l'usuari deixa anar el botó després
|
||||||
|
// d'haver completat la seqüència — replica la branca de
|
||||||
|
// `SDL_EVENT_GAMEPAD_BUTTON_UP` a `DefineButtons::handleEvents`.
|
||||||
|
void onButtonUp();
|
||||||
|
|
||||||
|
// Persistix les assignacions a `GamepadBindings` i posa `message_shown_`.
|
||||||
|
void persistAndShowComplete();
|
||||||
|
|
||||||
|
SDL_Gamepad* pad_{nullptr};
|
||||||
|
std::string pad_name_;
|
||||||
|
std::string pad_path_;
|
||||||
|
|
||||||
|
std::shared_ptr<Text> title_font_;
|
||||||
|
std::shared_ptr<Text> items_font_;
|
||||||
|
Palette ui_palette_{};
|
||||||
|
|
||||||
|
std::vector<ButtonAssignment> sequence_;
|
||||||
|
std::size_t index_{0};
|
||||||
|
int message_timer_ms_{0};
|
||||||
|
|
||||||
|
bool enabled_{false};
|
||||||
|
bool finished_{false};
|
||||||
|
bool closing_{false};
|
||||||
|
bool message_shown_{false};
|
||||||
|
bool l2_was_pressed_{false};
|
||||||
|
bool r2_was_pressed_{false};
|
||||||
|
};
|
||||||
@@ -0,0 +1,220 @@
|
|||||||
|
#include "core/input/gamepad_bindings.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string_view>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include "external/fkyaml_node.hpp"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
// Threshold per a considerar L2/R2 com a premuts (mateix valor que
|
||||||
|
// coffee_crisis_arcade_edition: 16384 ≈ 50% de ±32767).
|
||||||
|
constexpr Sint16 TRIGGER_THRESHOLD = 16384;
|
||||||
|
|
||||||
|
// Taules de mapejat string ↔ valor: replica BUTTON_TO_STRING /
|
||||||
|
// STRING_TO_BUTTON / ACTION_TO_STRING / STRING_TO_ACTION del projecte
|
||||||
|
// de referència. Els noms en lowercase per llegibilitat al YAML.
|
||||||
|
using ActionPair = std::pair<GamepadBindings::Action, std::string_view>;
|
||||||
|
constexpr std::array ACTION_NAMES = {
|
||||||
|
ActionPair{GamepadBindings::Action::JUMP, std::string_view{"jump"}},
|
||||||
|
ActionPair{GamepadBindings::Action::ATTACK, std::string_view{"attack"}},
|
||||||
|
ActionPair{GamepadBindings::Action::SERVICE, std::string_view{"service"}},
|
||||||
|
};
|
||||||
|
|
||||||
|
using ButtonPair = std::pair<int, std::string_view>;
|
||||||
|
constexpr std::array BUTTON_NAMES = {
|
||||||
|
ButtonPair{static_cast<int>(SDL_GAMEPAD_BUTTON_SOUTH), std::string_view{"south"}},
|
||||||
|
ButtonPair{static_cast<int>(SDL_GAMEPAD_BUTTON_EAST), std::string_view{"east"}},
|
||||||
|
ButtonPair{static_cast<int>(SDL_GAMEPAD_BUTTON_WEST), std::string_view{"west"}},
|
||||||
|
ButtonPair{static_cast<int>(SDL_GAMEPAD_BUTTON_NORTH), std::string_view{"north"}},
|
||||||
|
ButtonPair{static_cast<int>(SDL_GAMEPAD_BUTTON_BACK), std::string_view{"back"}},
|
||||||
|
ButtonPair{static_cast<int>(SDL_GAMEPAD_BUTTON_GUIDE), std::string_view{"guide"}},
|
||||||
|
ButtonPair{static_cast<int>(SDL_GAMEPAD_BUTTON_START), std::string_view{"start"}},
|
||||||
|
ButtonPair{static_cast<int>(SDL_GAMEPAD_BUTTON_LEFT_STICK), std::string_view{"left_stick"}},
|
||||||
|
ButtonPair{static_cast<int>(SDL_GAMEPAD_BUTTON_RIGHT_STICK), std::string_view{"right_stick"}},
|
||||||
|
ButtonPair{static_cast<int>(SDL_GAMEPAD_BUTTON_LEFT_SHOULDER), std::string_view{"l1"}},
|
||||||
|
ButtonPair{static_cast<int>(SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER), std::string_view{"r1"}},
|
||||||
|
ButtonPair{static_cast<int>(SDL_GAMEPAD_BUTTON_DPAD_UP), std::string_view{"dpad_up"}},
|
||||||
|
ButtonPair{static_cast<int>(SDL_GAMEPAD_BUTTON_DPAD_DOWN), std::string_view{"dpad_down"}},
|
||||||
|
ButtonPair{static_cast<int>(SDL_GAMEPAD_BUTTON_DPAD_LEFT), std::string_view{"dpad_left"}},
|
||||||
|
ButtonPair{static_cast<int>(SDL_GAMEPAD_BUTTON_DPAD_RIGHT), std::string_view{"dpad_right"}},
|
||||||
|
ButtonPair{GamepadBindings::TRIGGER_L2_AS_BUTTON, std::string_view{"l2"}},
|
||||||
|
ButtonPair{GamepadBindings::TRIGGER_R2_AS_BUTTON, std::string_view{"r2"}},
|
||||||
|
};
|
||||||
|
|
||||||
|
auto actionToString(GamepadBindings::Action a) -> std::string_view {
|
||||||
|
for (const auto& [act, name] : ACTION_NAMES) {
|
||||||
|
if (act == a) { return name; }
|
||||||
|
}
|
||||||
|
return ACTION_NAMES.front().second;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto stringToAction(std::string_view s, GamepadBindings::Action& out) -> bool {
|
||||||
|
for (const auto& [act, name] : ACTION_NAMES) {
|
||||||
|
if (name == s) {
|
||||||
|
out = act;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto buttonToString(int btn) -> std::string_view {
|
||||||
|
for (const auto& [val, name] : BUTTON_NAMES) {
|
||||||
|
if (val == btn) { return name; }
|
||||||
|
}
|
||||||
|
return std::string_view{""};
|
||||||
|
}
|
||||||
|
|
||||||
|
auto stringToButton(std::string_view s, int& out) -> bool {
|
||||||
|
for (const auto& [val, name] : BUTTON_NAMES) {
|
||||||
|
if (name == s) {
|
||||||
|
out = val;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
auto GamepadBindings::get() -> GamepadBindings& {
|
||||||
|
static GamepadBindings instance_;
|
||||||
|
return instance_;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto GamepadBindings::defaultButton(Action action) -> int {
|
||||||
|
// Defaults històrics de l'aee_2026 (vegeu Player::accumulateGamepadMovement
|
||||||
|
// i les consultes del Director per al menú).
|
||||||
|
switch (action) {
|
||||||
|
case Action::JUMP:
|
||||||
|
return static_cast<int>(SDL_GAMEPAD_BUTTON_SOUTH);
|
||||||
|
case Action::ATTACK:
|
||||||
|
return static_cast<int>(SDL_GAMEPAD_BUTTON_WEST);
|
||||||
|
case Action::SERVICE:
|
||||||
|
return static_cast<int>(SDL_GAMEPAD_BUTTON_BACK);
|
||||||
|
}
|
||||||
|
return static_cast<int>(SDL_GAMEPAD_BUTTON_INVALID);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto GamepadBindings::findConfig(const std::string& name, const std::string& path) const -> int {
|
||||||
|
if (!path.empty()) {
|
||||||
|
for (std::size_t i = 0; i < configs_.size(); ++i) {
|
||||||
|
if (configs_[i].path == path) { return static_cast<int>(i); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!name.empty()) {
|
||||||
|
for (std::size_t i = 0; i < configs_.size(); ++i) {
|
||||||
|
if (configs_[i].name == name) { return static_cast<int>(i); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto GamepadBindings::getButton(const std::string& name, const std::string& path, Action action) const -> int {
|
||||||
|
const int IDX = findConfig(name, path);
|
||||||
|
if (IDX < 0) { return defaultButton(action); }
|
||||||
|
const auto& m = configs_[static_cast<std::size_t>(IDX)].bindings;
|
||||||
|
auto it = m.find(action);
|
||||||
|
return (it != m.end()) ? it->second : defaultButton(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GamepadBindings::setBindings(const std::string& name,
|
||||||
|
const std::string& path,
|
||||||
|
const std::unordered_map<Action, int>& bindings) {
|
||||||
|
int idx = findConfig(name, path);
|
||||||
|
if (idx < 0) {
|
||||||
|
configs_.push_back(Config{.name = name, .path = path, .bindings = bindings});
|
||||||
|
} else {
|
||||||
|
auto& cfg = configs_[static_cast<std::size_t>(idx)];
|
||||||
|
cfg.name = name;
|
||||||
|
cfg.path = path;
|
||||||
|
cfg.bindings = bindings;
|
||||||
|
}
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto GamepadBindings::isPressed(SDL_Gamepad* pad, int button) -> bool {
|
||||||
|
if (pad == nullptr) { return false; }
|
||||||
|
if (button == TRIGGER_L2_AS_BUTTON) {
|
||||||
|
return SDL_GetGamepadAxis(pad, SDL_GAMEPAD_AXIS_LEFT_TRIGGER) > TRIGGER_THRESHOLD;
|
||||||
|
}
|
||||||
|
if (button == TRIGGER_R2_AS_BUTTON) {
|
||||||
|
return SDL_GetGamepadAxis(pad, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER) > TRIGGER_THRESHOLD;
|
||||||
|
}
|
||||||
|
return SDL_GetGamepadButton(pad, static_cast<SDL_GamepadButton>(button));
|
||||||
|
}
|
||||||
|
|
||||||
|
void GamepadBindings::load(const std::string& file_path) {
|
||||||
|
file_path_ = file_path;
|
||||||
|
configs_.clear();
|
||||||
|
|
||||||
|
std::ifstream file(file_path);
|
||||||
|
if (!file) { return; }
|
||||||
|
std::stringstream buf;
|
||||||
|
buf << file.rdbuf();
|
||||||
|
const std::string CONTENT = buf.str();
|
||||||
|
if (CONTENT.empty()) { return; }
|
||||||
|
|
||||||
|
try {
|
||||||
|
auto yaml = fkyaml::node::deserialize(CONTENT);
|
||||||
|
if (!yaml.contains("gamepads") || !yaml["gamepads"].is_sequence()) {
|
||||||
|
std::cerr << "GamepadBindings: secció 'gamepads' absent o invàlida a "
|
||||||
|
<< file_path << '\n';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (const auto& entry : yaml["gamepads"]) {
|
||||||
|
Config cfg;
|
||||||
|
if (entry.contains("name")) { cfg.name = entry["name"].get_value<std::string>(); }
|
||||||
|
if (entry.contains("path")) { cfg.path = entry["path"].get_value<std::string>(); }
|
||||||
|
if (entry.contains("bindings") && entry["bindings"].is_mapping()) {
|
||||||
|
for (const auto& kv : entry["bindings"].as_map()) {
|
||||||
|
const auto KEY = kv.first.get_value<std::string>();
|
||||||
|
const auto VAL = kv.second.get_value<std::string>();
|
||||||
|
Action action{};
|
||||||
|
int btn = 0;
|
||||||
|
if (stringToAction(KEY, action) && stringToButton(VAL, btn)) {
|
||||||
|
cfg.bindings[action] = btn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
configs_.push_back(std::move(cfg));
|
||||||
|
}
|
||||||
|
std::cout << "GamepadBindings: " << configs_.size() << " mandos carregats de "
|
||||||
|
<< file_path << '\n';
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
std::cerr << "GamepadBindings: error parsejant " << file_path << ": "
|
||||||
|
<< e.what() << '\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto GamepadBindings::save() -> bool {
|
||||||
|
if (file_path_.empty()) { return false; }
|
||||||
|
|
||||||
|
std::ostringstream out;
|
||||||
|
out << "# AEE 2026 - Vinculacions de mando per dispositiu.\n";
|
||||||
|
out << "# Auto-generat des del menú de servei. Editable a mà.\n";
|
||||||
|
out << "gamepads:\n";
|
||||||
|
for (const auto& cfg : configs_) {
|
||||||
|
out << " - name: \"" << cfg.name << "\"\n";
|
||||||
|
out << " path: \"" << cfg.path << "\"\n";
|
||||||
|
out << " bindings:\n";
|
||||||
|
for (const auto& [action, button] : cfg.bindings) {
|
||||||
|
out << " " << actionToString(action) << ": \""
|
||||||
|
<< buttonToString(button) << "\"\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ofstream file(file_path_, std::ios::binary);
|
||||||
|
if (!file) {
|
||||||
|
std::cerr << "GamepadBindings: no es pot escriure " << file_path_ << '\n';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
file << out.str();
|
||||||
|
return file.good();
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
// Vinculacions remapeables d'accions del joc a botons d'un mando concret,
|
||||||
|
// indexades per `(name, path)` del mando — replica el patró
|
||||||
|
// `GamepadConfig` + `GamepadConfigManager` de coffee_crisis_arcade_edition.
|
||||||
|
//
|
||||||
|
// Persisteix en un YAML aïllat al system folder (no a `config.yaml`) perquè
|
||||||
|
// és per dispositiu, no per usuari/perfil: dos mandos diferents poden
|
||||||
|
// tenir mappings diferents i cap d'ells va lligat a un slot de jugador.
|
||||||
|
//
|
||||||
|
// El layer runtime (consultat per Player/Director cada frame) és
|
||||||
|
// directament aquesta classe; no hi ha caché a `GamepadManager::Entry`. El
|
||||||
|
// nombre d'entries persistides és típicament <10, i les accions són 3
|
||||||
|
// (JUMP/ATTACK/SERVICE), així que les consultes són trivialment ràpides.
|
||||||
|
class GamepadBindings {
|
||||||
|
public:
|
||||||
|
enum class Action : std::uint8_t {
|
||||||
|
JUMP,
|
||||||
|
ATTACK,
|
||||||
|
SERVICE,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Triggers L2/R2 representats com a "botons virtuals" — replica la
|
||||||
|
// convenció de coffee_crisis_arcade_edition (`TRIGGER_L2_AS_BUTTON`,
|
||||||
|
// `TRIGGER_R2_AS_BUTTON`). El threshold viu a `isPressed`.
|
||||||
|
static constexpr int TRIGGER_L2_AS_BUTTON = 100;
|
||||||
|
static constexpr int TRIGGER_R2_AS_BUTTON = 101;
|
||||||
|
|
||||||
|
static auto get() -> GamepadBindings&;
|
||||||
|
|
||||||
|
GamepadBindings(const GamepadBindings&) = delete;
|
||||||
|
GamepadBindings(GamepadBindings&&) = delete;
|
||||||
|
auto operator=(const GamepadBindings&) -> GamepadBindings& = delete;
|
||||||
|
auto operator=(GamepadBindings&&) -> GamepadBindings& = delete;
|
||||||
|
|
||||||
|
// Fixa la ruta del fitxer persistent + el carrega. Si no existix
|
||||||
|
// encara, l'estat queda buit (les consultes retornaran defaults) i
|
||||||
|
// `save()` el crearà al primer `setBindings`.
|
||||||
|
void load(const std::string& file_path);
|
||||||
|
|
||||||
|
// Persistix l'estat actual (totes les Config conegudes). Cridat
|
||||||
|
// automàticament dins de `setBindings` — no cal cridar-la a mà.
|
||||||
|
auto save() -> bool;
|
||||||
|
|
||||||
|
// Retorna el botó (o trigger virtual 100/101) lligat a `action` per al
|
||||||
|
// mando identificat per (name, path). Si no hi ha entrada per aquest
|
||||||
|
// mando, retorna el default global. La cerca és primer per `path`
|
||||||
|
// (re-vincular el mateix mando al mateix port és prioritari) i, si no
|
||||||
|
// troba, fallback per `name` (mando connectat a un altre port USB).
|
||||||
|
[[nodiscard]] auto getButton(const std::string& name, const std::string& path, Action action) const -> int;
|
||||||
|
|
||||||
|
// Reescriu totes les vinculacions del mando (name, path). Si no hi
|
||||||
|
// havia config per aquest dispositiu, en crea una nova. Persisteix a
|
||||||
|
// disc immediatament. Replicació de `Input::saveGamepadConfigFromGamepad`.
|
||||||
|
void setBindings(const std::string& name,
|
||||||
|
const std::string& path,
|
||||||
|
const std::unordered_map<Action, int>& bindings);
|
||||||
|
|
||||||
|
// Wrapper de polling: torna `true` si el "botó" (o trigger virtual)
|
||||||
|
// està premut ara mateix al mando `pad`. Encapsula el threshold per
|
||||||
|
// a L2/R2 (~50% del rang).
|
||||||
|
[[nodiscard]] static auto isPressed(SDL_Gamepad* pad, int button) -> bool;
|
||||||
|
|
||||||
|
// Default de fàbrica per a una acció — usat tant pel fallback de
|
||||||
|
// `getButton` com per inicialitzar la seqüència del DefineButtons.
|
||||||
|
[[nodiscard]] static auto defaultButton(Action action) -> int;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct Config {
|
||||||
|
std::string name;
|
||||||
|
std::string path;
|
||||||
|
std::unordered_map<Action, int> bindings;
|
||||||
|
};
|
||||||
|
|
||||||
|
GamepadBindings() = default;
|
||||||
|
~GamepadBindings() = default;
|
||||||
|
|
||||||
|
// Localitza la Config que coincideix amb (name, path); retorna -1 si
|
||||||
|
// no la troba. Match prioritari per path, fallback per nom.
|
||||||
|
[[nodiscard]] auto findConfig(const std::string& name, const std::string& path) const -> int;
|
||||||
|
|
||||||
|
std::vector<Config> configs_;
|
||||||
|
std::string file_path_;
|
||||||
|
};
|
||||||
@@ -89,6 +89,9 @@ namespace GlobalInputs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onNextShader() {
|
void onNextShader() {
|
||||||
|
// F5/F6 només tenen sentit quan els shaders estan actius. Si no,
|
||||||
|
// ignorem la pulsació en silenci — l'usuari ha de prémer F4 abans.
|
||||||
|
if (!Options::video().shader.enabled) { return; }
|
||||||
const std::string NEW_NAME = (Options::video().shader.current_shader == "crtpi") ? "postfx" : "crtpi";
|
const std::string NEW_NAME = (Options::video().shader.current_shader == "crtpi") ? "postfx" : "crtpi";
|
||||||
Options::setActiveShaderName(NEW_NAME);
|
Options::setActiveShaderName(NEW_NAME);
|
||||||
OptionsApply::reapplyShader();
|
OptionsApply::reapplyShader();
|
||||||
@@ -98,6 +101,7 @@ namespace GlobalInputs {
|
|||||||
// Busca l'entrada actual al vector de presets i passa a la següent
|
// Busca l'entrada actual al vector de presets i passa a la següent
|
||||||
// (wrap-around). Si no en troba cap s'evita el canvi silenciosament.
|
// (wrap-around). Si no en troba cap s'evita el canvi silenciosament.
|
||||||
void onNextPreset() {
|
void onNextPreset() {
|
||||||
|
if (!Options::video().shader.enabled) { return; }
|
||||||
const bool IS_CRTPI = Options::video().shader.current_shader == "crtpi";
|
const bool IS_CRTPI = Options::video().shader.current_shader == "crtpi";
|
||||||
std::string new_preset;
|
std::string new_preset;
|
||||||
if (IS_CRTPI) {
|
if (IS_CRTPI) {
|
||||||
@@ -154,6 +158,14 @@ namespace GlobalInputs {
|
|||||||
Options::setVideoRenderInfoPosition(static_cast<Defaults::RenderInfoPosition>(NEXT));
|
Options::setVideoRenderInfoPosition(static_cast<Defaults::RenderInfoPosition>(NEXT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Debug helper: dispara una notificació prou llarga perquè
|
||||||
|
// `wrapToWidth` la parteixi en (almenys) dues línies. Útil per a
|
||||||
|
// verificar visualment el padding asimètric, el line_gap i la caixa
|
||||||
|
// multilinia després de tocar la geometria a `data/ui.yaml`.
|
||||||
|
void onDebugLongNotification() {
|
||||||
|
Notification::notify("Notificació de prova llarga per a comprovar que el text es parteix correctament en dues línies dins la caixa.");
|
||||||
|
}
|
||||||
|
|
||||||
void onExit() {
|
void onExit() {
|
||||||
if (exit_window_s > 0.0F) {
|
if (exit_window_s > 0.0F) {
|
||||||
quit_requested = true;
|
quit_requested = true;
|
||||||
@@ -193,6 +205,10 @@ namespace GlobalInputs {
|
|||||||
onCycleRenderInfo();
|
onCycleRenderInfo();
|
||||||
} else if (SC == KeyConfig::get().scancode("exit")) {
|
} else if (SC == KeyConfig::get().scancode("exit")) {
|
||||||
onExit();
|
onExit();
|
||||||
|
} else if (SC == SDL_SCANCODE_KP_2) {
|
||||||
|
// Tecla de debug fora del KeyConfig: dispara una notificació
|
||||||
|
// multilinia per a inspeccionar el layout de la caixa.
|
||||||
|
onDebugLongNotification();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "core/rendering/screen.hpp"
|
#include "core/rendering/screen.hpp"
|
||||||
#include "core/rendering/text.hpp"
|
#include "core/rendering/text.hpp"
|
||||||
|
#include "core/ui/ui_config.hpp"
|
||||||
#include "utils/defines.hpp"
|
#include "utils/defines.hpp"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -67,26 +68,39 @@ void Notifier::init(std::shared_ptr<Text> text, const Palette& ui_palette) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Notifier::update(int delta_ms) {
|
void Notifier::update(int delta_ms) {
|
||||||
const float DT = static_cast<float>(delta_ms) / 1000.0F;
|
const auto& geo = UiConfig::get().notifier();
|
||||||
switch (status_) {
|
switch (status_) {
|
||||||
case Status::RISING:
|
case Status::RISING: {
|
||||||
y_ += SLIDE_SPEED * DT;
|
slide_elapsed_ms_ += delta_ms;
|
||||||
if (y_ >= static_cast<float>(MARGIN_TOP)) {
|
if (slide_elapsed_ms_ >= geo.slide_ms) {
|
||||||
y_ = static_cast<float>(MARGIN_TOP);
|
y_ = slide_y_on_;
|
||||||
status_ = Status::ACTIVE;
|
status_ = Status::ACTIVE;
|
||||||
|
} else {
|
||||||
|
const float T = static_cast<float>(slide_elapsed_ms_) / static_cast<float>(geo.slide_ms);
|
||||||
|
const float K = geo.slide_in_curve(T);
|
||||||
|
y_ = slide_y_off_ + ((slide_y_on_ - slide_y_off_) * K);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case Status::ACTIVE:
|
case Status::ACTIVE:
|
||||||
remaining_ms_ -= delta_ms;
|
remaining_ms_ -= delta_ms;
|
||||||
if (remaining_ms_ <= 0) { status_ = Status::VANISHING; }
|
if (remaining_ms_ <= 0) {
|
||||||
break;
|
slide_elapsed_ms_ = 0;
|
||||||
case Status::VANISHING:
|
status_ = Status::VANISHING;
|
||||||
y_ -= SLIDE_SPEED * DT;
|
|
||||||
if (y_ <= static_cast<float>(-current_box_h_)) {
|
|
||||||
y_ = static_cast<float>(-current_box_h_ - MARGIN_TOP);
|
|
||||||
status_ = Status::HIDDEN;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Status::VANISHING: {
|
||||||
|
slide_elapsed_ms_ += delta_ms;
|
||||||
|
if (slide_elapsed_ms_ >= geo.slide_ms) {
|
||||||
|
y_ = slide_y_off_;
|
||||||
|
status_ = Status::HIDDEN;
|
||||||
|
} else {
|
||||||
|
const float T = static_cast<float>(slide_elapsed_ms_) / static_cast<float>(geo.slide_ms);
|
||||||
|
const float K = geo.slide_out_curve(T);
|
||||||
|
y_ = slide_y_on_ + ((slide_y_off_ - slide_y_on_) * K);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -95,6 +109,7 @@ void Notifier::update(int delta_ms) {
|
|||||||
void Notifier::render() {
|
void Notifier::render() {
|
||||||
if (status_ == Status::HIDDEN || text_ == nullptr || current_lines_.empty()) { return; }
|
if (status_ == Status::HIDDEN || text_ == nullptr || current_lines_.empty()) { return; }
|
||||||
|
|
||||||
|
const auto& geo = UiConfig::get().notifier();
|
||||||
const int BOX_X = (GameCanvas::WIDTH - current_box_w_) / 2;
|
const int BOX_X = (GameCanvas::WIDTH - current_box_w_) / 2;
|
||||||
const int BOX_Y = static_cast<int>(y_);
|
const int BOX_Y = static_cast<int>(y_);
|
||||||
|
|
||||||
@@ -102,8 +117,17 @@ void Notifier::render() {
|
|||||||
// (ARGB directe al canvas, sense tocar cap surface paletada).
|
// (ARGB directe al canvas, sense tocar cap surface paletada).
|
||||||
Screen::get().fillRect(BOX_X, BOX_Y, current_box_w_, current_box_h_, ui_palette_[current_bg_color_]);
|
Screen::get().fillRect(BOX_X, BOX_Y, current_box_w_, current_box_h_, ui_palette_[current_bg_color_]);
|
||||||
|
|
||||||
const int LINE_STEP = Rendering::Hud::FONT_SIZE_PX + LINE_GAP;
|
// Vora externa: 4 línies d'1 px del color del text, paral·leles a cada
|
||||||
int line_y = BOX_Y + PADDING_V;
|
// costat i una mica fora de la caixa. Cada segment es queda dins del
|
||||||
|
// rang del costat corresponent perquè les cantonades no es cobrisquen.
|
||||||
|
const std::uint32_t BORDER_ARGB = ui_palette_[current_text_color_];
|
||||||
|
Screen::get().fillRect(BOX_X, BOX_Y - geo.border_px, current_box_w_, geo.border_px, BORDER_ARGB);
|
||||||
|
Screen::get().fillRect(BOX_X, BOX_Y + current_box_h_, current_box_w_, geo.border_px, BORDER_ARGB);
|
||||||
|
Screen::get().fillRect(BOX_X - geo.border_px, BOX_Y, geo.border_px, current_box_h_, BORDER_ARGB);
|
||||||
|
Screen::get().fillRect(BOX_X + current_box_w_, BOX_Y, geo.border_px, current_box_h_, BORDER_ARGB);
|
||||||
|
|
||||||
|
const int LINE_STEP = Rendering::Hud::FONT_SIZE_PX + geo.line_gap;
|
||||||
|
int line_y = BOX_Y + geo.padding_top;
|
||||||
for (const auto& line : current_lines_) {
|
for (const auto& line : current_lines_) {
|
||||||
text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG,
|
text_->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG,
|
||||||
GameCanvas::CENTER_X,
|
GameCanvas::CENTER_X,
|
||||||
@@ -120,18 +144,26 @@ void Notifier::notify(const std::string& text, Uint8 text_color, Uint8 bg_color,
|
|||||||
// gestionar-ne una cua, canviar ací per una FIFO quan calga.
|
// gestionar-ne una cua, canviar ací per una FIFO quan calga.
|
||||||
if (text_ == nullptr) { return; }
|
if (text_ == nullptr) { return; }
|
||||||
|
|
||||||
|
const auto& geo = UiConfig::get().notifier();
|
||||||
|
const int MAX_TEXT_WIDTH = GameCanvas::WIDTH - (2 * SIDE_MARGIN) - (2 * geo.padding_h);
|
||||||
current_lines_ = wrapToWidth(text, MAX_TEXT_WIDTH, *text_, 1);
|
current_lines_ = wrapToWidth(text, MAX_TEXT_WIDTH, *text_, 1);
|
||||||
|
|
||||||
// Amplada = max de les línies + padding. Alçada = N*glif + (N-1)*gap + padding.
|
// Amplada = max de les línies + padding. Alçada = N*glif + (N-1)*gap + padding asimètric.
|
||||||
const int MAX_LINE_W = std::accumulate(current_lines_.begin(), current_lines_.end(), 0, [this](int acc, const std::string& s) { return std::max(acc, text_->length(s, 1)); });
|
const int MAX_LINE_W = std::accumulate(current_lines_.begin(), current_lines_.end(), 0, [this](int acc, const std::string& s) { return std::max(acc, text_->length(s, 1)); });
|
||||||
current_box_w_ = MAX_LINE_W + (2 * PADDING_H);
|
current_box_w_ = MAX_LINE_W + (2 * geo.padding_h);
|
||||||
|
|
||||||
const int N = static_cast<int>(current_lines_.size());
|
const int N = static_cast<int>(current_lines_.size());
|
||||||
current_box_h_ = (N * Rendering::Hud::FONT_SIZE_PX) + ((N - 1) * LINE_GAP) + (2 * PADDING_V);
|
current_box_h_ = (N * Rendering::Hud::FONT_SIZE_PX) + ((N - 1) * geo.line_gap) + geo.padding_top + geo.padding_bottom;
|
||||||
|
|
||||||
current_text_color_ = text_color;
|
current_text_color_ = text_color;
|
||||||
current_bg_color_ = bg_color;
|
current_bg_color_ = bg_color;
|
||||||
remaining_ms_ = time_ms;
|
remaining_ms_ = time_ms;
|
||||||
y_ = static_cast<float>(-current_box_h_ - MARGIN_TOP);
|
|
||||||
|
// Posicions extremes en y (top-left de la caixa). Off = totalment fora
|
||||||
|
// del canvas per dalt; On = posició final amb la vora respectada.
|
||||||
|
slide_y_off_ = static_cast<float>(-current_box_h_ - geo.border_px - geo.margin_top);
|
||||||
|
slide_y_on_ = static_cast<float>(geo.margin_top + geo.border_px);
|
||||||
|
slide_elapsed_ms_ = 0;
|
||||||
|
y_ = slide_y_off_;
|
||||||
status_ = Status::RISING;
|
status_ = Status::RISING;
|
||||||
}
|
}
|
||||||
@@ -43,15 +43,11 @@ class Notifier {
|
|||||||
|
|
||||||
void notify(const std::string& text, Uint8 text_color, Uint8 bg_color, int time_ms);
|
void notify(const std::string& text, Uint8 text_color, Uint8 bg_color, int time_ms);
|
||||||
|
|
||||||
static constexpr int PADDING_H = 6;
|
// Marge lateral entre la caixa i les vores esquerra/dreta del canvas.
|
||||||
static constexpr int PADDING_V = 3;
|
// Limita l'amplada disponible al text en multilinia (combinat amb el
|
||||||
static constexpr int LINE_GAP = 1; // Separació vertical entre línies multilinia.
|
// padding horitzontal llegit d'UiConfig). No està exposat al YAML
|
||||||
static constexpr int MARGIN_TOP = 2; // Separació amb la vora superior del canvas.
|
// perquè en pantalles 240 px no té sentit retallar més.
|
||||||
static constexpr float SLIDE_SPEED = 120.0F;
|
static constexpr int SIDE_MARGIN = 10;
|
||||||
// Amplada màxima (sense comptar padding) que pot ocupar el text abans que
|
|
||||||
// `wrapToWidth` el parteixi en línies. Deixem marge respecte a la vora del
|
|
||||||
// canvas perquè la caixa no toqui els laterals.
|
|
||||||
static constexpr int MAX_TEXT_WIDTH = GameCanvas::WIDTH - 20 - (2 * PADDING_H);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class Status : std::uint8_t { HIDDEN,
|
enum class Status : std::uint8_t { HIDDEN,
|
||||||
@@ -72,4 +68,11 @@ class Notifier {
|
|||||||
Uint8 current_text_color_{0};
|
Uint8 current_text_color_{0};
|
||||||
Uint8 current_bg_color_{0};
|
Uint8 current_bg_color_{0};
|
||||||
int remaining_ms_{0};
|
int remaining_ms_{0};
|
||||||
|
|
||||||
|
// Animació d'entrada/eixida per temps. `slide_elapsed_ms_` avança
|
||||||
|
// amb el delta dins de RISING/VANISHING; els extrems s'avaluen a
|
||||||
|
// `notify()` perquè depenen de la mida de la caixa.
|
||||||
|
int slide_elapsed_ms_{0};
|
||||||
|
float slide_y_off_{0.0F};
|
||||||
|
float slide_y_on_{0.0F};
|
||||||
};
|
};
|
||||||
@@ -7,36 +7,19 @@
|
|||||||
|
|
||||||
#include "core/rendering/surface.hpp"
|
#include "core/rendering/surface.hpp"
|
||||||
#include "core/resources/resource_cache.hpp"
|
#include "core/resources/resource_cache.hpp"
|
||||||
#include "external/fkyaml_node.hpp"
|
|
||||||
|
// El parser pure de YAML d'animacions (parseAnimationsFromYaml + helpers)
|
||||||
|
// viu a `animated_sprite_parser.cpp` perquè és testable sense Surface ni
|
||||||
|
// Resource::Cache. Aquesta unitat es queda amb el runtime de la classe i
|
||||||
|
// amb el que sí toca el cache de surfaces (parseSpriteBlock).
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
auto convertYamlFramesToRects(const fkyaml::node& frames_node, float frame_width, float frame_height, int frames_per_row, int max_tiles) -> std::vector<SDL_FRect> {
|
|
||||||
std::vector<SDL_FRect> frames;
|
|
||||||
SDL_FRect rect = {.x = 0.0F, .y = 0.0F, .w = frame_width, .h = frame_height};
|
|
||||||
for (const auto& frame_index_node : frames_node) {
|
|
||||||
const int NUM_TILE = frame_index_node.get_value<int>();
|
|
||||||
if (NUM_TILE <= max_tiles) {
|
|
||||||
rect.x = static_cast<float>(NUM_TILE % frames_per_row) * frame_width;
|
|
||||||
rect.y = static_cast<float>(NUM_TILE / frames_per_row) * frame_height;
|
|
||||||
frames.emplace_back(rect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return frames;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct SheetParams {
|
|
||||||
float frame_width{0.0F};
|
|
||||||
float frame_height{0.0F};
|
|
||||||
int frames_per_row{1};
|
|
||||||
int max_tiles{1};
|
|
||||||
};
|
|
||||||
|
|
||||||
// Llegeix el bloc `sprite: { path, size: [w, h] }` — mateix format que
|
// Llegeix el bloc `sprite: { path, size: [w, h] }` — mateix format que
|
||||||
// les plantilles d'entitat. La surface es resol via Resource::Cache amb
|
// les plantilles d'entitat. La surface es resol via Resource::Cache amb
|
||||||
// el basename del fitxer.
|
// el basename del fitxer.
|
||||||
auto parseSpriteBlock(const fkyaml::node& yaml, std::shared_ptr<Surface>& surface) -> SheetParams {
|
auto parseSpriteBlock(const fkyaml::node& yaml, std::shared_ptr<Surface>& surface) -> AnimatedSprite::SheetParams {
|
||||||
SheetParams params;
|
AnimatedSprite::SheetParams params;
|
||||||
if (!yaml.contains("sprite")) { return params; }
|
if (!yaml.contains("sprite")) { return params; }
|
||||||
const auto& s = yaml["sprite"];
|
const auto& s = yaml["sprite"];
|
||||||
if (s.contains("path")) {
|
if (s.contains("path")) {
|
||||||
@@ -57,62 +40,18 @@ namespace {
|
|||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
// `frame_ms` pot ser un escalar (temps uniforme) o una llista (per-frame).
|
// Tradueix els flags lògics flip_h/flip_v al `SDL_FlipMode` que admet
|
||||||
// Convertim sempre a segons perquè `animate()` treballa amb delta_time
|
// `Surface::render`. Important: a SDL3, `SDL_FlipMode` és un enum
|
||||||
// en segons. Si falta o val 0, `speeds` queda buit i l'animació es
|
// exclusiu (NONE/HORIZONTAL/VERTICAL), no un bitmask combinable. Per
|
||||||
// considera estàtica (no avança).
|
// tant, V+H simultani al mateix frame no es pot expressar amb una
|
||||||
void parseFrameTimes(const fkyaml::node& anim_node, AnimatedSprite::AnimationData& animation) {
|
// única crida — prioritzem H (suficient per als casos pràctics
|
||||||
if (!anim_node.contains("frame_ms")) { return; }
|
// d'animació, com `walk_west` o `death_spin`). Si en algun moment fa
|
||||||
const auto& fm = anim_node["frame_ms"];
|
// falta combinar, caldrà ampliar `Surface::render` per a doble-flipar
|
||||||
if (fm.is_sequence()) {
|
// a baix nivell.
|
||||||
for (const auto& v : fm) {
|
auto toFlipMode(bool flip_h, bool flip_v) -> SDL_FlipMode {
|
||||||
animation.speeds.push_back(static_cast<float>(v.get_value<int>()) / 1000.0F);
|
if (flip_h) { return SDL_FLIP_HORIZONTAL; }
|
||||||
}
|
if (flip_v) { return SDL_FLIP_VERTICAL; }
|
||||||
} else {
|
return SDL_FLIP_NONE;
|
||||||
const float SEC = static_cast<float>(fm.get_value<int>()) / 1000.0F;
|
|
||||||
if (SEC > 0.0F) { animation.speeds.assign(animation.frames.size(), SEC); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ordre de prioritat per a la política de loop:
|
|
||||||
// 1) `loop_from: N` → rebota al frame N en passar del final (implica loop).
|
|
||||||
// 2) `loop: false` → animació d'un sol tret (es queda al darrer frame).
|
|
||||||
// 3) Res → loop complet des del frame 0 (default).
|
|
||||||
void parseLoopPolicy(const fkyaml::node& anim_node, AnimatedSprite::AnimationData& animation) {
|
|
||||||
if (anim_node.contains("loop_from")) {
|
|
||||||
animation.loop_from = anim_node["loop_from"].get_value<int>();
|
|
||||||
} else if (anim_node.contains("loop") && !anim_node["loop"].get_value<bool>()) {
|
|
||||||
animation.loop_from = -1;
|
|
||||||
} else {
|
|
||||||
animation.loop_from = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto parseAnimations(const fkyaml::node& yaml, const SheetParams& params) -> std::unordered_map<std::string, AnimatedSprite::AnimationData> {
|
|
||||||
std::unordered_map<std::string, AnimatedSprite::AnimationData> animations;
|
|
||||||
if (!yaml.contains("animations") || !yaml["animations"].is_mapping()) {
|
|
||||||
return animations;
|
|
||||||
}
|
|
||||||
const auto& anims_node = yaml["animations"];
|
|
||||||
for (auto it = anims_node.begin(); it != anims_node.end(); ++it) {
|
|
||||||
const auto NAME = it.key().get_value<std::string>();
|
|
||||||
const auto& anim_node = *it;
|
|
||||||
|
|
||||||
AnimatedSprite::AnimationData animation;
|
|
||||||
if (anim_node.contains("frames") && anim_node["frames"].is_sequence()) {
|
|
||||||
animation.frames = convertYamlFramesToRects(
|
|
||||||
anim_node["frames"],
|
|
||||||
params.frame_width,
|
|
||||||
params.frame_height,
|
|
||||||
params.frames_per_row,
|
|
||||||
params.max_tiles);
|
|
||||||
}
|
|
||||||
parseFrameTimes(anim_node, animation);
|
|
||||||
parseLoopPolicy(anim_node, animation);
|
|
||||||
|
|
||||||
animations.emplace(NAME, std::move(animation));
|
|
||||||
}
|
|
||||||
return animations;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@@ -122,7 +61,7 @@ AnimatedSprite::AnimatedSprite(const AnimationResource& cached_data) {
|
|||||||
try {
|
try {
|
||||||
auto yaml = fkyaml::node::deserialize(yaml_content);
|
auto yaml = fkyaml::node::deserialize(yaml_content);
|
||||||
auto params = parseSpriteBlock(yaml, surface_);
|
auto params = parseSpriteBlock(yaml, surface_);
|
||||||
animations_ = parseAnimations(yaml, params);
|
animations_ = parseAnimationsFromYaml(yaml, params);
|
||||||
|
|
||||||
setWidth(params.frame_width);
|
setWidth(params.frame_width);
|
||||||
setHeight(params.frame_height);
|
setHeight(params.frame_height);
|
||||||
@@ -132,7 +71,7 @@ AnimatedSprite::AnimatedSprite(const AnimationResource& cached_data) {
|
|||||||
// abans del primer `update()`, així que el valor real el posa ell.
|
// abans del primer `update()`, així que el valor real el posa ell.
|
||||||
if (!animations_.empty()) {
|
if (!animations_.empty()) {
|
||||||
const auto& first = animations_.begin()->second;
|
const auto& first = animations_.begin()->second;
|
||||||
if (!first.frames.empty()) { setClip(first.frames[0]); }
|
if (!first.frames.empty()) { setClip(first.frames[0].rect); }
|
||||||
}
|
}
|
||||||
} catch (const fkyaml::exception& e) {
|
} catch (const fkyaml::exception& e) {
|
||||||
std::cerr << "YAML parsing error in animation " << cached_data.name << ": " << e.what() << '\n';
|
std::cerr << "YAML parsing error in animation " << cached_data.name << ": " << e.what() << '\n';
|
||||||
@@ -154,11 +93,20 @@ void AnimatedSprite::animate(float delta_time) {
|
|||||||
|
|
||||||
const float TOTAL = std::accumulate(anim.speeds.begin(), anim.speeds.end(), 0.0F);
|
const float TOTAL = std::accumulate(anim.speeds.begin(), anim.speeds.end(), 0.0F);
|
||||||
|
|
||||||
|
// Helper local per a propagar el frame actual (clip + flip) al sprite.
|
||||||
|
// El motor sempre sobreescriu el flip — si el YAML no declara `flip_h`/
|
||||||
|
// `flip_v`, el frame té els flags a false i el resultat és `SDL_FLIP_NONE`.
|
||||||
|
auto apply_current_frame = [&](int frame_index) {
|
||||||
|
const auto& frame = anim.frames[frame_index];
|
||||||
|
setClip(frame.rect);
|
||||||
|
setFlip(toFlipMode(frame.flip_h, frame.flip_v));
|
||||||
|
};
|
||||||
|
|
||||||
if (anim.accumulated_time >= TOTAL) {
|
if (anim.accumulated_time >= TOTAL) {
|
||||||
if (anim.loop_from < 0) {
|
if (anim.loop_from < 0) {
|
||||||
anim.current_frame = static_cast<int>(anim.frames.size()) - 1;
|
anim.current_frame = static_cast<int>(anim.frames.size()) - 1;
|
||||||
anim.completed = true;
|
anim.completed = true;
|
||||||
setClip(anim.frames[anim.current_frame]);
|
apply_current_frame(anim.current_frame);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float loop_start = 0.0F;
|
float loop_start = 0.0F;
|
||||||
@@ -172,13 +120,13 @@ void AnimatedSprite::animate(float delta_time) {
|
|||||||
cursor += anim.speeds[i];
|
cursor += anim.speeds[i];
|
||||||
if (anim.accumulated_time < cursor) {
|
if (anim.accumulated_time < cursor) {
|
||||||
anim.current_frame = i;
|
anim.current_frame = i;
|
||||||
setClip(anim.frames[i]);
|
apply_current_frame(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
anim.current_frame = static_cast<int>(anim.frames.size()) - 1;
|
anim.current_frame = static_cast<int>(anim.frames.size()) - 1;
|
||||||
setClip(anim.frames[anim.current_frame]);
|
apply_current_frame(anim.current_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto AnimatedSprite::animationIsCompleted() -> bool {
|
auto AnimatedSprite::animationIsCompleted() -> bool {
|
||||||
@@ -200,7 +148,10 @@ void AnimatedSprite::setCurrentAnimation(const std::string& name) {
|
|||||||
anim.current_frame = 0;
|
anim.current_frame = 0;
|
||||||
anim.accumulated_time = 0.0F;
|
anim.accumulated_time = 0.0F;
|
||||||
anim.completed = false;
|
anim.completed = false;
|
||||||
if (!anim.frames.empty()) { setClip(anim.frames[0]); }
|
if (!anim.frames.empty()) {
|
||||||
|
setClip(anim.frames[0].rect);
|
||||||
|
setFlip(toFlipMode(anim.frames[0].flip_h, anim.frames[0].flip_v));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimatedSprite::update(float delta_time) {
|
void AnimatedSprite::update(float delta_time) {
|
||||||
|
|||||||
@@ -8,14 +8,41 @@
|
|||||||
|
|
||||||
#include "core/rendering/sprite/moving_sprite.hpp"
|
#include "core/rendering/sprite/moving_sprite.hpp"
|
||||||
#include "core/resources/resource_types.hpp"
|
#include "core/resources/resource_types.hpp"
|
||||||
|
#include "external/fkyaml_node.hpp"
|
||||||
|
|
||||||
class AnimatedSprite : public MovingSprite {
|
class AnimatedSprite : public MovingSprite {
|
||||||
public:
|
public:
|
||||||
|
// Un frame d'animació = rectangle dins el spritesheet + flags de flip
|
||||||
|
// associats. El flip s'aplica al sprite a `animate()` quan l'animació
|
||||||
|
// declara que ella controla el flip (vegeu `AnimationData::controls_flip`).
|
||||||
|
struct Frame {
|
||||||
|
SDL_FRect rect{.x = 0.0F, .y = 0.0F, .w = 0.0F, .h = 0.0F};
|
||||||
|
bool flip_h{false};
|
||||||
|
bool flip_v{false};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Paràmetres geomètrics del spritesheet, derivats del bloc `sprite:`
|
||||||
|
// del YAML. Es passen al parser d'animacions per a calcular els
|
||||||
|
// rectangles de cada frame a partir dels seus índexs.
|
||||||
|
struct SheetParams {
|
||||||
|
float frame_width{0.0F};
|
||||||
|
float frame_height{0.0F};
|
||||||
|
int frames_per_row{1};
|
||||||
|
int max_tiles{1};
|
||||||
|
};
|
||||||
|
|
||||||
// Dades d'una animació concreta dins d'un spritesheet. Les claus del
|
// Dades d'una animació concreta dins d'un spritesheet. Les claus del
|
||||||
// mapa (`animations_`) són els noms; aquí només es guarden els fotogrames
|
// mapa (`animations_`) són els noms; aquí només es guarden els fotogrames
|
||||||
// i l'estat de reproducció.
|
// i l'estat de reproducció.
|
||||||
|
//
|
||||||
|
// El flip és sempre propietat del motor: a cada `animate()` s'escriu el
|
||||||
|
// flip del frame actual al sprite (default `SDL_FLIP_NONE` quan el YAML
|
||||||
|
// no declara res). El codi del joc no pot — ni ha de — tocar el flip
|
||||||
|
// manualment; ho expressa al YAML declarant `flip_h: true` a l'animació
|
||||||
|
// simètrica (p. ex. `walk_west`) o, per a casos puntuals, per frame
|
||||||
|
// amb la forma mapping `{ index, flip_h?, flip_v? }`.
|
||||||
struct AnimationData {
|
struct AnimationData {
|
||||||
std::vector<SDL_FRect> frames;
|
std::vector<Frame> frames;
|
||||||
// Durada de cada frame en segons (convertit des de `frame_ms` al YAML).
|
// Durada de cada frame en segons (convertit des de `frame_ms` al YAML).
|
||||||
// Si té un sol valor, val per a tots els frames; altrament ha de tenir
|
// Si té un sol valor, val per a tots els frames; altrament ha de tenir
|
||||||
// la mateixa mida que `frames`.
|
// la mateixa mida que `frames`.
|
||||||
@@ -40,6 +67,12 @@ class AnimatedSprite : public MovingSprite {
|
|||||||
void resetAnimation();
|
void resetAnimation();
|
||||||
void animate(float delta_time);
|
void animate(float delta_time);
|
||||||
|
|
||||||
|
// Helper de parsing exposat per a testabilitat. NO toca el cache de
|
||||||
|
// recursos — només el bloc `animations:` del YAML i els paràmetres de
|
||||||
|
// full ja calculats. El ctor d'`AnimatedSprite` el crida internament.
|
||||||
|
static auto parseAnimationsFromYaml(const fkyaml::node& yaml, const SheetParams& params)
|
||||||
|
-> std::unordered_map<std::string, AnimationData>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_map<std::string, AnimationData> animations_;
|
std::unordered_map<std::string, AnimationData> animations_;
|
||||||
// Nom de l'animació activa. Buit fins que algú crida `setCurrentAnimation`.
|
// Nom de l'animació activa. Buit fins que algú crida `setCurrentAnimation`.
|
||||||
|
|||||||
@@ -0,0 +1,114 @@
|
|||||||
|
#include "core/rendering/sprite/animated_sprite.hpp"
|
||||||
|
|
||||||
|
// Implementació del parser pure de YAML d'animacions. Viu en una unitat
|
||||||
|
// separada perquè NO depèn de Resource::Cache ni de Surface — només de
|
||||||
|
// fkyaml — i això permet als tests stand-alone enllaçar només aquest .cpp
|
||||||
|
// per a verificar el parsing sense haver d'arrossegar tot l'stack de
|
||||||
|
// recursos i renderitzat.
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
// Construeix el rectangle d'un frame a partir del seu índex dins del
|
||||||
|
// spritesheet. Centralitzat per a no duplicar la fórmula als dos
|
||||||
|
// formats (escalar / mapping) que admet `frames:` al YAML.
|
||||||
|
auto rectFromIndex(int index, const AnimatedSprite::SheetParams& params) -> SDL_FRect {
|
||||||
|
return SDL_FRect{
|
||||||
|
.x = static_cast<float>(index % params.frames_per_row) * params.frame_width,
|
||||||
|
.y = static_cast<float>(index / params.frames_per_row) * params.frame_height,
|
||||||
|
.w = params.frame_width,
|
||||||
|
.h = params.frame_height,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Llig un node `frames` (seqüència) i el converteix a la nova
|
||||||
|
// representació `vector<Frame>`. Cada element pot ser:
|
||||||
|
// - escalar (int) → hereta `default_flip_h`/`default_flip_v` de l'animació.
|
||||||
|
// - mapping `{ index: N, flip_h?: bool, flip_v?: bool }` → fully
|
||||||
|
// explícit. Els flags absents defaulten a false (NO hereta de l'anim).
|
||||||
|
auto convertYamlFrames(const fkyaml::node& frames_node, const AnimatedSprite::SheetParams& params, bool default_flip_h, bool default_flip_v) -> std::vector<AnimatedSprite::Frame> {
|
||||||
|
std::vector<AnimatedSprite::Frame> frames;
|
||||||
|
for (const auto& frame_node : frames_node) {
|
||||||
|
if (frame_node.is_mapping()) {
|
||||||
|
if (!frame_node.contains("index")) { continue; }
|
||||||
|
const int NUM_TILE = frame_node["index"].get_value<int>();
|
||||||
|
if (NUM_TILE > params.max_tiles) { continue; }
|
||||||
|
AnimatedSprite::Frame frame;
|
||||||
|
frame.rect = rectFromIndex(NUM_TILE, params);
|
||||||
|
if (frame_node.contains("flip_h")) { frame.flip_h = frame_node["flip_h"].get_value<bool>(); }
|
||||||
|
if (frame_node.contains("flip_v")) { frame.flip_v = frame_node["flip_v"].get_value<bool>(); }
|
||||||
|
frames.emplace_back(frame);
|
||||||
|
} else {
|
||||||
|
const int NUM_TILE = frame_node.get_value<int>();
|
||||||
|
if (NUM_TILE > params.max_tiles) { continue; }
|
||||||
|
frames.emplace_back(AnimatedSprite::Frame{
|
||||||
|
.rect = rectFromIndex(NUM_TILE, params),
|
||||||
|
.flip_h = default_flip_h,
|
||||||
|
.flip_v = default_flip_v,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return frames;
|
||||||
|
}
|
||||||
|
|
||||||
|
// `frame_ms` pot ser un escalar (temps uniforme) o una llista (per-frame).
|
||||||
|
// Convertim sempre a segons perquè `animate()` treballa amb delta_time
|
||||||
|
// en segons. Si falta o val 0, `speeds` queda buit i l'animació es
|
||||||
|
// considera estàtica (no avança).
|
||||||
|
void parseFrameTimes(const fkyaml::node& anim_node, AnimatedSprite::AnimationData& animation) {
|
||||||
|
if (!anim_node.contains("frame_ms")) { return; }
|
||||||
|
const auto& fm = anim_node["frame_ms"];
|
||||||
|
if (fm.is_sequence()) {
|
||||||
|
for (const auto& v : fm) {
|
||||||
|
animation.speeds.push_back(static_cast<float>(v.get_value<int>()) / 1000.0F);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const float SEC = static_cast<float>(fm.get_value<int>()) / 1000.0F;
|
||||||
|
if (SEC > 0.0F) { animation.speeds.assign(animation.frames.size(), SEC); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ordre de prioritat per a la política de loop:
|
||||||
|
// 1) `loop_from: N` → rebota al frame N en passar del final (implica loop).
|
||||||
|
// 2) `loop: false` → animació d'un sol tret (es queda al darrer frame).
|
||||||
|
// 3) Res → loop complet des del frame 0 (default).
|
||||||
|
void parseLoopPolicy(const fkyaml::node& anim_node, AnimatedSprite::AnimationData& animation) {
|
||||||
|
if (anim_node.contains("loop_from")) {
|
||||||
|
animation.loop_from = anim_node["loop_from"].get_value<int>();
|
||||||
|
} else if (anim_node.contains("loop") && !anim_node["loop"].get_value<bool>()) {
|
||||||
|
animation.loop_from = -1;
|
||||||
|
} else {
|
||||||
|
animation.loop_from = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
auto AnimatedSprite::parseAnimationsFromYaml(const fkyaml::node& yaml, const SheetParams& params)
|
||||||
|
-> std::unordered_map<std::string, AnimationData> {
|
||||||
|
std::unordered_map<std::string, AnimationData> animations;
|
||||||
|
if (!yaml.contains("animations") || !yaml["animations"].is_mapping()) {
|
||||||
|
return animations;
|
||||||
|
}
|
||||||
|
const auto& anims_node = yaml["animations"];
|
||||||
|
for (auto it = anims_node.begin(); it != anims_node.end(); ++it) {
|
||||||
|
const auto NAME = it.key().get_value<std::string>();
|
||||||
|
const auto& anim_node = *it;
|
||||||
|
|
||||||
|
// Flags de flip a nivell d'animació (defaults a false). Els frames
|
||||||
|
// declarats com a int els hereten; els declarats com a mapping no.
|
||||||
|
bool anim_flip_h = false;
|
||||||
|
bool anim_flip_v = false;
|
||||||
|
if (anim_node.contains("flip_h")) { anim_flip_h = anim_node["flip_h"].get_value<bool>(); }
|
||||||
|
if (anim_node.contains("flip_v")) { anim_flip_v = anim_node["flip_v"].get_value<bool>(); }
|
||||||
|
|
||||||
|
AnimationData animation;
|
||||||
|
if (anim_node.contains("frames") && anim_node["frames"].is_sequence()) {
|
||||||
|
animation.frames = convertYamlFrames(anim_node["frames"], params, anim_flip_h, anim_flip_v);
|
||||||
|
}
|
||||||
|
parseFrameTimes(anim_node, animation);
|
||||||
|
parseLoopPolicy(anim_node, animation);
|
||||||
|
|
||||||
|
animations.emplace(NAME, std::move(animation));
|
||||||
|
}
|
||||||
|
return animations;
|
||||||
|
}
|
||||||
@@ -38,7 +38,7 @@ class MovingSprite : public Sprite {
|
|||||||
void setAccelY(float value) { ay_ = value; }
|
void setAccelY(float value) { ay_ = value; }
|
||||||
|
|
||||||
void setFlip(SDL_FlipMode flip) { flip_ = flip; }
|
void setFlip(SDL_FlipMode flip) { flip_ = flip; }
|
||||||
auto getFlip() -> SDL_FlipMode { return flip_; }
|
[[nodiscard]] auto getFlip() const -> SDL_FlipMode { return flip_; }
|
||||||
void flip() { flip_ = (flip_ == SDL_FLIP_HORIZONTAL) ? SDL_FLIP_NONE : SDL_FLIP_HORIZONTAL; }
|
void flip() { flip_ = (flip_ == SDL_FLIP_HORIZONTAL) ? SDL_FLIP_NONE : SDL_FLIP_HORIZONTAL; }
|
||||||
|
|
||||||
// Moviment eix-separat amb col·lisió: aplica `dx` (i si la nova
|
// Moviment eix-separat amb col·lisió: aplica `dx` (i si la nova
|
||||||
|
|||||||
@@ -15,12 +15,18 @@ namespace Resource::Helper {
|
|||||||
Pack g_pack;
|
Pack g_pack;
|
||||||
bool g_pack_loaded = false;
|
bool g_pack_loaded = false;
|
||||||
bool g_fallback_enabled = true;
|
bool g_fallback_enabled = true;
|
||||||
|
// Inverteix la prioritat (disc abans que pack). Activat en Debug
|
||||||
|
// per defecte; veure setPreferDisk al header.
|
||||||
|
bool g_prefer_disk = false;
|
||||||
|
|
||||||
auto readFromDisk(const std::string& filepath) -> std::vector<std::uint8_t> {
|
auto readFromDisk(const std::string& filepath, bool verbose = true) -> std::vector<std::uint8_t> {
|
||||||
const auto FULL = resolve(filepath);
|
const auto FULL = resolve(filepath);
|
||||||
std::ifstream file(FULL, std::ios::binary | std::ios::ate);
|
std::ifstream file(FULL, std::ios::binary | std::ios::ate);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
std::cerr << "Resource::Helper: cannot open " << FULL << '\n';
|
// Silenciem si veníem de prefer_disk: aleshores caurem
|
||||||
|
// al pack i no és cap error real que el fitxer no estigui
|
||||||
|
// al disc.
|
||||||
|
if (verbose) { std::cerr << "Resource::Helper: cannot open " << FULL << '\n'; }
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
std::streamsize size = file.tellg();
|
std::streamsize size = file.tellg();
|
||||||
@@ -37,6 +43,11 @@ namespace Resource::Helper {
|
|||||||
|
|
||||||
auto initializeResourceSystem(const std::string& pack_file, bool enable_fallback) -> bool {
|
auto initializeResourceSystem(const std::string& pack_file, bool enable_fallback) -> bool {
|
||||||
g_fallback_enabled = enable_fallback;
|
g_fallback_enabled = enable_fallback;
|
||||||
|
// En el flux Debug típic (fallback actiu, source tree disponible)
|
||||||
|
// preferim sempre disc: el desenvolupador edita YAML/GIF a `data/`
|
||||||
|
// i ho veu reflectit al següent reload sense re-packejar. En
|
||||||
|
// Release el fallback està desactivat i aquest flag és inert.
|
||||||
|
g_prefer_disk = enable_fallback;
|
||||||
g_pack_loaded = g_pack.loadPack(pack_file);
|
g_pack_loaded = g_pack.loadPack(pack_file);
|
||||||
|
|
||||||
if (g_pack_loaded) {
|
if (g_pack_loaded) {
|
||||||
@@ -76,17 +87,45 @@ namespace Resource::Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto loadFile(const std::string& filepath) -> std::vector<std::uint8_t> {
|
auto loadFile(const std::string& filepath) -> std::vector<std::uint8_t> {
|
||||||
if (g_pack_loaded) {
|
// Helper local: lookup al pack normalitzant la clau (els callers
|
||||||
// El pack està indexat relatiu a `data/` (la carpeta que
|
// passen "data/foo.yaml" però l'índex del pack és relatiu a la
|
||||||
// s'empaqueta), però els callers passen "data/foo.yaml" amb
|
// carpeta `data/`).
|
||||||
// prefix. Fem el strip ací perquè no hagin de tenir-ho en compte.
|
const auto FROM_PACK = [&filepath]() -> std::vector<std::uint8_t> {
|
||||||
|
if (!g_pack_loaded) { return {}; }
|
||||||
constexpr std::string_view PREFIX = "data/";
|
constexpr std::string_view PREFIX = "data/";
|
||||||
std::string key = filepath;
|
std::string key = filepath;
|
||||||
if (key.starts_with(PREFIX)) { key.erase(0, PREFIX.size()); }
|
if (key.starts_with(PREFIX)) { key.erase(0, PREFIX.size()); }
|
||||||
if (g_pack.hasResource(key)) { return g_pack.getResource(key); }
|
if (g_pack.hasResource(key)) { return g_pack.getResource(key); }
|
||||||
|
return {};
|
||||||
|
};
|
||||||
|
|
||||||
|
if (g_prefer_disk && g_fallback_enabled) {
|
||||||
|
// En Debug volem que el disc guanyi: així les edicions del
|
||||||
|
// editor in-game (i les manuals del repo) es vegen al pròxim
|
||||||
|
// reload sense rebuild del pack. Si el fitxer no és al disc,
|
||||||
|
// caiem al pack — útil per a recursos que només s'han
|
||||||
|
// empaquetat (cas estrany). El silenci a `readFromDisk` evita
|
||||||
|
// emplenar el log amb "cannot open" en aquest camí esperat.
|
||||||
|
auto bytes = readFromDisk(filepath, false);
|
||||||
|
if (!bytes.empty()) { return bytes; }
|
||||||
|
return FROM_PACK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Política original: pack primer; disc com a fallback si el
|
||||||
|
// recurs no està empaquetat (típic d'arrencada en Debug abans
|
||||||
|
// del primer pack).
|
||||||
|
auto packed = FROM_PACK();
|
||||||
|
if (!packed.empty()) { return packed; }
|
||||||
if (g_fallback_enabled) { return readFromDisk(filepath); }
|
if (g_fallback_enabled) { return readFromDisk(filepath); }
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setPreferDisk(bool prefer) {
|
||||||
|
g_prefer_disk = prefer;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto preferDisk() -> bool {
|
||||||
|
return g_prefer_disk;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Resource::Helper
|
} // namespace Resource::Helper
|
||||||
@@ -32,7 +32,17 @@ namespace Resource::Helper {
|
|||||||
// Carrega un recurs pel seu camí relatiu (p.ex. "fonts/hud.gif",
|
// Carrega un recurs pel seu camí relatiu (p.ex. "fonts/hud.gif",
|
||||||
// "input/keys.yaml"). Prova primer el pack; si no hi és i el fallback
|
// "input/keys.yaml"). Prova primer el pack; si no hi és i el fallback
|
||||||
// està actiu, cau a disc (data root + ruta). Retorna vector buit si
|
// està actiu, cau a disc (data root + ruta). Retorna vector buit si
|
||||||
// no el troba.
|
// no el troba. Si `preferDisk()` és true (Debug), inverteix la
|
||||||
|
// prioritat: prova disc abans del pack.
|
||||||
auto loadFile(const std::string& filepath) -> std::vector<std::uint8_t>;
|
auto loadFile(const std::string& filepath) -> std::vector<std::uint8_t>;
|
||||||
|
|
||||||
|
// Inverteix la prioritat de `loadFile` (disc abans que pack). En Debug
|
||||||
|
// s'activa per defecte al `initializeResourceSystem` perquè cada
|
||||||
|
// canvi al YAML/GIF al source tree es vegi sense re-packejar — és el
|
||||||
|
// que necessita l'editor in-game per veure les seues edicions
|
||||||
|
// immediatament al recarregar la sala. En Release no té efecte
|
||||||
|
// (el fallback està desactivat).
|
||||||
|
void setPreferDisk(bool prefer);
|
||||||
|
[[nodiscard]] auto preferDisk() -> bool;
|
||||||
|
|
||||||
} // namespace Resource::Helper
|
} // namespace Resource::Helper
|
||||||
@@ -12,6 +12,8 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "core/audio/audio.hpp"
|
#include "core/audio/audio.hpp"
|
||||||
|
#include "core/audio/sound_effects_config.hpp"
|
||||||
|
#include "core/input/gamepad_bindings.hpp"
|
||||||
#include "core/input/gamepad_manager.hpp"
|
#include "core/input/gamepad_manager.hpp"
|
||||||
#include "core/input/key_config.hpp"
|
#include "core/input/key_config.hpp"
|
||||||
#include "core/input/mouse.hpp"
|
#include "core/input/mouse.hpp"
|
||||||
@@ -27,6 +29,10 @@
|
|||||||
#include "core/system/event_buffer.hpp"
|
#include "core/system/event_buffer.hpp"
|
||||||
#include "core/ui/ui_config.hpp"
|
#include "core/ui/ui_config.hpp"
|
||||||
#include "game/debug_config.hpp"
|
#include "game/debug_config.hpp"
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#include "game/editor/editor_config.hpp"
|
||||||
|
#endif
|
||||||
|
#include "game/levels/level_manager.hpp"
|
||||||
#include "game/options.hpp"
|
#include "game/options.hpp"
|
||||||
#include "game/scenes/game_scene.hpp"
|
#include "game/scenes/game_scene.hpp"
|
||||||
#include "game/scenes/intro_scene.hpp"
|
#include "game/scenes/intro_scene.hpp"
|
||||||
@@ -80,6 +86,11 @@ Director::Director() {
|
|||||||
std::cerr << "Director: no s'ha pogut carregar ni desar config.yaml a " << system_folder_ << '\n';
|
std::cerr << "Director: no s'ha pogut carregar ni desar config.yaml a " << system_folder_ << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Vinculacions de mando per dispositiu — fitxer aïllat de `config.yaml`
|
||||||
|
// perquè és per (name, path) del mando, no per perfil/usuari. Replica
|
||||||
|
// el patró de coffee_crisis_arcade_edition (`gamepad_configs.json`).
|
||||||
|
GamepadBindings::get().load(system_folder_ + "gamepad_configs.yaml");
|
||||||
|
|
||||||
// Carrega els presets de PostFX des de shaders/postfx.yaml; si no existeix
|
// Carrega els presets de PostFX des de shaders/postfx.yaml; si no existeix
|
||||||
// es crea amb presets per defecte (off, crt, ntsc).
|
// es crea amb presets per defecte (off, crt, ntsc).
|
||||||
Options::setPostFXFile(system_folder_ + Defaults::Video::POSTFX_FILE);
|
Options::setPostFXFile(system_folder_ + Defaults::Video::POSTFX_FILE);
|
||||||
@@ -111,6 +122,12 @@ Director::Director() {
|
|||||||
// data/ui.yaml cau al valor compilat a Defaults::UI.
|
// data/ui.yaml cau al valor compilat a Defaults::UI.
|
||||||
UiConfig::get().load("data/ui.yaml");
|
UiConfig::get().load("data/ui.yaml");
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
// Tema visual de l'editor de tilemap (Debug-only). Claus absents
|
||||||
|
// cauen als valors compilats a Defaults::Editor.
|
||||||
|
EditorConfig::get().load("data/editor/editor.yaml");
|
||||||
|
#endif
|
||||||
|
|
||||||
// Recursos compartits d'UI (paleta + fonts). Es carreguen abans que els
|
// Recursos compartits d'UI (paleta + fonts). Es carreguen abans que els
|
||||||
// overlays perquè tots els reaprofiten sense duplicar la lògica. Els
|
// overlays perquè tots els reaprofiten sense duplicar la lògica. Els
|
||||||
// noms de font viuen al fitxer data/ui.yaml via UiConfig.
|
// noms de font viuen al fitxer data/ui.yaml via UiConfig.
|
||||||
@@ -121,10 +138,34 @@ Director::Director() {
|
|||||||
const std::string PLACEHOLDER_FONT_GIF_KEY = UiConfig::get().placeholderFont().name + ".gif";
|
const std::string PLACEHOLDER_FONT_GIF_KEY = UiConfig::get().placeholderFont().name + ".gif";
|
||||||
Resource::Cache::get().loadSurface(PLACEHOLDER_FONT_GIF_KEY, UiConfig::get().placeholderFont().gif);
|
Resource::Cache::get().loadSurface(PLACEHOLDER_FONT_GIF_KEY, UiConfig::get().placeholderFont().gif);
|
||||||
Resource::Cache::get().getSurface(PLACEHOLDER_FONT_GIF_KEY)->setPalette(Resource::Cache::get().getPalette("ui"));
|
Resource::Cache::get().getSurface(PLACEHOLDER_FONT_GIF_KEY)->setPalette(Resource::Cache::get().getPalette("ui"));
|
||||||
|
// Font del rètol de transició de sala (la consumeix `GameScene`
|
||||||
|
// tant per la línia "Piràmide N / Sala M" de l'INTRO com pel
|
||||||
|
// "Fase completada" de l'OUTRO). Es preloda ací per consistència
|
||||||
|
// amb la resta de fonts d'UI; sense això, la primera entrada a
|
||||||
|
// GAME aniria a disc.
|
||||||
|
const std::string ROOM_TEXT_FONT_GIF_KEY = UiConfig::get().roomTextFont().name + ".gif";
|
||||||
|
Resource::Cache::get().loadSurface(ROOM_TEXT_FONT_GIF_KEY, UiConfig::get().roomTextFont().gif);
|
||||||
|
Resource::Cache::get().getSurface(ROOM_TEXT_FONT_GIF_KEY)->setPalette(Resource::Cache::get().getPalette("ui"));
|
||||||
|
|
||||||
// Música de la piràmide 1 (primer i únic track de moment). Carreguem ací
|
// Pistes de música del cicle de sala (intro/playing/outro). Es preloden
|
||||||
// perquè forma part del preload d'assets, com la font i la paleta.
|
// ací perquè formen part del preload d'assets, com la font i la paleta;
|
||||||
Resource::Cache::get().loadMusic("pyramid_1.ogg", "data/music/pyramid_1.ogg");
|
// la lògica de quina sona en cada estat viu a `GameScene`.
|
||||||
|
Resource::Cache::get().loadMusic("room_intro.ogg", "data/music/room_intro.ogg");
|
||||||
|
Resource::Cache::get().loadMusic("playing.ogg", "data/music/playing.ogg");
|
||||||
|
Resource::Cache::get().loadMusic("room_outro.ogg", "data/music/room_outro.ogg");
|
||||||
|
|
||||||
|
// Sons del menú de servei. Els noms venen de `data/ui.yaml` (amb
|
||||||
|
// fallback a `Defaults::UI::MENU_*_SOUND`); el ServiceMenu els
|
||||||
|
// dispara via Audio::Group::INTERFACE.
|
||||||
|
const auto& menu_select = UiConfig::get().menuSelectSound();
|
||||||
|
const auto& menu_accept = UiConfig::get().menuAcceptSound();
|
||||||
|
Resource::Cache::get().loadSound(menu_select, "data/sounds/" + menu_select);
|
||||||
|
Resource::Cache::get().loadSound(menu_accept, "data/sounds/" + menu_accept);
|
||||||
|
|
||||||
|
// Catàleg de presets d'efectes per als sons. Es carrega abans d'Audio
|
||||||
|
// perquè els primers playSoundWith* (al començament del joc) ja
|
||||||
|
// troben els presets disponibles.
|
||||||
|
SoundEffectsConfig::get().load("data/sounds.yaml");
|
||||||
|
|
||||||
// Audio: singleton manual propietari d'un SDL audio device. Es destrueix
|
// Audio: singleton manual propietari d'un SDL audio device. Es destrueix
|
||||||
// explícitament a ~Director abans que Resource::Cache (Meyers) buide els
|
// explícitament a ~Director abans que Resource::Cache (Meyers) buide els
|
||||||
@@ -182,6 +223,13 @@ Director::Director() {
|
|||||||
DebugConfig::createDefaultIfMissing(DEBUG_YAML);
|
DebugConfig::createDefaultIfMissing(DEBUG_YAML);
|
||||||
const auto START = DebugConfig::resolveStartScene(DEBUG_YAML);
|
const auto START = DebugConfig::resolveStartScene(DEBUG_YAML);
|
||||||
const auto STARTING_PLAYERS = DebugConfig::resolveStartingPlayers(DEBUG_YAML);
|
const auto STARTING_PLAYERS = DebugConfig::resolveStartingPlayers(DEBUG_YAML);
|
||||||
|
// `starting_level` (opcional) sobreescriu l'índex inicial del
|
||||||
|
// LevelManager abans de crear cap GameScene. Si la clau no està o el
|
||||||
|
// (pyramid, room) no apareix al levels.yaml, el LevelManager
|
||||||
|
// continua a la primera entrada (P1-R1).
|
||||||
|
if (const auto SL = DebugConfig::resolveStartingLevel(DEBUG_YAML); SL.has_value()) {
|
||||||
|
Levels::LevelManager::get().setStartingPoint(SL->pyramid, SL->room);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
const auto START = DebugConfig::StartScene::LOGO;
|
const auto START = DebugConfig::StartScene::LOGO;
|
||||||
const auto STARTING_PLAYERS = DebugConfig::StartingPlayers::BOTH;
|
const auto STARTING_PLAYERS = DebugConfig::StartingPlayers::BOTH;
|
||||||
@@ -189,6 +237,12 @@ Director::Director() {
|
|||||||
std::cout << "Director: start_scene=" << DebugConfig::toString(START)
|
std::cout << "Director: start_scene=" << DebugConfig::toString(START)
|
||||||
<< " starting_players=" << DebugConfig::toString(STARTING_PLAYERS) << '\n';
|
<< " starting_players=" << DebugConfig::toString(STARTING_PLAYERS) << '\n';
|
||||||
|
|
||||||
|
// El branch Release inicialitza STARTING_PLAYERS amb una constant
|
||||||
|
// literal i clang considera la captura redundant; en Debug el valor és
|
||||||
|
// runtime i la captura sí és imprescindible. La lambda viu dins de
|
||||||
|
// IntroScene, més enllà del scope d'aquest ctor — capturar per
|
||||||
|
// referència seria UB.
|
||||||
|
// NOLINTNEXTLINE(clang-diagnostic-unused-lambda-capture)
|
||||||
auto make_game = [STARTING_PLAYERS]() -> std::unique_ptr<Scene> {
|
auto make_game = [STARTING_PLAYERS]() -> std::unique_ptr<Scene> {
|
||||||
auto cfg = GameScene::defaultConfig();
|
auto cfg = GameScene::defaultConfig();
|
||||||
cfg.starting_players = STARTING_PLAYERS;
|
cfg.starting_players = STARTING_PLAYERS;
|
||||||
@@ -265,12 +319,29 @@ void Director::processEvents() {
|
|||||||
if (QUIT_REQUESTED) { current_scene_.reset(); }
|
if (QUIT_REQUESTED) { current_scene_.reset(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
// Resol el botó SERVICE configurat per al mando origen d'aquest event.
|
||||||
|
// Retorna -1 si no en troba cap. La cerca passa per `GamepadManager`
|
||||||
|
// per obtenir el (name, path) i d'ahí a `GamepadBindings`.
|
||||||
|
auto serviceButtonForGamepadEvent(SDL_JoystickID jid) -> int {
|
||||||
|
for (const auto& info : GamepadManager::get().getAll()) {
|
||||||
|
if (info.pad == nullptr) { continue; }
|
||||||
|
if (SDL_GetJoystickID(SDL_GetGamepadJoystick(info.pad)) != jid) { continue; }
|
||||||
|
return GamepadBindings::get().getButton(info.name, info.path, GamepadBindings::Action::SERVICE);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void Director::processGamepadEvents() {
|
void Director::processGamepadEvents() {
|
||||||
// Dues responsabilitats: (1) passar ADDED/REMOVED al GamepadManager
|
// Dues responsabilitats: (1) passar ADDED/REMOVED al GamepadManager
|
||||||
// perquè obri/tanqui mandos i emeti les notificacions hot-plug; (2)
|
// perquè obri/tanqui mandos i emeti les notificacions hot-plug; (2)
|
||||||
// tractar el botó BACK com a toggle del menú quan està tancat (el
|
// tractar el botó SERVICE (per defecte BACK; remapejable per
|
||||||
// paral·lel de F9 per al teclat). Quan el menú està obert, el BACK
|
// `GamepadBindings`) com a toggle del menú quan està tancat (el
|
||||||
// passa pel pipeline del `ServiceMenu::handleEvent()` via
|
// paral·lel de F9 per al teclat). Quan el menú està obert, el botó
|
||||||
|
// SERVICE passa pel pipeline del `ServiceMenu::handleEvent()` via
|
||||||
// `processMenuInput()` i allà es converteix en `close()`.
|
// `processMenuInput()` i allà es converteix en `close()`.
|
||||||
for (auto it = EventBuffer::events.begin(); it != EventBuffer::events.end();) {
|
for (auto it = EventBuffer::events.begin(); it != EventBuffer::events.end();) {
|
||||||
bool consumed = false;
|
bool consumed = false;
|
||||||
@@ -278,11 +349,13 @@ void Director::processGamepadEvents() {
|
|||||||
GamepadManager::get().handleEvent(*it);
|
GamepadManager::get().handleEvent(*it);
|
||||||
consumed = true;
|
consumed = true;
|
||||||
} else if (it->type == SDL_EVENT_GAMEPAD_BUTTON_DOWN &&
|
} else if (it->type == SDL_EVENT_GAMEPAD_BUTTON_DOWN &&
|
||||||
it->gbutton.button == SDL_GAMEPAD_BUTTON_BACK &&
|
|
||||||
!ServiceMenu::get().isOpen()) {
|
!ServiceMenu::get().isOpen()) {
|
||||||
|
const int SERVICE_BTN = serviceButtonForGamepadEvent(it->gbutton.which);
|
||||||
|
if (SERVICE_BTN >= 0 && static_cast<int>(it->gbutton.button) == SERVICE_BTN) {
|
||||||
ServiceMenu::get().toggle();
|
ServiceMenu::get().toggle();
|
||||||
consumed = true;
|
consumed = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (consumed) {
|
if (consumed) {
|
||||||
it = EventBuffer::events.erase(it);
|
it = EventBuffer::events.erase(it);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ UiConfig::UiConfig()
|
|||||||
hud_label_(Defaults::UI::HUD_LABEL),
|
hud_label_(Defaults::UI::HUD_LABEL),
|
||||||
hud_value_(Defaults::UI::HUD_VALUE),
|
hud_value_(Defaults::UI::HUD_VALUE),
|
||||||
hud_flash_(Defaults::UI::HUD_FLASH),
|
hud_flash_(Defaults::UI::HUD_FLASH),
|
||||||
|
room_text_(Defaults::UI::ROOM_TEXT),
|
||||||
|
room_text_outline_(Defaults::UI::ROOM_TEXT_OUTLINE),
|
||||||
notification_ms_(Defaults::UI::NOTIFICATION_TIME_MS),
|
notification_ms_(Defaults::UI::NOTIFICATION_TIME_MS),
|
||||||
exit_ms_(Defaults::UI::EXIT_TIME_MS),
|
exit_ms_(Defaults::UI::EXIT_TIME_MS),
|
||||||
hud_entry_ms_(Defaults::UI::HUD_ENTRY_MS),
|
hud_entry_ms_(Defaults::UI::HUD_ENTRY_MS),
|
||||||
@@ -94,10 +96,24 @@ UiConfig::UiConfig()
|
|||||||
pause_exit_ms_(Defaults::UI::PAUSE_EXIT_MS),
|
pause_exit_ms_(Defaults::UI::PAUSE_EXIT_MS),
|
||||||
pause_enter_curve_(curveByName(Defaults::UI::PAUSE_ENTER_CURVE)),
|
pause_enter_curve_(curveByName(Defaults::UI::PAUSE_ENTER_CURVE)),
|
||||||
pause_exit_curve_(curveByName(Defaults::UI::PAUSE_EXIT_CURVE)),
|
pause_exit_curve_(curveByName(Defaults::UI::PAUSE_EXIT_CURVE)),
|
||||||
|
menu_select_sound_(Defaults::UI::MENU_SELECT_SOUND),
|
||||||
|
menu_accept_sound_(Defaults::UI::MENU_ACCEPT_SOUND),
|
||||||
hud_font_{.name = Defaults::UI::Font::HUD_NAME, .gif = Defaults::UI::Font::HUD_GIF, .fnt = Defaults::UI::Font::HUD_FNT, .kerning = Defaults::UI::Font::HUD_KERNING},
|
hud_font_{.name = Defaults::UI::Font::HUD_NAME, .gif = Defaults::UI::Font::HUD_GIF, .fnt = Defaults::UI::Font::HUD_FNT, .kerning = Defaults::UI::Font::HUD_KERNING},
|
||||||
placeholder_font_{.name = Defaults::UI::Font::PLACEHOLDER_NAME, .gif = Defaults::UI::Font::PLACEHOLDER_GIF, .fnt = Defaults::UI::Font::PLACEHOLDER_FNT, .kerning = Defaults::UI::Font::PLACEHOLDER_KERNING},
|
placeholder_font_{.name = Defaults::UI::Font::PLACEHOLDER_NAME, .gif = Defaults::UI::Font::PLACEHOLDER_GIF, .fnt = Defaults::UI::Font::PLACEHOLDER_FNT, .kerning = Defaults::UI::Font::PLACEHOLDER_KERNING},
|
||||||
|
room_text_font_{.name = Defaults::UI::Font::ROOM_TEXT_NAME, .gif = Defaults::UI::Font::ROOM_TEXT_GIF, .fnt = Defaults::UI::Font::ROOM_TEXT_FNT, .kerning = Defaults::UI::Font::ROOM_TEXT_KERNING},
|
||||||
menu_title_font_{.name = Defaults::UI::Font::MENU_TITLE_NAME, .gif = Defaults::UI::Font::MENU_TITLE_GIF, .fnt = Defaults::UI::Font::MENU_TITLE_FNT, .kerning = Defaults::UI::Font::MENU_TITLE_KERNING},
|
menu_title_font_{.name = Defaults::UI::Font::MENU_TITLE_NAME, .gif = Defaults::UI::Font::MENU_TITLE_GIF, .fnt = Defaults::UI::Font::MENU_TITLE_FNT, .kerning = Defaults::UI::Font::MENU_TITLE_KERNING},
|
||||||
menu_items_font_{.name = Defaults::UI::Font::MENU_ITEMS_NAME, .gif = Defaults::UI::Font::MENU_ITEMS_GIF, .fnt = Defaults::UI::Font::MENU_ITEMS_FNT, .kerning = Defaults::UI::Font::MENU_ITEMS_KERNING} {
|
menu_items_font_{.name = Defaults::UI::Font::MENU_ITEMS_NAME, .gif = Defaults::UI::Font::MENU_ITEMS_GIF, .fnt = Defaults::UI::Font::MENU_ITEMS_FNT, .kerning = Defaults::UI::Font::MENU_ITEMS_KERNING},
|
||||||
|
notifier_{
|
||||||
|
.padding_h = Defaults::UI::Notifier::PADDING_H,
|
||||||
|
.padding_top = Defaults::UI::Notifier::PADDING_TOP,
|
||||||
|
.padding_bottom = Defaults::UI::Notifier::PADDING_BOTTOM,
|
||||||
|
.line_gap = Defaults::UI::Notifier::LINE_GAP,
|
||||||
|
.margin_top = Defaults::UI::Notifier::MARGIN_TOP,
|
||||||
|
.border_px = Defaults::UI::Notifier::BORDER_PX,
|
||||||
|
.slide_ms = Defaults::UI::Notifier::SLIDE_MS,
|
||||||
|
.slide_in_curve = curveByName(Defaults::UI::Notifier::SLIDE_IN_CURVE),
|
||||||
|
.slide_out_curve = curveByName(Defaults::UI::Notifier::SLIDE_OUT_CURVE),
|
||||||
|
} {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto UiConfig::get() -> UiConfig& {
|
auto UiConfig::get() -> UiConfig& {
|
||||||
@@ -147,6 +163,8 @@ void UiConfig::load(const std::string& file_path) {
|
|||||||
readColorIndex(c, "hud_label", hud_label_);
|
readColorIndex(c, "hud_label", hud_label_);
|
||||||
readColorIndex(c, "hud_value", hud_value_);
|
readColorIndex(c, "hud_value", hud_value_);
|
||||||
readColorIndex(c, "hud_flash", hud_flash_);
|
readColorIndex(c, "hud_flash", hud_flash_);
|
||||||
|
readColorIndex(c, "room_text", room_text_);
|
||||||
|
readColorIndex(c, "room_text_outline", room_text_outline_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yaml.contains("timings")) {
|
if (yaml.contains("timings")) {
|
||||||
@@ -159,6 +177,7 @@ void UiConfig::load(const std::string& file_path) {
|
|||||||
const auto& f = yaml["fonts"];
|
const auto& f = yaml["fonts"];
|
||||||
readFont(f, "hud", hud_font_);
|
readFont(f, "hud", hud_font_);
|
||||||
readFont(f, "placeholder", placeholder_font_);
|
readFont(f, "placeholder", placeholder_font_);
|
||||||
|
readFont(f, "room_text", room_text_font_);
|
||||||
readFont(f, "menu_title", menu_title_font_);
|
readFont(f, "menu_title", menu_title_font_);
|
||||||
readFont(f, "menu_items", menu_items_font_);
|
readFont(f, "menu_items", menu_items_font_);
|
||||||
}
|
}
|
||||||
@@ -179,6 +198,25 @@ void UiConfig::load(const std::string& file_path) {
|
|||||||
readCurve(p, "exit_curve", pause_exit_curve_);
|
readCurve(p, "exit_curve", pause_exit_curve_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (yaml.contains("sounds")) {
|
||||||
|
const auto& s = yaml["sounds"];
|
||||||
|
readField(s, "menu_select", menu_select_sound_);
|
||||||
|
readField(s, "menu_accept", menu_accept_sound_);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (yaml.contains("notifier")) {
|
||||||
|
const auto& n = yaml["notifier"];
|
||||||
|
readField(n, "padding_h", notifier_.padding_h);
|
||||||
|
readField(n, "padding_top", notifier_.padding_top);
|
||||||
|
readField(n, "padding_bottom", notifier_.padding_bottom);
|
||||||
|
readField(n, "line_gap", notifier_.line_gap);
|
||||||
|
readField(n, "margin_top", notifier_.margin_top);
|
||||||
|
readField(n, "border_px", notifier_.border_px);
|
||||||
|
readField(n, "slide_ms", notifier_.slide_ms);
|
||||||
|
readCurve(n, "slide_in_curve", notifier_.slide_in_curve);
|
||||||
|
readCurve(n, "slide_out_curve", notifier_.slide_out_curve);
|
||||||
|
}
|
||||||
|
|
||||||
std::cout << "UiConfig: carregat des de " << file_path << '\n';
|
std::cout << "UiConfig: carregat des de " << file_path << '\n';
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cerr << "UiConfig: error parsejant " << file_path << ": " << e.what() << '\n';
|
std::cerr << "UiConfig: error parsejant " << file_path << ": " << e.what() << '\n';
|
||||||
|
|||||||
@@ -20,6 +20,27 @@ class UiConfig {
|
|||||||
int kerning;
|
int kerning;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Signatura d'una funció d'easing: t ∈ [0, 1] → valor ∈ [0, 1].
|
||||||
|
// Permet triar corbes des de data/ui.yaml per nom (cadena) i guardar
|
||||||
|
// el punter a la corresponent funció de `utils/easing.hpp`.
|
||||||
|
using CurveFn = auto (*)(float) -> float;
|
||||||
|
|
||||||
|
// Geometria del Notifier (popup superior). Carregada des de
|
||||||
|
// data/ui.yaml secció `notifier:`; els valors per defecte vénen de
|
||||||
|
// Defaults::UI::Notifier. El moviment és per temps (slide_ms) i no per
|
||||||
|
// velocitat, perquè una caixa més gran no triga més a entrar/eixir.
|
||||||
|
struct Notifier {
|
||||||
|
int padding_h;
|
||||||
|
int padding_top;
|
||||||
|
int padding_bottom;
|
||||||
|
int line_gap;
|
||||||
|
int margin_top;
|
||||||
|
int border_px;
|
||||||
|
int slide_ms;
|
||||||
|
CurveFn slide_in_curve;
|
||||||
|
CurveFn slide_out_curve;
|
||||||
|
};
|
||||||
|
|
||||||
static auto get() -> UiConfig&;
|
static auto get() -> UiConfig&;
|
||||||
|
|
||||||
UiConfig(const UiConfig&) = delete;
|
UiConfig(const UiConfig&) = delete;
|
||||||
@@ -48,11 +69,8 @@ class UiConfig {
|
|||||||
[[nodiscard]] auto hudLabel() const -> Uint8 { return hud_label_; }
|
[[nodiscard]] auto hudLabel() const -> Uint8 { return hud_label_; }
|
||||||
[[nodiscard]] auto hudValue() const -> Uint8 { return hud_value_; }
|
[[nodiscard]] auto hudValue() const -> Uint8 { return hud_value_; }
|
||||||
[[nodiscard]] auto hudFlash() const -> Uint8 { return hud_flash_; }
|
[[nodiscard]] auto hudFlash() const -> Uint8 { return hud_flash_; }
|
||||||
|
[[nodiscard]] auto roomText() const -> Uint8 { return room_text_; }
|
||||||
// Signatura d'una funció d'easing: t ∈ [0, 1] → valor ∈ [0, 1].
|
[[nodiscard]] auto roomTextOutline() const -> Uint8 { return room_text_outline_; }
|
||||||
// Permet triar corbes des de data/ui.yaml per nom (cadena) i guardar
|
|
||||||
// el punter a la corresponent funció de `utils/easing.hpp`.
|
|
||||||
using CurveFn = auto (*)(float) -> float;
|
|
||||||
|
|
||||||
// Timings (ms).
|
// Timings (ms).
|
||||||
[[nodiscard]] auto notificationMs() const -> int { return notification_ms_; }
|
[[nodiscard]] auto notificationMs() const -> int { return notification_ms_; }
|
||||||
@@ -74,12 +92,21 @@ class UiConfig {
|
|||||||
// retorna Easing::linear i deixa un warning al log.
|
// retorna Easing::linear i deixa un warning al log.
|
||||||
[[nodiscard]] static auto curveByName(const std::string& name) -> CurveFn;
|
[[nodiscard]] static auto curveByName(const std::string& name) -> CurveFn;
|
||||||
|
|
||||||
|
// Sons del menú de servei. Claus de Resource::Cache::loadSound (els
|
||||||
|
// fitxers viuen a `data/sounds/`).
|
||||||
|
[[nodiscard]] auto menuSelectSound() const -> const std::string& { return menu_select_sound_; }
|
||||||
|
[[nodiscard]] auto menuAcceptSound() const -> const std::string& { return menu_accept_sound_; }
|
||||||
|
|
||||||
// Fonts de UI.
|
// Fonts de UI.
|
||||||
[[nodiscard]] auto hudFont() const -> const Font& { return hud_font_; }
|
[[nodiscard]] auto hudFont() const -> const Font& { return hud_font_; }
|
||||||
[[nodiscard]] auto placeholderFont() const -> const Font& { return placeholder_font_; }
|
[[nodiscard]] auto placeholderFont() const -> const Font& { return placeholder_font_; }
|
||||||
|
[[nodiscard]] auto roomTextFont() const -> const Font& { return room_text_font_; }
|
||||||
[[nodiscard]] auto menuTitleFont() const -> const Font& { return menu_title_font_; }
|
[[nodiscard]] auto menuTitleFont() const -> const Font& { return menu_title_font_; }
|
||||||
[[nodiscard]] auto menuItemsFont() const -> const Font& { return menu_items_font_; }
|
[[nodiscard]] auto menuItemsFont() const -> const Font& { return menu_items_font_; }
|
||||||
|
|
||||||
|
// Geometria del Notifier.
|
||||||
|
[[nodiscard]] auto notifier() const -> const Notifier& { return notifier_; }
|
||||||
|
|
||||||
// Flags visuals.
|
// Flags visuals.
|
||||||
[[nodiscard]] auto hudBgEnabled() const -> bool { return hud_bg_enabled_; }
|
[[nodiscard]] auto hudBgEnabled() const -> bool { return hud_bg_enabled_; }
|
||||||
|
|
||||||
@@ -105,6 +132,8 @@ class UiConfig {
|
|||||||
Uint8 hud_label_;
|
Uint8 hud_label_;
|
||||||
Uint8 hud_value_;
|
Uint8 hud_value_;
|
||||||
Uint8 hud_flash_;
|
Uint8 hud_flash_;
|
||||||
|
Uint8 room_text_;
|
||||||
|
Uint8 room_text_outline_;
|
||||||
|
|
||||||
int notification_ms_;
|
int notification_ms_;
|
||||||
int exit_ms_;
|
int exit_ms_;
|
||||||
@@ -116,10 +145,16 @@ class UiConfig {
|
|||||||
CurveFn pause_enter_curve_;
|
CurveFn pause_enter_curve_;
|
||||||
CurveFn pause_exit_curve_;
|
CurveFn pause_exit_curve_;
|
||||||
|
|
||||||
|
std::string menu_select_sound_;
|
||||||
|
std::string menu_accept_sound_;
|
||||||
|
|
||||||
Font hud_font_;
|
Font hud_font_;
|
||||||
Font placeholder_font_;
|
Font placeholder_font_;
|
||||||
|
Font room_text_font_;
|
||||||
Font menu_title_font_;
|
Font menu_title_font_;
|
||||||
Font menu_items_font_;
|
Font menu_items_font_;
|
||||||
|
|
||||||
|
Notifier notifier_;
|
||||||
|
|
||||||
bool hud_bg_enabled_{false};
|
bool hud_bg_enabled_{false};
|
||||||
};
|
};
|
||||||
@@ -103,6 +103,34 @@ namespace DebugConfig {
|
|||||||
return parseStartingPlayers(CONTENT);
|
return parseStartingPlayers(CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto parseStartingLevel(const std::string& yaml_content) -> std::optional<StartingLevel> {
|
||||||
|
if (yaml_content.empty()) { return std::nullopt; }
|
||||||
|
try {
|
||||||
|
auto yaml = fkyaml::node::deserialize(yaml_content);
|
||||||
|
if (!yaml.contains("starting_level")) { return std::nullopt; }
|
||||||
|
const auto& sl = yaml["starting_level"];
|
||||||
|
if (!sl.contains("pyramid") || !sl.contains("room")) {
|
||||||
|
std::cerr << "debug.yaml: starting_level necessita els camps `pyramid` i `room` — ignorat\n";
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
return StartingLevel{
|
||||||
|
.pyramid = sl["pyramid"].get_value<int>(),
|
||||||
|
.room = sl["room"].get_value<int>(),
|
||||||
|
};
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
std::cerr << "debug.yaml: error parsejant starting_level: " << e.what() << " — ignorat\n";
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto resolveStartingLevel(const std::string& file_path) -> std::optional<StartingLevel> {
|
||||||
|
std::error_code error;
|
||||||
|
if (!std::filesystem::exists(file_path, error)) { return std::nullopt; }
|
||||||
|
const auto CONTENT = readFile(file_path);
|
||||||
|
if (CONTENT.empty()) { return std::nullopt; }
|
||||||
|
return parseStartingLevel(CONTENT);
|
||||||
|
}
|
||||||
|
|
||||||
auto toString(StartScene scene) -> const char* {
|
auto toString(StartScene scene) -> const char* {
|
||||||
switch (scene) {
|
switch (scene) {
|
||||||
case StartScene::LOGO:
|
case StartScene::LOGO:
|
||||||
@@ -140,6 +168,9 @@ namespace DebugConfig {
|
|||||||
file << "# debug.yaml — ajust personal de dev (no versionat).\n";
|
file << "# debug.yaml — ajust personal de dev (no versionat).\n";
|
||||||
file << "# start_scene: LOGO | TITLE | INTRO | GAME\n";
|
file << "# start_scene: LOGO | TITLE | INTRO | GAME\n";
|
||||||
file << "# starting_players: P1 | P2 | BOTH\n";
|
file << "# starting_players: P1 | P2 | BOTH\n";
|
||||||
|
file << "# starting_level (opcional): { pyramid: N, room: M } — salta a la sala\n";
|
||||||
|
file << "# corresponent del levels.yaml. Sense la\n";
|
||||||
|
file << "# clau, comença a la primera (P1-R1).\n";
|
||||||
file << "start_scene: GAME\n";
|
file << "start_scene: GAME\n";
|
||||||
file << "starting_players: BOTH\n";
|
file << "starting_players: BOTH\n";
|
||||||
std::cout << "debug.yaml: creat a " << file_path << " amb start_scene=GAME starting_players=BOTH\n";
|
std::cout << "debug.yaml: creat a " << file_path << " amb start_scene=GAME starting_players=BOTH\n";
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
// Configuració personal de desenvolupament, carregada de `debug.yaml` dins la
|
// Configuració personal de desenvolupament, carregada de `debug.yaml` dins la
|
||||||
@@ -37,6 +38,18 @@ namespace DebugConfig {
|
|||||||
[[nodiscard]] auto parseStartingPlayers(const std::string& yaml_content) -> StartingPlayers;
|
[[nodiscard]] auto parseStartingPlayers(const std::string& yaml_content) -> StartingPlayers;
|
||||||
[[nodiscard]] auto resolveStartingPlayers(const std::string& file_path) -> StartingPlayers;
|
[[nodiscard]] auto resolveStartingPlayers(const std::string& file_path) -> StartingPlayers;
|
||||||
|
|
||||||
|
// Punt d'arrencada dins de la progressió de sales (consumit pel
|
||||||
|
// `Levels::LevelManager`). YAML:
|
||||||
|
// starting_level: { pyramid: 2, room: 3 }
|
||||||
|
// L'absència de la clau és el cas habitual i deixa la progressió a
|
||||||
|
// la primera entrada del `levels.yaml`.
|
||||||
|
struct StartingLevel {
|
||||||
|
int pyramid{0};
|
||||||
|
int room{0};
|
||||||
|
};
|
||||||
|
[[nodiscard]] auto parseStartingLevel(const std::string& yaml_content) -> std::optional<StartingLevel>;
|
||||||
|
[[nodiscard]] auto resolveStartingLevel(const std::string& file_path) -> std::optional<StartingLevel>;
|
||||||
|
|
||||||
// Nom canònic de l'enum (útil per a logs): "LOGO" / "TITLE" / "INTRO" / "GAME".
|
// Nom canònic de l'enum (útil per a logs): "LOGO" / "TITLE" / "INTRO" / "GAME".
|
||||||
[[nodiscard]] auto toString(StartScene scene) -> const char*;
|
[[nodiscard]] auto toString(StartScene scene) -> const char*;
|
||||||
[[nodiscard]] auto toString(StartingPlayers players) -> const char*;
|
[[nodiscard]] auto toString(StartingPlayers players) -> const char*;
|
||||||
|
|||||||
@@ -2,6 +2,15 @@
|
|||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class Entity;
|
||||||
|
class EntityManager;
|
||||||
|
class Surface;
|
||||||
|
class Text;
|
||||||
class Tilemap;
|
class Tilemap;
|
||||||
|
|
||||||
// Mode editor modal del GameScene. Només disponible en Debug — en Release
|
// Mode editor modal del GameScene. Només disponible en Debug — en Release
|
||||||
@@ -11,55 +20,176 @@ class Tilemap;
|
|||||||
// L'editor NO gestiona la tecla de toggle pròpia (`editor_toggle`): això
|
// L'editor NO gestiona la tecla de toggle pròpia (`editor_toggle`): això
|
||||||
// ho fa GameScene per poder decidir la coexistència amb la pausa F11
|
// ho fa GameScene per poder decidir la coexistència amb la pausa F11
|
||||||
// (mútuament excloents). L'editor s'encarrega de:
|
// (mútuament excloents). L'editor s'encarrega de:
|
||||||
// - Estat propi (actiu/no actiu, brush, picker obert).
|
// - Estat propi (mode actiu, brush per mode, picker obert).
|
||||||
// - Input del ratolí i tecles internes (`T`, `ESC`).
|
// - Input del ratolí i tecles internes (`T`, `E`, `H`, `Supr`, `ESC`).
|
||||||
// - Render del border blau + brush preview + picker.
|
// - Render del border blau + brush preview + picker.
|
||||||
// - Persistència del tilemap al YAML del repo en sortir.
|
// - Persistència del tilemap i de les entitats al YAML del repo en sortir.
|
||||||
//
|
//
|
||||||
// GameScene, quan `active()` és true, salta el tick de jugadors/entitats
|
// Modes del cursor (`Mode`):
|
||||||
// i no els pinta; el tilemap sí es pinta perquè és el que s'està editant.
|
// - TILE : el clic esquerre pinta el `brush_tile_` al tilemap.
|
||||||
|
// - ENTITY : el clic esquerre col·loca una instància de `brush_entity_`.
|
||||||
|
// - HAND : selecciona/mou/borra entitats existents.
|
||||||
|
//
|
||||||
|
// Pickers (`Picker`):
|
||||||
|
// - TILE_PICKER (`T`) : selecciona índex de tile.
|
||||||
|
// - ENTITY_PICKER (`E`) : selecciona tipus d'entitat (nom registrat al
|
||||||
|
// factory).
|
||||||
|
// Mútuament excloents: obrir un tanca l'altre.
|
||||||
class Editor {
|
class Editor {
|
||||||
public:
|
public:
|
||||||
// Entra al mode editor: notifica i marca `active=true`. La congelació
|
// Entra al mode editor: notifica i marca `active=true`. La congelació
|
||||||
// d'entitats / jugador la gestiona GameScene consultant `active()`.
|
// d'entitats / jugador la gestiona GameScene consultant `active()`.
|
||||||
void enter();
|
void enter();
|
||||||
|
|
||||||
// Surt del mode editor: persisteix el tilemap al YAML (writer surgical)
|
// Surt del mode editor: persisteix el tilemap i les entitats al YAML
|
||||||
// i notifica. Si la persistència falla, emet la notificació d'error.
|
// (writers surgicals) i notifica. Si la persistència falla, emet la
|
||||||
void exit(Tilemap& tilemap);
|
// notificació d'error.
|
||||||
|
void exit(Tilemap& tilemap, const EntityManager& entities);
|
||||||
|
|
||||||
// Helper: enter() si no actiu, exit() si actiu. Útil des de GameScene
|
// Helper: enter() si no actiu, exit() si actiu. Útil des de GameScene
|
||||||
// quan detecta la tecla de toggle.
|
// quan detecta la tecla de toggle.
|
||||||
void toggle(Tilemap& tilemap);
|
void toggle(Tilemap& tilemap, const EntityManager& entities);
|
||||||
|
|
||||||
[[nodiscard]] auto active() const -> bool { return active_; }
|
[[nodiscard]] auto active() const -> bool { return active_; }
|
||||||
|
|
||||||
// Processa input propi (brush, picker). No-op si no actiu.
|
// Cert quan, en mode editor, GameScene ha de pintar les entitats
|
||||||
void update(int delta_ms, Tilemap& tilemap);
|
// de la sala. Falses en mode TILE (volem veure el tilemap pelat
|
||||||
|
// per pintar-lo) i quan hi ha un picker obert (la caixa del picker
|
||||||
|
// ja tapa la pantalla i el soroll visual addicional sobra).
|
||||||
|
[[nodiscard]] auto shouldShowEntities() const -> bool {
|
||||||
|
return active_ && mode_ != Mode::TILE && picker_ == Picker::NONE;
|
||||||
|
}
|
||||||
|
|
||||||
// Pinta el border blau i, més endavant, brush preview + picker.
|
// Processa input propi (brush, picker). No-op si no actiu.
|
||||||
// No-op si no actiu.
|
// `entities` cal perquè els modes ENTITY i HAND modifiquen el manager
|
||||||
void render(const Tilemap& tilemap) const;
|
// en directe (col·loca/mou/borra entitats); en TILE no s'usa.
|
||||||
|
void update(int delta_ms, Tilemap& tilemap, EntityManager& entities);
|
||||||
|
|
||||||
|
// Pinta el border blau i, segons mode i picker, brush preview, marc
|
||||||
|
// d'entitat seleccionada o el picker. No-op si no actiu.
|
||||||
|
// `entities` és necessari per al marc d'entitat hovered/seleccionada
|
||||||
|
// en Mode::HAND; en altres modes no s'usa.
|
||||||
|
void render(const Tilemap& tilemap, const EntityManager& entities) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Les branques d'update / render segons el mode (picker obert o
|
// Mode del cursor: determina què fa el clic esquerre sobre el mapa.
|
||||||
// pintura al mapa) queden separades per claredat; no formen part
|
enum class Mode : std::uint8_t { TILE,
|
||||||
// de l'API pública perquè només té sentit cridar-les des d'`update`.
|
ENTITY,
|
||||||
void updateMap(Tilemap& tilemap, int canvas_x, int canvas_y);
|
HAND };
|
||||||
void updatePicker(const Tilemap& tilemap, int canvas_x, int canvas_y);
|
|
||||||
void renderPicker(const Tilemap& tilemap) const;
|
// Quin picker està obert (si n'hi ha). Mútuament excloents.
|
||||||
|
enum class Picker : std::uint8_t { NONE,
|
||||||
|
TILE,
|
||||||
|
ENTITY };
|
||||||
|
|
||||||
|
// Consum de hotkeys pròpies (T, E, H, ESC). Modifica `mode_` / `picker_`.
|
||||||
|
// Es crida al principi d'`update` perquè altres handlers no vegin
|
||||||
|
// tecles ja interpretades pel propi editor.
|
||||||
|
void handleHotkeys();
|
||||||
|
|
||||||
|
// Aplica una tecla i retorna true si l'editor l'ha consumit. Aïllat
|
||||||
|
// per mantenir baixa la complexitat cognitiva de `handleHotkeys` —
|
||||||
|
// l'iteració del buffer queda neta i la lògica de transició viu en
|
||||||
|
// un sol lloc.
|
||||||
|
auto applyHotkey(int scancode) -> bool;
|
||||||
|
|
||||||
|
// Branques d'update segons (mode, picker). Només té sentit cridar-les
|
||||||
|
// des d'`update`.
|
||||||
|
void updateTileBrush(Tilemap& tilemap, int canvas_x, int canvas_y);
|
||||||
|
void updateEntityBrush(EntityManager& entities, int canvas_x, int canvas_y);
|
||||||
|
void updateHand(const Tilemap& tilemap, EntityManager& entities, int canvas_x, int canvas_y);
|
||||||
|
void updateTilePicker(const Tilemap& tilemap, int canvas_x, int canvas_y);
|
||||||
|
void updateEntityPicker(int canvas_x, int canvas_y);
|
||||||
|
|
||||||
|
// Intent de col·locació segons brush_entity_ a la cel·la del cursor.
|
||||||
|
// Construeix un node spawn sintètic, fa el snap concret per tipus
|
||||||
|
// (sarc → rejilla 4×5; door → fila del mur i, de moment, columna
|
||||||
|
// canònica) i comprova solapaments. No-op si la cel·la està ocupada
|
||||||
|
// o el snap no és vàlid. Retorna true si s'ha col·locat.
|
||||||
|
auto tryPlaceEntity(EntityManager& entities) -> bool;
|
||||||
|
|
||||||
|
// Mou l'entitat seleccionada a la cel·la del cursor: borra l'antiga
|
||||||
|
// i crida `addSpawn` amb la nova posició. Reusa la mateixa lògica
|
||||||
|
// de snap/solapament que la col·locació nova, excloent l'entitat
|
||||||
|
// que es mou del check de solapament. Cas especial per a la porta:
|
||||||
|
// el sprite ocupa 3 cols (col-1, col, col+1) sobre el mur superior;
|
||||||
|
// per tant la columna central vàlida és [1, cols-2] — `tilemap` és
|
||||||
|
// necessari per saber `cols`.
|
||||||
|
auto tryMoveSelected(const Tilemap& tilemap, EntityManager& entities) const -> bool;
|
||||||
|
|
||||||
|
// Sub-handlers de `updateHand`. Aïllats per mantenir baixa la
|
||||||
|
// complexitat cognitiva del bucle d'esdeveniments.
|
||||||
|
void handleHandLeftClick(const Tilemap& tilemap, EntityManager& entities);
|
||||||
|
void handleHandRightClick();
|
||||||
|
|
||||||
|
// Borra l'entitat seleccionada. La validació de constraints
|
||||||
|
// (1 puerta, ≥1 sarc) es fa al pas 8.
|
||||||
|
void deleteSelected(EntityManager& entities);
|
||||||
|
|
||||||
|
// Render del marc d'una entitat: 1 px sobre el seu pixel_rect.
|
||||||
|
static void renderEntityFrame(const Entity& e, std::uint32_t argb);
|
||||||
|
|
||||||
|
// HUD d'edició: franja superior amb mode, brush, cursor i comptadors
|
||||||
|
// de constraints. Substitueix el HUD del joc mentre l'editor és actiu.
|
||||||
|
void renderEditorHud(const EntityManager& entities) const;
|
||||||
|
|
||||||
|
// Carrega la font 8bithud del cache. Lazy: al primer enter().
|
||||||
|
void ensureHudFont();
|
||||||
|
|
||||||
|
void renderTilePicker(const Tilemap& tilemap) const;
|
||||||
|
void renderEntityPicker(const Tilemap& tilemap) const;
|
||||||
|
|
||||||
bool active_{false};
|
bool active_{false};
|
||||||
|
Mode mode_{Mode::TILE};
|
||||||
|
Picker picker_{Picker::NONE};
|
||||||
|
|
||||||
// Estat de l'edició (brush + cursor + picker). Es poblen al pas
|
// Cursor en cel·les del tilemap. -1/-1 = fora del mapa.
|
||||||
// següent; els declarem ara perquè `update()` pugui mutar-los i les
|
int cursor_col_{-1};
|
||||||
// signatures queden estables entre hitos.
|
|
||||||
int brush_{-1}; // Índex de tile al tileset; -1 = sense brush.
|
|
||||||
int cursor_col_{-1}; // Cel·la del mapa sota el cursor (-1 = fora).
|
|
||||||
int cursor_row_{-1};
|
int cursor_row_{-1};
|
||||||
bool picker_open_{false};
|
|
||||||
int picker_scroll_{0}; // Fila superior visible del picker (linealitzat).
|
// Brush actiu per Mode::TILE (índex al tileset; -1 = sense brush).
|
||||||
int picker_hover_{-1}; // Índex del tile sota el cursor dins del picker.
|
int brush_tile_{-1};
|
||||||
|
// Estat del TilePicker.
|
||||||
|
int tile_picker_scroll_{0};
|
||||||
|
int tile_picker_hover_{-1};
|
||||||
|
|
||||||
|
// Brush actiu per Mode::ENTITY (nom registrat al factory; "" = cap).
|
||||||
|
std::string brush_entity_;
|
||||||
|
// Estat de l'EntityPicker.
|
||||||
|
int entity_picker_scroll_{0};
|
||||||
|
int entity_picker_hover_{-1}; // Índex a la llista de noms.
|
||||||
|
|
||||||
|
// Entrada editable del picker. Cada item recorda el nom (clau de
|
||||||
|
// factory + YAML), el surface del sprite (frame 0 com a icona) i la
|
||||||
|
// mida de cada frame al GIF — necessària per clipar el primer frame
|
||||||
|
// quan el GIF és un strip multi-frame.
|
||||||
|
struct EditableEntity {
|
||||||
|
std::string name;
|
||||||
|
std::shared_ptr<Surface> sprite;
|
||||||
|
int frame_w{0};
|
||||||
|
int frame_h{0};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Construïda lazy al primer enter() i preservada entre sessions:
|
||||||
|
// el cost és I/O + parse de N plantilles YAML, però `EntityLoader`
|
||||||
|
// ja les memoritza, així que rellegir només resoldria per sortida i
|
||||||
|
// entrada al editor — no val la pena.
|
||||||
|
void ensureEditableEntities();
|
||||||
|
|
||||||
|
std::vector<EditableEntity> editable_entities_;
|
||||||
|
|
||||||
|
// Font compartida amb el Notifier/HUD: el surface el carrega Director
|
||||||
|
// a l'arrencada, ací només prenem la referència del cache. shared_ptr
|
||||||
|
// perquè `Text` accepta el surface per shared_ptr i així no copiem.
|
||||||
|
std::shared_ptr<Text> hud_font_;
|
||||||
|
|
||||||
|
// Selecció en Mode::HAND. Treballem amb índexs sobre el snapshot de
|
||||||
|
// `EntityManager::getEntities()` perquè és el que ens dóna l'API
|
||||||
|
// pública. Després de cada mutació (move/delete) ho recalculem; com
|
||||||
|
// que l'editor congela el joc, el snapshot només canvia per accions
|
||||||
|
// pròpies.
|
||||||
|
int hand_hover_idx_{-1};
|
||||||
|
int hand_selected_idx_{-1};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _DEBUG
|
#endif // _DEBUG
|
||||||