Compare commits
206 Commits
2025-08-21
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| c610065fe0 | |||
| d2be113c4e | |||
| 052bb063df | |||
| 9d974438b3 | |||
| b9fe376f2a | |||
| 0c05f6d5b6 | |||
| 39125ee57c | |||
| 7ebeeebaaf | |||
| c6c7b63f6d | |||
| 7959baeed9 | |||
| 5d1c6c6d99 | |||
| 145d1e3fc0 | |||
| 4679255d60 | |||
| 3cfb65320c | |||
| 636e4d932a | |||
| 9979f31b4a | |||
| 6190b35349 | |||
| fd4136a882 | |||
| 5362c5b022 | |||
| 357b5d5977 | |||
| f50ad68f10 | |||
| 155a7d038d | |||
| 4b732c189c | |||
| 1c3d59d678 | |||
| 1acbe1d097 | |||
| 245524c021 | |||
| b4624a9223 | |||
| 28e3e1ee0a | |||
| e250ca048f | |||
| 5bf96b9aba | |||
| ac6f521288 | |||
| 5a5c06efd1 | |||
| ef1a514c9b | |||
| ce54b10abb | |||
| 40538eaa28 | |||
| 88d814f371 | |||
| b933ceee63 | |||
| 75ccddbaa1 | |||
| fde77affdf | |||
| 52a387463d | |||
| 5a0fc9330d | |||
| 66661036a4 | |||
| bb132aade2 | |||
| d4e09e1e88 | |||
| 866f464d37 | |||
| da9f3c1e02 | |||
| 9b8fdf289f | |||
| bf12c1664a | |||
| d7836eedd7 | |||
| 4bac816e37 | |||
| 67f9103b96 | |||
| 8ddee66304 | |||
| 4fb6a9999f | |||
| 794dcf83f6 | |||
| 9fe73ed8e4 | |||
| e99b2abd7d | |||
| b128b285ed | |||
| c8bf9640cf | |||
| 2b4523d644 | |||
| 16306f2325 | |||
| d7c3ea7f69 | |||
| 413c3c30a6 | |||
| df6e7e5155 | |||
| 46974ef2eb | |||
| 50ccb2ccc2 | |||
| 9b966a260c | |||
| 49ea56f5e2 | |||
| 300edc90b5 | |||
| 5ff33ca6ca | |||
| 6dc6d8fc24 | |||
| 8d94ed516c | |||
| ba0b0930b0 | |||
| 29e76b1ddd | |||
| 54ceaa3042 | |||
| dcc223d287 | |||
| 7187412a45 | |||
| ff7aef827c | |||
| 6ff7ccf69a | |||
| e347e04d33 | |||
| 7946ea54a6 | |||
| 79033346c0 | |||
| 62b73d6f41 | |||
| 218ddabb5e | |||
| 427f40632a | |||
| a29b4d4379 | |||
| d851cdd2fe | |||
| 3354d00814 | |||
| 7bd7ba84e0 | |||
| 6ad34eaf57 | |||
| b4f2251508 | |||
| 473a52f986 | |||
| bcdd48d622 | |||
| 6985569573 | |||
| 5db43e674d | |||
| 34baa3c97d | |||
| bddb790fe2 | |||
| 6fae12ba02 | |||
| 4e083a8cdb | |||
| cbe4315701 | |||
| 49d561b583 | |||
| 6e56a6fd79 | |||
| 267d9647e0 | |||
| 13b3702d00 | |||
| 4500845dcd | |||
| a4abc02f88 | |||
| a0fb6934b0 | |||
| 19645445b2 | |||
| efe8628a3c | |||
| c98cb0d29f | |||
| c16fc1bae5 | |||
| fa0af1179a | |||
| d1e4a5eb07 | |||
| e18d1b186a | |||
| d056a5e336 | |||
| b9e26aa755 | |||
| b2afef2226 | |||
| c400aa96c0 | |||
| 8818954dcd | |||
| b92e5df98b | |||
| 83871273ec | |||
| 0459b39366 | |||
| 5bb0ff19bc | |||
| a867b3cf4d | |||
| 8a6ce8e66d | |||
| a40f04a739 | |||
| 0c670fd344 | |||
| 35f4bf690c | |||
| abeaf47f96 | |||
| 6498c35628 | |||
| d1c6af02db | |||
| 5edef17d84 | |||
| e4532fcef2 | |||
| 7a8d66c29d | |||
| 54292c9f8f | |||
| 3897553704 | |||
| 308f5c20fb | |||
| 987dcd0205 | |||
| d56f23544c | |||
| c79a846b29 | |||
| ad39d55e79 | |||
| 853ef426f0 | |||
| cadf7de3d8 | |||
| ec65ff9acb | |||
| d077374883 | |||
| 40a2b2cc00 | |||
| b3f3f151da | |||
| 3fdd61655a | |||
| 504727b95f | |||
| ff5446fcdf | |||
| 545eb70082 | |||
| 232a23a5dd | |||
| c9a29e26dd | |||
| 2977869ab5 | |||
| 6a223b68ba | |||
| 3fafff026b | |||
| 159528adc9 | |||
| 6c8f231b34 | |||
| c5d6d77ebf | |||
| 5e73327b2f | |||
| 720d286dcf | |||
| dd13a2bd7c | |||
| 1a6ef79466 | |||
| 8f83a1d13e | |||
| 9edfe6877f | |||
| 91b26631c6 | |||
| 331a690b78 | |||
| 5e3946e28b | |||
| d4a0189dc8 | |||
| 568b941990 | |||
| 49a3989ecf | |||
| af7cb01ead | |||
| 5c82916650 | |||
| 0c0518adac | |||
| cb7b290818 | |||
| ae30c9b34f | |||
| 9acd9aa631 | |||
| 577510ff8c | |||
| 66566913f6 | |||
| 3e6cc9dfab | |||
| a15e29344f | |||
| a96a17e11b | |||
| e0f6a424a9 | |||
| 49e30f947a | |||
| 470a07d28c | |||
| 65716fce20 | |||
| dfa66b0e95 | |||
| 3d9ffe356e | |||
| 19768cb72b | |||
| 26e0fd7247 | |||
| e2fd470ad3 | |||
| a72ae0a5fc | |||
| 7579594c22 | |||
| 6c702e7e23 | |||
| fb9c78eb49 | |||
| 62f65cbd5a | |||
| 057d3dcfee | |||
| c85336a4d0 | |||
| e4702e4e24 | |||
| 928335576c | |||
| fe950e6f17 | |||
| 6e81b6e60c | |||
| 74f6fe3501 | |||
| dfdb679054 | |||
| 26ed479306 | |||
| 32e9da55ef | |||
| 610083578e |
@@ -14,6 +14,8 @@ ContinuationIndentWidth: 4
|
|||||||
ConstructorInitializerIndentWidth: 4
|
ConstructorInitializerIndentWidth: 4
|
||||||
IndentWrappedFunctionNames: false
|
IndentWrappedFunctionNames: false
|
||||||
Cpp11BracedListStyle: true
|
Cpp11BracedListStyle: true
|
||||||
BreakConstructorInitializers: BeforeComma
|
BreakConstructorInitializers: BeforeColon
|
||||||
|
AllowAllConstructorInitializersOnNextLine: false
|
||||||
|
PackConstructorInitializers: Never
|
||||||
AllowAllArgumentsOnNextLine: false
|
AllowAllArgumentsOnNextLine: false
|
||||||
AllowAllParametersOfDeclarationOnNextLine: false
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
|
|||||||
9
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
.vscode
|
.vscode
|
||||||
|
.claude
|
||||||
build/
|
build/
|
||||||
data/config/config.txt
|
data/config/config.txt
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
@@ -16,4 +17,10 @@ coffee_crisis*
|
|||||||
debug.txt
|
debug.txt
|
||||||
cppcheck-result*
|
cppcheck-result*
|
||||||
desktop.ini
|
desktop.ini
|
||||||
ccae_release/
|
ccae_release/
|
||||||
|
Frameworks/
|
||||||
|
resources.pack
|
||||||
|
|
||||||
|
# Herramienta pack_resources (todas las plataformas)
|
||||||
|
tools/pack_resources
|
||||||
|
tools/pack_resources.exe
|
||||||
|
|||||||
@@ -14,6 +14,22 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
|
|||||||
cmake_policy(SET CMP0072 NEW)
|
cmake_policy(SET CMP0072 NEW)
|
||||||
set(OpenGL_GL_PREFERENCE GLVND)
|
set(OpenGL_GL_PREFERENCE GLVND)
|
||||||
|
|
||||||
|
# --- GENERACIÓN DE VERSIÓN AUTOMÁTICA ---
|
||||||
|
find_package(Git QUIET)
|
||||||
|
if(GIT_FOUND)
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${GIT_EXECUTABLE} rev-parse --short=7 HEAD
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_HASH
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
ERROR_QUIET
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
set(GIT_HASH "unknown")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Configurar archivo de versión
|
||||||
|
configure_file(${CMAKE_SOURCE_DIR}/source/version.h.in ${CMAKE_BINARY_DIR}/version.h @ONLY)
|
||||||
|
|
||||||
# --- 1. LISTA EXPLÍCITA DE FUENTES ---
|
# --- 1. LISTA EXPLÍCITA DE FUENTES ---
|
||||||
set(APP_SOURCES
|
set(APP_SOURCES
|
||||||
@@ -48,6 +64,7 @@ set(APP_SOURCES
|
|||||||
source/balloon_manager.cpp
|
source/balloon_manager.cpp
|
||||||
source/balloon.cpp
|
source/balloon.cpp
|
||||||
source/bullet.cpp
|
source/bullet.cpp
|
||||||
|
source/bullet_manager.cpp
|
||||||
source/enter_name.cpp
|
source/enter_name.cpp
|
||||||
source/explosions.cpp
|
source/explosions.cpp
|
||||||
source/game_logo.cpp
|
source/game_logo.cpp
|
||||||
@@ -79,6 +96,7 @@ set(APP_SOURCES
|
|||||||
|
|
||||||
# --- Otros ---
|
# --- Otros ---
|
||||||
source/color.cpp
|
source/color.cpp
|
||||||
|
source/demo.cpp
|
||||||
source/define_buttons.cpp
|
source/define_buttons.cpp
|
||||||
source/difficulty.cpp
|
source/difficulty.cpp
|
||||||
source/input_types.cpp
|
source/input_types.cpp
|
||||||
@@ -92,28 +110,29 @@ set(APP_SOURCES
|
|||||||
|
|
||||||
# Fuentes de librerías de terceros
|
# Fuentes de librerías de terceros
|
||||||
set(EXTERNAL_SOURCES
|
set(EXTERNAL_SOURCES
|
||||||
source/external/jail_shader.cpp
|
source/external/jail_audio.cpp
|
||||||
source/external/json.hpp
|
source/external/json.hpp
|
||||||
source/external/gif.cpp
|
source/external/gif.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# Añadir jail_audio.cpp solo si el audio está habilitado
|
# Fuentes del sistema de renderizado
|
||||||
if(NOT DISABLE_AUDIO)
|
set(RENDERING_SOURCES
|
||||||
list(APPEND EXTERNAL_SOURCES source/external/jail_audio.cpp)
|
source/rendering/opengl/opengl_shader.cpp
|
||||||
endif()
|
)
|
||||||
|
|
||||||
|
|
||||||
# Configuración de SDL3
|
# Configuración de SDL3
|
||||||
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3)
|
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3)
|
||||||
message(STATUS "SDL3 encontrado: ${SDL3_INCLUDE_DIRS}")
|
message(STATUS "SDL3 encontrado: ${SDL3_INCLUDE_DIRS}")
|
||||||
|
|
||||||
# --- 2. AÑADIR EJECUTABLE ---
|
# --- 2. AÑADIR EJECUTABLE ---
|
||||||
add_executable(${PROJECT_NAME} ${APP_SOURCES} ${EXTERNAL_SOURCES})
|
add_executable(${PROJECT_NAME} ${APP_SOURCES} ${EXTERNAL_SOURCES} ${RENDERING_SOURCES})
|
||||||
|
|
||||||
# --- 3. DIRECTORIOS DE INCLUSIÓN ---
|
# --- 3. DIRECTORIOS DE INCLUSIÓN ---
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||||
"${CMAKE_SOURCE_DIR}/source"
|
"${CMAKE_SOURCE_DIR}/source"
|
||||||
"${CMAKE_SOURCE_DIR}/source/external"
|
"${CMAKE_SOURCE_DIR}/source/external"
|
||||||
|
"${CMAKE_SOURCE_DIR}/source/rendering"
|
||||||
|
"${CMAKE_BINARY_DIR}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Enlazar la librería SDL3
|
# Enlazar la librería SDL3
|
||||||
@@ -128,16 +147,9 @@ target_compile_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:RELEASE>:-Os -ffunctio
|
|||||||
# Definir _DEBUG en modo Debug
|
# Definir _DEBUG en modo Debug
|
||||||
target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<CONFIG:DEBUG>:_DEBUG>)
|
target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<CONFIG:DEBUG>:_DEBUG>)
|
||||||
|
|
||||||
# Opción para habilitar/deshabilitar audio
|
# Descomentar la siguiente línea para activar el modo grabación de demos
|
||||||
option(DISABLE_AUDIO "Disable audio system" OFF)
|
# target_compile_definitions(${PROJECT_NAME} PRIVATE RECORDING)
|
||||||
|
|
||||||
# Definir NO_AUDIO si la opción está activada
|
|
||||||
if(DISABLE_AUDIO)
|
|
||||||
target_compile_definitions(${PROJECT_NAME} PRIVATE NO_AUDIO)
|
|
||||||
message(STATUS "Audio deshabilitado - NO_AUDIO definido")
|
|
||||||
else()
|
|
||||||
message(STATUS "Audio habilitado")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Configuración específica para cada plataforma
|
# Configuración específica para cada plataforma
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
|||||||
180
Makefile
@@ -3,6 +3,7 @@ DIR_ROOT := $(dir $(abspath $(MAKEFILE_LIST)))
|
|||||||
DIR_SOURCES := $(addsuffix /, $(DIR_ROOT)source)
|
DIR_SOURCES := $(addsuffix /, $(DIR_ROOT)source)
|
||||||
DIR_BIN := $(addsuffix /, $(DIR_ROOT))
|
DIR_BIN := $(addsuffix /, $(DIR_ROOT))
|
||||||
DIR_BUILD := $(addsuffix /, $(DIR_ROOT)build)
|
DIR_BUILD := $(addsuffix /, $(DIR_ROOT)build)
|
||||||
|
DIR_TOOLS := $(addsuffix /, $(DIR_ROOT)tools)
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
TARGET_NAME := coffee_crisis_arcade_edition
|
TARGET_NAME := coffee_crisis_arcade_edition
|
||||||
@@ -12,6 +13,17 @@ RELEASE_FOLDER := ccae_release
|
|||||||
RELEASE_FILE := $(RELEASE_FOLDER)/$(TARGET_NAME)
|
RELEASE_FILE := $(RELEASE_FOLDER)/$(TARGET_NAME)
|
||||||
RESOURCE_FILE := release/coffee.res
|
RESOURCE_FILE := release/coffee.res
|
||||||
|
|
||||||
|
# Variables para herramienta de empaquetado
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
PACK_TOOL := $(DIR_TOOLS)pack_resources.exe
|
||||||
|
PACK_CXX := $(CXX)
|
||||||
|
else
|
||||||
|
PACK_TOOL := $(DIR_TOOLS)pack_resources
|
||||||
|
PACK_CXX := $(CXX)
|
||||||
|
endif
|
||||||
|
PACK_SOURCES := $(DIR_TOOLS)pack_resources.cpp $(DIR_SOURCES)resource_pack.cpp
|
||||||
|
PACK_INCLUDES := -I$(DIR_ROOT) -I$(DIR_BUILD)
|
||||||
|
|
||||||
# Versión automática basada en la fecha actual (específica por SO)
|
# Versión automática basada en la fecha actual (específica por SO)
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
VERSION := $(shell powershell -Command "Get-Date -Format 'yyyy-MM-dd'")
|
VERSION := $(shell powershell -Command "Get-Date -Format 'yyyy-MM-dd'")
|
||||||
@@ -37,45 +49,41 @@ RASPI_RELEASE := $(TARGET_FILE)-$(VERSION)-raspberry.tar.gz
|
|||||||
|
|
||||||
# Lista completa de archivos fuente (basada en CMakeLists.txt)
|
# Lista completa de archivos fuente (basada en CMakeLists.txt)
|
||||||
APP_SOURCES := \
|
APP_SOURCES := \
|
||||||
source/animated_sprite.cpp \
|
|
||||||
source/asset.cpp \
|
source/asset.cpp \
|
||||||
source/audio.cpp \
|
source/audio.cpp \
|
||||||
source/background.cpp \
|
|
||||||
source/balloon_formations.cpp \
|
|
||||||
source/balloon_manager.cpp \
|
|
||||||
source/balloon.cpp \
|
|
||||||
source/bullet.cpp \
|
|
||||||
source/color.cpp \
|
|
||||||
source/define_buttons.cpp \
|
|
||||||
source/difficulty.cpp \
|
|
||||||
source/director.cpp \
|
source/director.cpp \
|
||||||
source/enter_name.cpp \
|
|
||||||
source/explosions.cpp \
|
|
||||||
source/external/gif.cpp \
|
|
||||||
source/external/jail_audio.cpp \
|
|
||||||
source/external/jail_shader.cpp \
|
|
||||||
source/fade.cpp \
|
|
||||||
source/game_logo.cpp \
|
|
||||||
source/global_events.cpp \
|
source/global_events.cpp \
|
||||||
source/global_inputs.cpp \
|
source/global_inputs.cpp \
|
||||||
source/input_types.cpp \
|
|
||||||
source/input.cpp \
|
source/input.cpp \
|
||||||
source/item.cpp \
|
|
||||||
source/lang.cpp \
|
source/lang.cpp \
|
||||||
source/main.cpp \
|
source/main.cpp \
|
||||||
source/manage_hiscore_table.cpp \
|
|
||||||
source/mouse.cpp \
|
|
||||||
source/moving_sprite.cpp \
|
|
||||||
source/options.cpp \
|
|
||||||
source/param.cpp \
|
source/param.cpp \
|
||||||
source/path_sprite.cpp \
|
|
||||||
source/player.cpp \
|
|
||||||
source/resource.cpp \
|
source/resource.cpp \
|
||||||
source/resource_helper.cpp \
|
source/resource_helper.cpp \
|
||||||
source/resource_loader.cpp \
|
source/resource_loader.cpp \
|
||||||
source/resource_pack.cpp \
|
source/resource_pack.cpp \
|
||||||
source/scoreboard.cpp \
|
|
||||||
source/screen.cpp \
|
source/screen.cpp \
|
||||||
|
source/text.cpp \
|
||||||
|
source/writer.cpp \
|
||||||
|
source/ui/menu_option.cpp \
|
||||||
|
source/ui/menu_renderer.cpp \
|
||||||
|
source/ui/notifier.cpp \
|
||||||
|
source/ui/service_menu.cpp \
|
||||||
|
source/ui/ui_message.cpp \
|
||||||
|
source/ui/window_message.cpp \
|
||||||
|
source/balloon_formations.cpp \
|
||||||
|
source/balloon_manager.cpp \
|
||||||
|
source/balloon.cpp \
|
||||||
|
source/bullet.cpp \
|
||||||
|
source/bullet_manager.cpp \
|
||||||
|
source/enter_name.cpp \
|
||||||
|
source/explosions.cpp \
|
||||||
|
source/game_logo.cpp \
|
||||||
|
source/item.cpp \
|
||||||
|
source/manage_hiscore_table.cpp \
|
||||||
|
source/player.cpp \
|
||||||
|
source/scoreboard.cpp \
|
||||||
|
source/tabe.cpp \
|
||||||
source/sections/credits.cpp \
|
source/sections/credits.cpp \
|
||||||
source/sections/game.cpp \
|
source/sections/game.cpp \
|
||||||
source/sections/hiscore_table.cpp \
|
source/sections/hiscore_table.cpp \
|
||||||
@@ -83,26 +91,32 @@ APP_SOURCES := \
|
|||||||
source/sections/intro.cpp \
|
source/sections/intro.cpp \
|
||||||
source/sections/logo.cpp \
|
source/sections/logo.cpp \
|
||||||
source/sections/title.cpp \
|
source/sections/title.cpp \
|
||||||
source/shutdown.cpp \
|
source/animated_sprite.cpp \
|
||||||
|
source/background.cpp \
|
||||||
|
source/fade.cpp \
|
||||||
|
source/moving_sprite.cpp \
|
||||||
|
source/path_sprite.cpp \
|
||||||
source/smart_sprite.cpp \
|
source/smart_sprite.cpp \
|
||||||
source/sprite.cpp \
|
source/sprite.cpp \
|
||||||
source/stage.cpp \
|
|
||||||
source/system_utils.cpp \
|
|
||||||
source/tabe.cpp \
|
|
||||||
source/text.cpp \
|
|
||||||
source/texture.cpp \
|
source/texture.cpp \
|
||||||
source/tiled_bg.cpp \
|
source/tiled_bg.cpp \
|
||||||
source/ui/menu_option.cpp \
|
source/color.cpp \
|
||||||
source/ui/menu_renderer.cpp \
|
source/demo.cpp \
|
||||||
source/ui/notifier.cpp \
|
source/define_buttons.cpp \
|
||||||
source/ui/service_menu.cpp \
|
source/difficulty.cpp \
|
||||||
source/ui/ui_message.cpp \
|
source/input_types.cpp \
|
||||||
source/ui/window_message.cpp \
|
source/mouse.cpp \
|
||||||
|
source/options.cpp \
|
||||||
|
source/shutdown.cpp \
|
||||||
|
source/stage.cpp \
|
||||||
|
source/system_utils.cpp \
|
||||||
source/utils.cpp \
|
source/utils.cpp \
|
||||||
source/writer.cpp
|
source/external/jail_audio.cpp \
|
||||||
|
source/external/gif.cpp \
|
||||||
|
source/rendering/opengl/opengl_shader.cpp
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
INCLUDES := -Isource -Isource/external
|
INCLUDES := -Isource -Isource/external -Isource/rendering -I$(DIR_BUILD)
|
||||||
|
|
||||||
# Variables según el sistema operativo
|
# Variables según el sistema operativo
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
@@ -135,6 +149,19 @@ else
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# Reglas para herramienta de empaquetado y resources.pack
|
||||||
|
$(PACK_TOOL): FORCE
|
||||||
|
@echo "Compilando herramienta de empaquetado..."
|
||||||
|
$(PACK_CXX) -std=c++20 -Wall -Os $(PACK_INCLUDES) $(PACK_SOURCES) -o $(PACK_TOOL)
|
||||||
|
@echo "✓ Herramienta de empaquetado lista: $(PACK_TOOL)"
|
||||||
|
|
||||||
|
pack_tool: $(PACK_TOOL)
|
||||||
|
|
||||||
|
resources.pack: $(PACK_TOOL)
|
||||||
|
@echo "Generando resources.pack desde directorio data/..."
|
||||||
|
$(PACK_TOOL) data resources.pack
|
||||||
|
@echo "✓ resources.pack generado exitosamente"
|
||||||
|
|
||||||
# Reglas para compilación
|
# Reglas para compilación
|
||||||
windows:
|
windows:
|
||||||
@echo off
|
@echo off
|
||||||
@@ -154,6 +181,8 @@ windows_debug:
|
|||||||
$(CXX) $(APP_SOURCES) $(INCLUDES) -DDEBUG -DVERBOSE $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(WIN_TARGET_FILE)_debug.exe"
|
$(CXX) $(APP_SOURCES) $(INCLUDES) -DDEBUG -DVERBOSE $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(WIN_TARGET_FILE)_debug.exe"
|
||||||
|
|
||||||
windows_release:
|
windows_release:
|
||||||
|
@$(MAKE) pack_tool
|
||||||
|
@$(MAKE) resources.pack
|
||||||
@echo off
|
@echo off
|
||||||
@echo Creando release para Windows - Version: $(VERSION)
|
@echo Creando release para Windows - Version: $(VERSION)
|
||||||
|
|
||||||
@@ -172,7 +201,7 @@ windows_release:
|
|||||||
|
|
||||||
# Compila
|
# Compila
|
||||||
windres release/coffee.rc -O coff -o $(RESOURCE_FILE)
|
windres release/coffee.rc -O coff -o $(RESOURCE_FILE)
|
||||||
$(CXX) $(APP_SOURCES) $(RESOURCE_FILE) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o "$(WIN_RELEASE_FILE).exe"
|
$(CXX) $(APP_SOURCES) $(RESOURCE_FILE) $(INCLUDES) -DRELEASE_BUILD $(CXXFLAGS) $(LDFLAGS) -o "$(WIN_RELEASE_FILE).exe"
|
||||||
strip -s -R .comment -R .gnu.version "$(WIN_RELEASE_FILE).exe" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(WIN_RELEASE_FILE).exe" --strip-unneeded
|
||||||
|
|
||||||
# Crea el fichero .zip
|
# Crea el fichero .zip
|
||||||
@@ -192,7 +221,13 @@ macos_debug:
|
|||||||
$(CXX) $(APP_SOURCES) $(INCLUDES) -DDEBUG -DVERBOSE $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
|
$(CXX) $(APP_SOURCES) $(INCLUDES) -DDEBUG -DVERBOSE $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
|
||||||
|
|
||||||
macos_release:
|
macos_release:
|
||||||
|
@$(MAKE) pack_tool
|
||||||
|
@$(MAKE) resources.pack
|
||||||
@echo "Creando release para macOS - Version: $(VERSION)"
|
@echo "Creando release para macOS - Version: $(VERSION)"
|
||||||
|
|
||||||
|
# Verificar e instalar create-dmg si es necesario
|
||||||
|
@which create-dmg > /dev/null || (echo "Instalando create-dmg..." && brew install create-dmg)
|
||||||
|
|
||||||
# Elimina datos de compilaciones anteriores
|
# Elimina datos de compilaciones anteriores
|
||||||
$(RMDIR) "$(RELEASE_FOLDER)"
|
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||||
$(RMDIR) Frameworks
|
$(RMDIR) Frameworks
|
||||||
@@ -216,33 +251,52 @@ macos_release:
|
|||||||
cp LICENSE "$(RELEASE_FOLDER)"
|
cp LICENSE "$(RELEASE_FOLDER)"
|
||||||
cp README.md "$(RELEASE_FOLDER)"
|
cp README.md "$(RELEASE_FOLDER)"
|
||||||
|
|
||||||
# Crea enlaces
|
|
||||||
ln -s /Applications "$(RELEASE_FOLDER)"/Applications
|
|
||||||
|
|
||||||
# Compila la versión para procesadores Intel
|
# Compila la versión para procesadores Intel
|
||||||
ifdef ENABLE_MACOS_X86_64
|
ifdef ENABLE_MACOS_X86_64
|
||||||
$(CXX) $(APP_SOURCES) $(INCLUDES) -DMACOS_BUNDLE $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)" -rpath @executable_path/../Frameworks/ -target x86_64-apple-macos10.15
|
$(CXX) $(APP_SOURCES) $(INCLUDES) -DMACOS_BUNDLE -DRELEASE_BUILD $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)" -rpath @executable_path/../Frameworks/ -target x86_64-apple-macos10.15
|
||||||
|
|
||||||
# Firma la aplicación
|
# Firma la aplicación
|
||||||
codesign --deep --force --sign - --timestamp=none "$(RELEASE_FOLDER)/$(APP_NAME).app"
|
codesign --deep --force --sign - --timestamp=none "$(RELEASE_FOLDER)/$(APP_NAME).app"
|
||||||
|
|
||||||
# Empaqueta el .dmg de la versión Intel
|
# Empaqueta el .dmg de la versión Intel con create-dmg
|
||||||
hdiutil create tmp.dmg -ov -volname "$(APP_NAME)" -fs HFS+ -srcfolder "$(RELEASE_FOLDER)"
|
@echo "Creando DMG Intel con iconos de 96x96..."
|
||||||
hdiutil convert tmp.dmg -format UDZO -o "$(MACOS_INTEL_RELEASE)"
|
create-dmg \
|
||||||
$(RMFILE) tmp.dmg
|
--volname "$(APP_NAME)" \
|
||||||
|
--window-pos 200 120 \
|
||||||
|
--window-size 720 300 \
|
||||||
|
--icon-size 96 \
|
||||||
|
--text-size 12 \
|
||||||
|
--icon "$(APP_NAME).app" 278 102 \
|
||||||
|
--icon "LICENSE" 441 102 \
|
||||||
|
--icon "README.md" 604 102 \
|
||||||
|
--app-drop-link 115 102 \
|
||||||
|
--hide-extension "$(APP_NAME).app" \
|
||||||
|
"$(MACOS_INTEL_RELEASE)" \
|
||||||
|
"$(RELEASE_FOLDER)" || true
|
||||||
@echo "Release Intel creado: $(MACOS_INTEL_RELEASE)"
|
@echo "Release Intel creado: $(MACOS_INTEL_RELEASE)"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Compila la versión para procesadores Apple Silicon
|
# Compila la versión para procesadores Apple Silicon
|
||||||
$(CXX) $(APP_SOURCES) $(INCLUDES) -DMACOS_BUNDLE -DSDL_DISABLE_IMMINTRIN_H $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)" -rpath @executable_path/../Frameworks/ -target arm64-apple-macos11
|
$(CXX) $(APP_SOURCES) $(INCLUDES) -DMACOS_BUNDLE -DRELEASE_BUILD -DSDL_DISABLE_IMMINTRIN_H $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)" -rpath @executable_path/../Frameworks/ -target arm64-apple-macos11
|
||||||
|
|
||||||
# Firma la aplicación
|
# Firma la aplicación
|
||||||
codesign --deep --force --sign - --timestamp=none "$(RELEASE_FOLDER)/$(APP_NAME).app"
|
codesign --deep --force --sign - --timestamp=none "$(RELEASE_FOLDER)/$(APP_NAME).app"
|
||||||
|
|
||||||
# Empaqueta el .dmg de la versión Apple Silicon
|
# Empaqueta el .dmg de la versión Apple Silicon con create-dmg
|
||||||
hdiutil create tmp.dmg -ov -volname "$(APP_NAME)" -fs HFS+ -srcfolder "$(RELEASE_FOLDER)"
|
@echo "Creando DMG Apple Silicon con iconos de 96x96..."
|
||||||
hdiutil convert tmp.dmg -format UDZO -o "$(MACOS_APPLE_SILICON_RELEASE)"
|
create-dmg \
|
||||||
$(RMFILE) tmp.dmg
|
--volname "$(APP_NAME)" \
|
||||||
|
--window-pos 200 120 \
|
||||||
|
--window-size 720 300 \
|
||||||
|
--icon-size 96 \
|
||||||
|
--text-size 12 \
|
||||||
|
--icon "$(APP_NAME).app" 278 102 \
|
||||||
|
--icon "LICENSE" 441 102 \
|
||||||
|
--icon "README.md" 604 102 \
|
||||||
|
--app-drop-link 115 102 \
|
||||||
|
--hide-extension "$(APP_NAME).app" \
|
||||||
|
"$(MACOS_APPLE_SILICON_RELEASE)" \
|
||||||
|
"$(RELEASE_FOLDER)" || true
|
||||||
@echo "Release Apple Silicon creado: $(MACOS_APPLE_SILICON_RELEASE)"
|
@echo "Release Apple Silicon creado: $(MACOS_APPLE_SILICON_RELEASE)"
|
||||||
|
|
||||||
# Elimina las carpetas temporales
|
# Elimina las carpetas temporales
|
||||||
@@ -259,6 +313,8 @@ linux_debug:
|
|||||||
$(CXX) $(APP_SOURCES) $(INCLUDES) -DDEBUG -DVERBOSE $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
|
$(CXX) $(APP_SOURCES) $(INCLUDES) -DDEBUG -DVERBOSE $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
|
||||||
|
|
||||||
linux_release:
|
linux_release:
|
||||||
|
@$(MAKE) pack_tool
|
||||||
|
@$(MAKE) resources.pack
|
||||||
@echo "Creando release para Linux - Version: $(VERSION)"
|
@echo "Creando release para Linux - Version: $(VERSION)"
|
||||||
# Elimina carpetas previas
|
# Elimina carpetas previas
|
||||||
$(RMDIR) "$(RELEASE_FOLDER)"
|
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||||
@@ -273,7 +329,7 @@ linux_release:
|
|||||||
cp README.md "$(RELEASE_FOLDER)"
|
cp README.md "$(RELEASE_FOLDER)"
|
||||||
|
|
||||||
# Compila
|
# Compila
|
||||||
$(CXX) $(APP_SOURCES) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FILE)"
|
$(CXX) $(APP_SOURCES) $(INCLUDES) -DRELEASE_BUILD $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FILE)"
|
||||||
strip -s -R .comment -R .gnu.version "$(RELEASE_FILE)" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(RELEASE_FILE)" --strip-unneeded
|
||||||
|
|
||||||
# Empaqueta ficheros
|
# Empaqueta ficheros
|
||||||
@@ -285,6 +341,8 @@ linux_release:
|
|||||||
$(RMDIR) "$(RELEASE_FOLDER)"
|
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||||
|
|
||||||
linux_release_desktop:
|
linux_release_desktop:
|
||||||
|
@$(MAKE) pack_tool
|
||||||
|
@$(MAKE) resources.pack
|
||||||
@echo "Creando release con integracion desktop para Linux - Version: $(VERSION)"
|
@echo "Creando release con integracion desktop para Linux - Version: $(VERSION)"
|
||||||
# Elimina carpetas previas
|
# Elimina carpetas previas
|
||||||
$(RMDIR) "$(RELEASE_FOLDER)"
|
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||||
@@ -303,7 +361,7 @@ linux_release_desktop:
|
|||||||
cp README.md "$(RELEASE_FOLDER)/$(TARGET_NAME)/"
|
cp README.md "$(RELEASE_FOLDER)/$(TARGET_NAME)/"
|
||||||
|
|
||||||
# Compila el ejecutable
|
# Compila el ejecutable
|
||||||
$(CXX) $(APP_SOURCES) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FOLDER)/$(TARGET_NAME)/bin/$(TARGET_NAME)"
|
$(CXX) $(APP_SOURCES) $(INCLUDES) -DRELEASE_BUILD $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FOLDER)/$(TARGET_NAME)/bin/$(TARGET_NAME)"
|
||||||
strip -s -R .comment -R .gnu.version "$(RELEASE_FOLDER)/$(TARGET_NAME)/bin/$(TARGET_NAME)" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(RELEASE_FOLDER)/$(TARGET_NAME)/bin/$(TARGET_NAME)" --strip-unneeded
|
||||||
|
|
||||||
# Crea el archivo .desktop
|
# Crea el archivo .desktop
|
||||||
@@ -390,6 +448,8 @@ raspi_debug:
|
|||||||
$(CXX) $(APP_SOURCES) $(INCLUDES) -DVERBOSE -DDEBUG $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
|
$(CXX) $(APP_SOURCES) $(INCLUDES) -DVERBOSE -DDEBUG $(CXXFLAGS_DEBUG) $(LDFLAGS) -o "$(TARGET_FILE)_debug"
|
||||||
|
|
||||||
raspi_release:
|
raspi_release:
|
||||||
|
@$(MAKE) pack_tool
|
||||||
|
@$(MAKE) resources.pack
|
||||||
@echo "Creando release para Raspberry Pi - Version: $(VERSION)"
|
@echo "Creando release para Raspberry Pi - Version: $(VERSION)"
|
||||||
# Elimina carpetas previas
|
# Elimina carpetas previas
|
||||||
$(RMDIR) "$(RELEASE_FOLDER)"
|
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||||
@@ -404,7 +464,7 @@ raspi_release:
|
|||||||
cp README.md "$(RELEASE_FOLDER)"
|
cp README.md "$(RELEASE_FOLDER)"
|
||||||
|
|
||||||
# Compila
|
# Compila
|
||||||
$(CXX) $(APP_SOURCES) $(INCLUDES) -DVERBOSE $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FILE)"
|
$(CXX) $(APP_SOURCES) $(INCLUDES) -DRELEASE_BUILD -DVERBOSE $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FILE)"
|
||||||
strip -s -R .comment -R .gnu.version "$(RELEASE_FILE)" --strip-unneeded
|
strip -s -R .comment -R .gnu.version "$(RELEASE_FILE)" --strip-unneeded
|
||||||
|
|
||||||
# Empaqueta ficheros
|
# Empaqueta ficheros
|
||||||
@@ -416,6 +476,8 @@ raspi_release:
|
|||||||
$(RMDIR) "$(RELEASE_FOLDER)"
|
$(RMDIR) "$(RELEASE_FOLDER)"
|
||||||
|
|
||||||
anbernic:
|
anbernic:
|
||||||
|
@$(MAKE) pack_tool
|
||||||
|
@$(MAKE) resources.pack
|
||||||
@echo "Compilando para Anbernic: $(TARGET_NAME)"
|
@echo "Compilando para Anbernic: $(TARGET_NAME)"
|
||||||
# Elimina carpetas previas
|
# Elimina carpetas previas
|
||||||
$(RMDIR) "$(RELEASE_FOLDER)"_anbernic
|
$(RMDIR) "$(RELEASE_FOLDER)"_anbernic
|
||||||
@@ -428,7 +490,7 @@ anbernic:
|
|||||||
cp resources.pack "$(RELEASE_FOLDER)"_anbernic
|
cp resources.pack "$(RELEASE_FOLDER)"_anbernic
|
||||||
|
|
||||||
# Compila
|
# Compila
|
||||||
$(CXX) $(APP_SOURCES) $(INCLUDES) -DANBERNIC -DNO_SHADERS -DARCADE -DVERBOSE $(CXXFLAGS) $(LDFLAGS) -o $(RELEASE_FOLDER)_anbernic/$(TARGET_NAME)
|
$(CXX) $(APP_SOURCES) $(INCLUDES) -DRELEASE_BUILD -DANBERNIC -DNO_SHADERS -DARCADE -DVERBOSE $(CXXFLAGS) $(LDFLAGS) -o $(RELEASE_FOLDER)_anbernic/$(TARGET_NAME)
|
||||||
|
|
||||||
# Opción para deshabilitar audio (equivalente a la opción DISABLE_AUDIO de CMake)
|
# Opción para deshabilitar audio (equivalente a la opción DISABLE_AUDIO de CMake)
|
||||||
no_audio:
|
no_audio:
|
||||||
@@ -457,7 +519,11 @@ help:
|
|||||||
@echo " raspi_release - Crear release completo para Raspberry Pi"
|
@echo " raspi_release - Crear release completo para Raspberry Pi"
|
||||||
@echo " anbernic - Compilar para Anbernic"
|
@echo " anbernic - Compilar para Anbernic"
|
||||||
@echo " no_audio - Compilar sin sistema de audio"
|
@echo " no_audio - Compilar sin sistema de audio"
|
||||||
|
@echo " pack_tool - Compilar herramienta de empaquetado"
|
||||||
|
@echo " resources.pack - Generar pack de recursos desde data/"
|
||||||
@echo " show_version - Mostrar version actual ($(VERSION))"
|
@echo " show_version - Mostrar version actual ($(VERSION))"
|
||||||
@echo " help - Mostrar esta ayuda"
|
@echo " help - Mostrar esta ayuda"
|
||||||
|
|
||||||
.PHONY: windows windows_rec windows_debug windows_release macos macos_debug macos_release linux linux_debug linux_release linux_release_desktop raspi raspi_debug raspi_release anbernic no_audio show_version help
|
.PHONY: windows windows_rec windows_debug windows_release macos macos_debug macos_release linux linux_debug linux_release linux_release_desktop raspi raspi_debug raspi_release anbernic no_audio show_version help pack_tool resources.pack
|
||||||
|
|
||||||
|
FORCE:
|
||||||
13
README.md
@@ -1,6 +1,8 @@
|
|||||||
# Coffee Crisis Arcade Edition
|
<div align="center">
|
||||||
|
<img src="https://php.sustancia.synology.me/images/ccae/coffee_crisis_arcade_edition_cover_web.png" width="600" alt="Coffee Crisis Cover">
|
||||||
|
</div>
|
||||||
|
|
||||||
<img src="https://php.sustancia.synology.me/images/ccae/coffee_crisis_arcade_edition_cover_web.png" width="300" align="left" style="margin-right: 20px; margin-bottom: 10px;" alt="Coffee Crisis Cover">
|
# Coffee Crisis Arcade Edition
|
||||||
|
|
||||||
## ¡La batalla definitiva pel cafè està ací!
|
## ¡La batalla definitiva pel cafè està ací!
|
||||||
|
|
||||||
@@ -35,10 +37,7 @@ El joc està optimitzat per a ser jugat amb un mando de jocs, encara que un dels
|
|||||||
|
|
||||||
> Nota: El joc suporta nomes un jugador amb teclat.
|
> Nota: El joc suporta nomes un jugador amb teclat.
|
||||||
|
|
||||||
<p align="center">
|

|
||||||
<img src="https://php.sustancia.synology.me/images/ccae/ccae1.png" alt="Joc" width="45%" />
|
|
||||||
<img src="https://php.sustancia.synology.me/images/ccae/ccae3.png" alt="Joc" width="45%" />
|
|
||||||
</p>
|
|
||||||
|
|
||||||
## Altres tecles
|
## Altres tecles
|
||||||
|
|
||||||
@@ -64,6 +63,8 @@ El joc està optimitzat per a ser jugat amb un mando de jocs, encara que un dels
|
|||||||
2. Descomprimix i executa l'arxiu `coffee_crisis_arcade_edition.exe`.
|
2. Descomprimix i executa l'arxiu `coffee_crisis_arcade_edition.exe`.
|
||||||
3. Gaudeix del joc!
|
3. Gaudeix del joc!
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## Agraïments
|
## Agraïments
|
||||||
|
|
||||||
Vull expressar la meua gratitud a **ChatGPT** i **GitHub Copilot**. Gràcies per ser un suport constant en el desenvolupament d'aquest joc!
|
Vull expressar la meua gratitud a **ChatGPT** i **GitHub Copilot**. Gràcies per ser un suport constant en el desenvolupament d'aquest joc!
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
# Variables: ${PREFIX}, ${SYSTEM_FOLDER}
|
# Variables: ${PREFIX}, ${SYSTEM_FOLDER}
|
||||||
|
|
||||||
# Archivos de configuración del sistema (absolutos y opcionales)
|
# Archivos de configuración del sistema (absolutos y opcionales)
|
||||||
DATA|${SYSTEM_FOLDER}/config.txt|optional,absolute
|
DATA|${SYSTEM_FOLDER}/config_v2.txt|optional,absolute
|
||||||
DATA|${SYSTEM_FOLDER}/controllers.json|optional,absolute
|
DATA|${SYSTEM_FOLDER}/controllers.json|optional,absolute
|
||||||
DATA|${SYSTEM_FOLDER}/score.bin|optional,absolute
|
DATA|${SYSTEM_FOLDER}/score.bin|optional,absolute
|
||||||
|
|
||||||
@@ -18,181 +18,191 @@ DATA|${PREFIX}/config/pools.txt
|
|||||||
DATA|${PREFIX}/config/stages.txt
|
DATA|${PREFIX}/config/stages.txt
|
||||||
|
|
||||||
# Archivos con los datos de la demo
|
# Archivos con los datos de la demo
|
||||||
DEMODATA|${PREFIX}/data/demo/demo1.bin
|
DEMODATA|/data/demo/demo1.bin
|
||||||
DEMODATA|${PREFIX}/data/demo/demo2.bin
|
DEMODATA|/data/demo/demo2.bin
|
||||||
|
DEMODATA|/data/demo/demo3.bin
|
||||||
|
|
||||||
# Música
|
# Música
|
||||||
MUSIC|${PREFIX}/data/music/credits.ogg
|
MUSIC|/data/music/congratulations.ogg
|
||||||
MUSIC|${PREFIX}/data/music/intro.ogg
|
MUSIC|/data/music/credits.ogg
|
||||||
MUSIC|${PREFIX}/data/music/playing.ogg
|
MUSIC|/data/music/intro.ogg
|
||||||
MUSIC|${PREFIX}/data/music/title.ogg
|
MUSIC|/data/music/playing.ogg
|
||||||
|
MUSIC|/data/music/title.ogg
|
||||||
|
|
||||||
# Sonidos
|
# Sonidos
|
||||||
SOUND|${PREFIX}/data/sound/balloon_bounce0.wav
|
SOUND|/data/sound/balloon_bounce0.wav
|
||||||
SOUND|${PREFIX}/data/sound/balloon_bounce1.wav
|
SOUND|/data/sound/balloon_bounce1.wav
|
||||||
SOUND|${PREFIX}/data/sound/balloon_bounce2.wav
|
SOUND|/data/sound/balloon_bounce2.wav
|
||||||
SOUND|${PREFIX}/data/sound/balloon_bounce3.wav
|
SOUND|/data/sound/balloon_bounce3.wav
|
||||||
SOUND|${PREFIX}/data/sound/balloon_pop0.wav
|
SOUND|/data/sound/balloon_pop0.wav
|
||||||
SOUND|${PREFIX}/data/sound/balloon_pop1.wav
|
SOUND|/data/sound/balloon_pop1.wav
|
||||||
SOUND|${PREFIX}/data/sound/balloon_pop2.wav
|
SOUND|/data/sound/balloon_pop2.wav
|
||||||
SOUND|${PREFIX}/data/sound/balloon_pop3.wav
|
SOUND|/data/sound/balloon_pop3.wav
|
||||||
SOUND|${PREFIX}/data/sound/bullet.wav
|
SOUND|/data/sound/bullet1p.wav
|
||||||
SOUND|${PREFIX}/data/sound/clock.wav
|
SOUND|/data/sound/bullet2p.wav
|
||||||
SOUND|${PREFIX}/data/sound/coffee_out.wav
|
SOUND|/data/sound/clock.wav
|
||||||
SOUND|${PREFIX}/data/sound/continue_clock.wav
|
SOUND|/data/sound/coffee_out.wav
|
||||||
SOUND|${PREFIX}/data/sound/credit.wav
|
SOUND|/data/sound/continue_clock.wav
|
||||||
SOUND|${PREFIX}/data/sound/debian_drop.wav
|
SOUND|/data/sound/credit.wav
|
||||||
SOUND|${PREFIX}/data/sound/debian_pickup.wav
|
SOUND|/data/sound/debian_drop.wav
|
||||||
SOUND|${PREFIX}/data/sound/hi_score_achieved.wav
|
SOUND|/data/sound/debian_pickup.wav
|
||||||
SOUND|${PREFIX}/data/sound/item_drop.wav
|
SOUND|/data/sound/hi_score_achieved.wav
|
||||||
SOUND|${PREFIX}/data/sound/item_pickup.wav
|
SOUND|/data/sound/item_drop.wav
|
||||||
SOUND|${PREFIX}/data/sound/jump.wav
|
SOUND|/data/sound/item_pickup.wav
|
||||||
SOUND|${PREFIX}/data/sound/logo.wav
|
SOUND|/data/sound/jump.wav
|
||||||
SOUND|${PREFIX}/data/sound/notify.wav
|
SOUND|/data/sound/logo.wav
|
||||||
SOUND|${PREFIX}/data/sound/player_collision.wav
|
SOUND|/data/sound/name_input_accept.wav
|
||||||
SOUND|${PREFIX}/data/sound/power_ball_explosion.wav
|
SOUND|/data/sound/notify.wav
|
||||||
SOUND|${PREFIX}/data/sound/service_menu_adjust.wav
|
SOUND|/data/sound/player_collision.wav
|
||||||
SOUND|${PREFIX}/data/sound/service_menu_move.wav
|
SOUND|/data/sound/power_ball_explosion.wav
|
||||||
SOUND|${PREFIX}/data/sound/service_menu_select.wav
|
SOUND|/data/sound/service_menu_adjust.wav
|
||||||
SOUND|${PREFIX}/data/sound/stage_change.wav
|
SOUND|/data/sound/service_menu_back.wav
|
||||||
SOUND|${PREFIX}/data/sound/tabe_hit.wav
|
SOUND|/data/sound/service_menu_move.wav
|
||||||
SOUND|${PREFIX}/data/sound/tabe.wav
|
SOUND|/data/sound/service_menu_select.wav
|
||||||
SOUND|${PREFIX}/data/sound/title.wav
|
SOUND|/data/sound/stage_change.wav
|
||||||
SOUND|${PREFIX}/data/sound/voice_aw_aw_aw.wav
|
SOUND|/data/sound/tabe_hit.wav
|
||||||
SOUND|${PREFIX}/data/sound/voice_coffee.wav
|
SOUND|/data/sound/tabe.wav
|
||||||
SOUND|${PREFIX}/data/sound/voice_credit_thankyou.wav
|
SOUND|/data/sound/title.wav
|
||||||
SOUND|${PREFIX}/data/sound/voice_get_ready.wav
|
SOUND|/data/sound/voice_aw_aw_aw.wav
|
||||||
SOUND|${PREFIX}/data/sound/voice_no.wav
|
SOUND|/data/sound/voice_coffee.wav
|
||||||
SOUND|${PREFIX}/data/sound/voice_power_up.wav
|
SOUND|/data/sound/voice_credit_thankyou.wav
|
||||||
SOUND|${PREFIX}/data/sound/voice_recover.wav
|
SOUND|/data/sound/voice_game_over.wav
|
||||||
SOUND|${PREFIX}/data/sound/voice_thankyou.wav
|
SOUND|/data/sound/voice_get_ready.wav
|
||||||
SOUND|${PREFIX}/data/sound/walk.wav
|
SOUND|/data/sound/voice_no.wav
|
||||||
|
SOUND|/data/sound/voice_power_up.wav
|
||||||
|
SOUND|/data/sound/voice_recover.wav
|
||||||
|
SOUND|/data/sound/voice_thankyou.wav
|
||||||
|
SOUND|/data/sound/walk.wav
|
||||||
|
|
||||||
# Shaders
|
# Shaders OpenGL Desktop 3.3 (Windows/Linux)
|
||||||
DATA|${PREFIX}/data/shaders/crtpi_240.glsl
|
DATA|/data/shaders/crtpi_vertex.glsl
|
||||||
DATA|${PREFIX}/data/shaders/crtpi_256.glsl
|
DATA|/data/shaders/crtpi_fragment.glsl
|
||||||
|
|
||||||
|
# Shaders OpenGL ES 3.0 (Raspberry Pi) - opcionales
|
||||||
|
DATA|/data/shaders/crtpi_vertex_es.glsl|optional
|
||||||
|
DATA|/data/shaders/crtpi_fragment_es.glsl|optional
|
||||||
|
|
||||||
# Texturas - Balloons
|
# Texturas - Balloons
|
||||||
ANIMATION|${PREFIX}/data/gfx/balloon/balloon0.ani
|
ANIMATION|/data/gfx/balloon/balloon0.ani
|
||||||
ANIMATION|${PREFIX}/data/gfx/balloon/balloon1.ani
|
ANIMATION|/data/gfx/balloon/balloon1.ani
|
||||||
ANIMATION|${PREFIX}/data/gfx/balloon/balloon2.ani
|
ANIMATION|/data/gfx/balloon/balloon2.ani
|
||||||
ANIMATION|${PREFIX}/data/gfx/balloon/balloon3.ani
|
ANIMATION|/data/gfx/balloon/balloon3.ani
|
||||||
BITMAP|${PREFIX}/data/gfx/balloon/balloon0.png
|
BITMAP|/data/gfx/balloon/balloon0.png
|
||||||
BITMAP|${PREFIX}/data/gfx/balloon/balloon1.png
|
BITMAP|/data/gfx/balloon/balloon1.png
|
||||||
BITMAP|${PREFIX}/data/gfx/balloon/balloon2.png
|
BITMAP|/data/gfx/balloon/balloon2.png
|
||||||
BITMAP|${PREFIX}/data/gfx/balloon/balloon3.png
|
BITMAP|/data/gfx/balloon/balloon3.png
|
||||||
|
|
||||||
# Texturas - Explosiones
|
# Texturas - Explosiones
|
||||||
ANIMATION|${PREFIX}/data/gfx/balloon/explosion0.ani
|
ANIMATION|/data/gfx/balloon/explosion0.ani
|
||||||
ANIMATION|${PREFIX}/data/gfx/balloon/explosion1.ani
|
ANIMATION|/data/gfx/balloon/explosion1.ani
|
||||||
ANIMATION|${PREFIX}/data/gfx/balloon/explosion2.ani
|
ANIMATION|/data/gfx/balloon/explosion2.ani
|
||||||
ANIMATION|${PREFIX}/data/gfx/balloon/explosion3.ani
|
ANIMATION|/data/gfx/balloon/explosion3.ani
|
||||||
BITMAP|${PREFIX}/data/gfx/balloon/explosion0.png
|
BITMAP|/data/gfx/balloon/explosion0.png
|
||||||
BITMAP|${PREFIX}/data/gfx/balloon/explosion1.png
|
BITMAP|/data/gfx/balloon/explosion1.png
|
||||||
BITMAP|${PREFIX}/data/gfx/balloon/explosion2.png
|
BITMAP|/data/gfx/balloon/explosion2.png
|
||||||
BITMAP|${PREFIX}/data/gfx/balloon/explosion3.png
|
BITMAP|/data/gfx/balloon/explosion3.png
|
||||||
|
|
||||||
# Texturas - Power Ball
|
# Texturas - Power Ball
|
||||||
ANIMATION|${PREFIX}/data/gfx/balloon/powerball.ani
|
ANIMATION|/data/gfx/balloon/powerball.ani
|
||||||
BITMAP|${PREFIX}/data/gfx/balloon/powerball.png
|
BITMAP|/data/gfx/balloon/powerball.png
|
||||||
|
|
||||||
# Texturas - Bala
|
# Texturas - Bala
|
||||||
ANIMATION|${PREFIX}/data/gfx/bullet/bullet.ani
|
ANIMATION|/data/gfx/bullet/bullet.ani
|
||||||
BITMAP|${PREFIX}/data/gfx/bullet/bullet.png
|
BITMAP|/data/gfx/bullet/bullet.png
|
||||||
|
|
||||||
# Texturas - Tabe
|
# Texturas - Tabe
|
||||||
ANIMATION|${PREFIX}/data/gfx/tabe/tabe.ani
|
ANIMATION|/data/gfx/tabe/tabe.ani
|
||||||
BITMAP|${PREFIX}/data/gfx/tabe/tabe.png
|
BITMAP|/data/gfx/tabe/tabe.png
|
||||||
|
|
||||||
# Texturas - Juego
|
# Texturas - Juego
|
||||||
BITMAP|${PREFIX}/data/gfx/game/game_buildings.png
|
BITMAP|/data/gfx/game/game_buildings.png
|
||||||
BITMAP|${PREFIX}/data/gfx/game/game_clouds1.png
|
BITMAP|/data/gfx/game/game_clouds1.png
|
||||||
BITMAP|${PREFIX}/data/gfx/game/game_clouds2.png
|
BITMAP|/data/gfx/game/game_clouds2.png
|
||||||
BITMAP|${PREFIX}/data/gfx/game/game_grass.png
|
ANIMATION|/data/gfx/game/game_grass.ani
|
||||||
BITMAP|${PREFIX}/data/gfx/game/game_moon.png
|
BITMAP|/data/gfx/game/game_grass.png
|
||||||
BITMAP|${PREFIX}/data/gfx/game/game_power_meter.png
|
BITMAP|/data/gfx/game/game_moon.png
|
||||||
BITMAP|${PREFIX}/data/gfx/game/game_sky_colors.png
|
BITMAP|/data/gfx/game/game_power_meter.png
|
||||||
BITMAP|${PREFIX}/data/gfx/game/game_sun.png
|
BITMAP|/data/gfx/game/game_sky_colors.png
|
||||||
|
BITMAP|/data/gfx/game/game_sun.png
|
||||||
|
|
||||||
# Texturas - Intro
|
# Texturas - Intro
|
||||||
BITMAP|${PREFIX}/data/gfx/intro/intro1.png
|
BITMAP|/data/gfx/intro/intro1.png
|
||||||
BITMAP|${PREFIX}/data/gfx/intro/intro2.png
|
BITMAP|/data/gfx/intro/intro2.png
|
||||||
BITMAP|${PREFIX}/data/gfx/intro/intro3.png
|
BITMAP|/data/gfx/intro/intro3.png
|
||||||
BITMAP|${PREFIX}/data/gfx/intro/intro4.png
|
BITMAP|/data/gfx/intro/intro4.png
|
||||||
BITMAP|${PREFIX}/data/gfx/intro/intro5.png
|
BITMAP|/data/gfx/intro/intro5.png
|
||||||
BITMAP|${PREFIX}/data/gfx/intro/intro6.png
|
BITMAP|/data/gfx/intro/intro6.png
|
||||||
|
|
||||||
# Texturas - Logo
|
# Texturas - Logo
|
||||||
BITMAP|${PREFIX}/data/gfx/logo/logo_jailgames_mini.png
|
BITMAP|/data/gfx/logo/logo_jailgames_mini.png
|
||||||
BITMAP|${PREFIX}/data/gfx/logo/logo_jailgames.png
|
BITMAP|/data/gfx/logo/logo_jailgames.png
|
||||||
BITMAP|${PREFIX}/data/gfx/logo/logo_since_1998.png
|
BITMAP|/data/gfx/logo/logo_since_1998.png
|
||||||
|
|
||||||
# Texturas - Items
|
# Texturas - Items
|
||||||
ANIMATION|${PREFIX}/data/gfx/item/item_clock.ani
|
ANIMATION|/data/gfx/item/item_clock.ani
|
||||||
ANIMATION|${PREFIX}/data/gfx/item/item_coffee_machine.ani
|
ANIMATION|/data/gfx/item/item_coffee_machine.ani
|
||||||
ANIMATION|${PREFIX}/data/gfx/item/item_coffee.ani
|
ANIMATION|/data/gfx/item/item_coffee.ani
|
||||||
ANIMATION|${PREFIX}/data/gfx/item/item_debian.ani
|
ANIMATION|/data/gfx/item/item_debian.ani
|
||||||
ANIMATION|${PREFIX}/data/gfx/item/item_points1_disk.ani
|
ANIMATION|/data/gfx/item/item_points1_disk.ani
|
||||||
ANIMATION|${PREFIX}/data/gfx/item/item_points2_gavina.ani
|
ANIMATION|/data/gfx/item/item_points2_gavina.ani
|
||||||
ANIMATION|${PREFIX}/data/gfx/item/item_points3_pacmar.ani
|
ANIMATION|/data/gfx/item/item_points3_pacmar.ani
|
||||||
BITMAP|${PREFIX}/data/gfx/item/item_clock.png
|
BITMAP|/data/gfx/item/item_clock.png
|
||||||
BITMAP|${PREFIX}/data/gfx/item/item_coffee_machine.png
|
BITMAP|/data/gfx/item/item_coffee_machine.png
|
||||||
BITMAP|${PREFIX}/data/gfx/item/item_coffee.png
|
BITMAP|/data/gfx/item/item_coffee.png
|
||||||
BITMAP|${PREFIX}/data/gfx/item/item_debian.png
|
BITMAP|/data/gfx/item/item_debian.png
|
||||||
BITMAP|${PREFIX}/data/gfx/item/item_points1_disk.png
|
BITMAP|/data/gfx/item/item_points1_disk.png
|
||||||
BITMAP|${PREFIX}/data/gfx/item/item_points2_gavina.png
|
BITMAP|/data/gfx/item/item_points2_gavina.png
|
||||||
BITMAP|${PREFIX}/data/gfx/item/item_points3_pacmar.png
|
BITMAP|/data/gfx/item/item_points3_pacmar.png
|
||||||
|
|
||||||
# Texturas - Titulo
|
# Texturas - Titulo
|
||||||
ANIMATION|${PREFIX}/data/gfx/title/title_dust.ani
|
ANIMATION|/data/gfx/title/title_dust.ani
|
||||||
BITMAP|${PREFIX}/data/gfx/title/title_arcade_edition.png
|
BITMAP|/data/gfx/title/title_arcade_edition.png
|
||||||
BITMAP|${PREFIX}/data/gfx/title/title_bg_tile.png
|
BITMAP|/data/gfx/title/title_bg_tile.png
|
||||||
BITMAP|${PREFIX}/data/gfx/title/title_coffee.png
|
BITMAP|/data/gfx/title/title_coffee.png
|
||||||
BITMAP|${PREFIX}/data/gfx/title/title_crisis.png
|
BITMAP|/data/gfx/title/title_crisis.png
|
||||||
BITMAP|${PREFIX}/data/gfx/title/title_dust.png
|
BITMAP|/data/gfx/title/title_dust.png
|
||||||
|
|
||||||
# Texturas - Jugador 1
|
# Texturas - Jugador 1
|
||||||
BITMAP|${PREFIX}/data/gfx/player/player1_power.png
|
BITMAP|/data/gfx/player/player1_power.png
|
||||||
BITMAP|${PREFIX}/data/gfx/player/player1.gif
|
BITMAP|/data/gfx/player/player1.gif
|
||||||
PALETTE|${PREFIX}/data/gfx/player/player1_coffee1.pal
|
PALETTE|/data/gfx/player/player1_coffee1.pal
|
||||||
PALETTE|${PREFIX}/data/gfx/player/player1_coffee2.pal
|
PALETTE|/data/gfx/player/player1_coffee2.pal
|
||||||
PALETTE|${PREFIX}/data/gfx/player/player1_invencible.pal
|
PALETTE|/data/gfx/player/player1_invencible.pal
|
||||||
|
|
||||||
# Texturas - Jugador 2
|
# Texturas - Jugador 2
|
||||||
BITMAP|${PREFIX}/data/gfx/player/player2_power.png
|
BITMAP|/data/gfx/player/player2_power.png
|
||||||
BITMAP|${PREFIX}/data/gfx/player/player2.gif
|
BITMAP|/data/gfx/player/player2.gif
|
||||||
PALETTE|${PREFIX}/data/gfx/player/player2_coffee1.pal
|
PALETTE|/data/gfx/player/player2_coffee1.pal
|
||||||
PALETTE|${PREFIX}/data/gfx/player/player2_coffee2.pal
|
PALETTE|/data/gfx/player/player2_coffee2.pal
|
||||||
PALETTE|${PREFIX}/data/gfx/player/player2_invencible.pal
|
PALETTE|/data/gfx/player/player2_invencible.pal
|
||||||
|
|
||||||
# Animaciones del jugador
|
# Animaciones del jugador
|
||||||
ANIMATION|${PREFIX}/data/gfx/player/player_power.ani
|
ANIMATION|/data/gfx/player/player_power.ani
|
||||||
ANIMATION|${PREFIX}/data/gfx/player/player.ani
|
ANIMATION|/data/gfx/player/player1.ani
|
||||||
|
ANIMATION|/data/gfx/player/player2.ani
|
||||||
# Texturas - Golpe del jugador
|
|
||||||
BITMAP|${PREFIX}/data/gfx/player/hit.png
|
|
||||||
|
|
||||||
# Fuentes de texto
|
# Fuentes de texto
|
||||||
BITMAP|${PREFIX}/data/font/04b_25_2x.png
|
BITMAP|/data/font/04b_25_2x.png
|
||||||
BITMAP|${PREFIX}/data/font/04b_25_flat_2x.png
|
BITMAP|/data/font/04b_25_2x_white.png
|
||||||
BITMAP|${PREFIX}/data/font/04b_25_flat.png
|
BITMAP|/data/font/04b_25_flat_2x.png
|
||||||
BITMAP|${PREFIX}/data/font/04b_25_grey.png
|
BITMAP|/data/font/04b_25_flat.png
|
||||||
BITMAP|${PREFIX}/data/font/04b_25_metal.png
|
BITMAP|/data/font/04b_25_grey.png
|
||||||
BITMAP|${PREFIX}/data/font/04b_25_reversed_2x.png
|
BITMAP|/data/font/04b_25_metal.png
|
||||||
BITMAP|${PREFIX}/data/font/04b_25_reversed.png
|
BITMAP|/data/font/04b_25_reversed_2x.png
|
||||||
BITMAP|${PREFIX}/data/font/04b_25_white.png
|
BITMAP|/data/font/04b_25_reversed.png
|
||||||
BITMAP|${PREFIX}/data/font/04b_25.png
|
BITMAP|/data/font/04b_25_white.png
|
||||||
BITMAP|${PREFIX}/data/font/8bithud.png
|
BITMAP|/data/font/04b_25.png
|
||||||
BITMAP|${PREFIX}/data/font/aseprite.png
|
BITMAP|/data/font/8bithud.png
|
||||||
BITMAP|${PREFIX}/data/font/smb2_grad.png
|
BITMAP|/data/font/aseprite.png
|
||||||
BITMAP|${PREFIX}/data/font/smb2.png
|
BITMAP|/data/font/smb2_grad.png
|
||||||
FONT|${PREFIX}/data/font/04b_25_2x.txt
|
BITMAP|/data/font/smb2.png
|
||||||
FONT|${PREFIX}/data/font/04b_25.txt
|
FONT|/data/font/04b_25_2x.txt
|
||||||
FONT|${PREFIX}/data/font/8bithud.txt
|
FONT|/data/font/04b_25.txt
|
||||||
FONT|${PREFIX}/data/font/aseprite.txt
|
FONT|/data/font/8bithud.txt
|
||||||
FONT|${PREFIX}/data/font/smb2.txt
|
FONT|/data/font/aseprite.txt
|
||||||
|
FONT|/data/font/smb2.txt
|
||||||
|
|
||||||
# Idiomas
|
# Idiomas
|
||||||
LANG|${PREFIX}/data/lang/ba_BA.json
|
LANG|/data/lang/ba_BA.json
|
||||||
LANG|${PREFIX}/data/lang/en_UK.json
|
LANG|/data/lang/en_UK.json
|
||||||
LANG|${PREFIX}/data/lang/es_ES.json
|
LANG|/data/lang/es_ES.json
|
||||||
@@ -8,270 +8,270 @@
|
|||||||
|
|
||||||
formation: 0
|
formation: 0
|
||||||
# Dos enemigos BALLOON3 uno a cada extremo
|
# Dos enemigos BALLOON3 uno a cada extremo
|
||||||
X3_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, EXTRALARGE, 0
|
X3_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, EXTRALARGE, 0.0000
|
||||||
X3_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, EXTRALARGE, 0
|
X3_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, EXTRALARGE, 0.0000
|
||||||
|
|
||||||
formation: 1
|
formation: 1
|
||||||
# Dos enemigos BALLOON3 uno a cada cuarto. Ambos van hacia el centro
|
# Dos enemigos BALLOON3 uno a cada cuarto. Ambos van hacia el centro
|
||||||
X3_25, 0, DEFAULT_POS_Y, RIGHT, BALLOON, EXTRALARGE, 0
|
X3_25, 0, DEFAULT_POS_Y, RIGHT, BALLOON, EXTRALARGE, 0.0000
|
||||||
X3_75, 0, DEFAULT_POS_Y, LEFT, BALLOON, EXTRALARGE, 0
|
X3_75, 0, DEFAULT_POS_Y, LEFT, BALLOON, EXTRALARGE, 0.0000
|
||||||
|
|
||||||
formation: 2
|
formation: 2
|
||||||
# Cuatro enemigos BALLOON1 uno detrás del otro. A la izquierda y hacia el centro
|
# Cuatro enemigos BALLOON1 uno detrás del otro. A la izquierda y hacia el centro
|
||||||
X1_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 30
|
X1_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 0.5000
|
||||||
X1_0, 1, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 20
|
X1_0, 1, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 0.3333
|
||||||
X1_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 10
|
X1_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 0.1667
|
||||||
X1_0, 3, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 0
|
X1_0, 3, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 0.0000
|
||||||
|
|
||||||
formation: 3
|
formation: 3
|
||||||
# Cuatro enemigos BALLOON1 uno detrás del otro. A la derecha y hacia el centro
|
# Cuatro enemigos BALLOON1 uno detrás del otro. A la derecha y hacia el centro
|
||||||
X1_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 30
|
X1_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 0.5000
|
||||||
X1_100, -1, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 20
|
X1_100, -1, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 0.3333
|
||||||
X1_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 10
|
X1_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 0.1667
|
||||||
X1_100, -3, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 0
|
X1_100, -3, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 0.0000
|
||||||
|
|
||||||
formation: 4
|
formation: 4
|
||||||
# Tres enemigos BALLOON2. 0, 25, 50. Hacia la derecha
|
# Tres enemigos BALLOON2. 0, 25, 50. Hacia la derecha
|
||||||
X2_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 20
|
X2_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.3333
|
||||||
X2_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 10
|
X2_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.1667
|
||||||
X2_0, 4, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0
|
X2_0, 4, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.0000
|
||||||
|
|
||||||
formation: 5
|
formation: 5
|
||||||
# Tres enemigos BALLOON2. 50, 75, 100. Hacia la izquierda
|
# Tres enemigos BALLOON2. 50, 75, 100. Hacia la izquierda
|
||||||
X2_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 20
|
X2_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.3333
|
||||||
X2_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 10
|
X2_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.1667
|
||||||
X2_100, -4, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0
|
X2_100, -4, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.0000
|
||||||
|
|
||||||
formation: 6
|
formation: 6
|
||||||
# Tres enemigos BALLOON2. 0, 0, 0. Hacia la derecha
|
# Tres enemigos BALLOON2. 0, 0, 0. Hacia la derecha
|
||||||
X2_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 20
|
X2_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.3333
|
||||||
X2_0, 1, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 10
|
X2_0, 1, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.1667
|
||||||
X2_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0
|
X2_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.0000
|
||||||
|
|
||||||
formation: 7
|
formation: 7
|
||||||
# Tres enemigos BALLOON2. 100, 100, 100. Hacia la izquierda
|
# Tres enemigos BALLOON2. 100, 100, 100. Hacia la izquierda
|
||||||
X2_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 20
|
X2_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.3333
|
||||||
X2_100, -1, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 10
|
X2_100, -1, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.1667
|
||||||
X2_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0
|
X2_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.0000
|
||||||
|
|
||||||
formation: 8
|
formation: 8
|
||||||
# Seis enemigos BALLOON0. 0, 0, 0, 0, 0, 0. Hacia la derecha
|
# Seis enemigos BALLOON0. 0, 0, 0, 0, 0, 0. Hacia la derecha
|
||||||
X0_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 50
|
X0_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.8333
|
||||||
X0_0, 1, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 40
|
X0_0, 1, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.6667
|
||||||
X0_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 30
|
X0_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.5000
|
||||||
X0_0, 3, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 20
|
X0_0, 3, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.3333
|
||||||
X0_0, 4, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 10
|
X0_0, 4, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.1667
|
||||||
X0_0, 5, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0
|
X0_0, 5, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.0000
|
||||||
|
|
||||||
formation: 9
|
formation: 9
|
||||||
# Seis enemigos BALLOON0. 100, 100, 100, 100, 100, 100. Hacia la izquierda
|
# Seis enemigos BALLOON0. 100, 100, 100, 100, 100, 100. Hacia la izquierda
|
||||||
X0_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 50
|
X0_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.8333
|
||||||
X0_100, -1, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 40
|
X0_100, -1, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.6667
|
||||||
X0_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 30
|
X0_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.5000
|
||||||
X0_100, -3, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 20
|
X0_100, -3, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.3333
|
||||||
X0_100, -4, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 10
|
X0_100, -4, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.1667
|
||||||
X0_100, -5, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0
|
X0_100, -5, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.0000
|
||||||
|
|
||||||
formation: 10
|
formation: 10
|
||||||
# Tres enemigos BALLOON3 seguidos desde la izquierda. Hacia la derecha
|
# Tres enemigos BALLOON3 seguidos desde la izquierda. Hacia la derecha
|
||||||
X3_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, EXTRALARGE, 30
|
X3_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, EXTRALARGE, 0.5000
|
||||||
X3_0, 1, DEFAULT_POS_Y, RIGHT, BALLOON, EXTRALARGE, 15
|
X3_0, 1, DEFAULT_POS_Y, RIGHT, BALLOON, EXTRALARGE, 0.2500
|
||||||
X3_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, EXTRALARGE, 0
|
X3_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, EXTRALARGE, 0.0000
|
||||||
|
|
||||||
formation: 11
|
formation: 11
|
||||||
# Tres enemigos BALLOON3 seguidos desde la derecha. Hacia la izquierda
|
# Tres enemigos BALLOON3 seguidos desde la derecha. Hacia la izquierda
|
||||||
X3_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, EXTRALARGE, 30
|
X3_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, EXTRALARGE, 0.5000
|
||||||
X3_100, -1, DEFAULT_POS_Y, LEFT, BALLOON, EXTRALARGE, 15
|
X3_100, -1, DEFAULT_POS_Y, LEFT, BALLOON, EXTRALARGE, 0.2500
|
||||||
X3_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, EXTRALARGE, 0
|
X3_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, EXTRALARGE, 0.0000
|
||||||
|
|
||||||
formation: 12
|
formation: 12
|
||||||
# Seis enemigos BALLOON1 uno detrás del otro. A la izquierda y hacia el centro
|
# Seis enemigos BALLOON1 uno detrás del otro. A la izquierda y hacia el centro
|
||||||
X1_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 50
|
X1_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 0.8333
|
||||||
X1_0, 1, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 40
|
X1_0, 1, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 0.6667
|
||||||
X1_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 30
|
X1_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 0.5000
|
||||||
X1_0, 3, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 20
|
X1_0, 3, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 0.3333
|
||||||
X1_0, 4, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 10
|
X1_0, 4, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 0.1667
|
||||||
X1_0, 5, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 0
|
X1_0, 5, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 0.0000
|
||||||
|
|
||||||
formation: 13
|
formation: 13
|
||||||
# Seis enemigos BALLOON1 uno detrás del otro. A la derecha y hacia el centro
|
# Seis enemigos BALLOON1 uno detrás del otro. A la derecha y hacia el centro
|
||||||
X1_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 50
|
X1_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 0.8333
|
||||||
X1_100, -1, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 40
|
X1_100, -1, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 0.6667
|
||||||
X1_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 30
|
X1_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 0.5000
|
||||||
X1_100, -3, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 20
|
X1_100, -3, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 0.3333
|
||||||
X1_100, -4, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 10
|
X1_100, -4, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 0.1667
|
||||||
X1_100, -5, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 0
|
X1_100, -5, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 0.0000
|
||||||
|
|
||||||
formation: 14
|
formation: 14
|
||||||
# Cinco enemigos BALLOON2. Hacia la derecha. Separados
|
# Cinco enemigos BALLOON2. Hacia la derecha. Separados
|
||||||
X2_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 40
|
X2_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.6667
|
||||||
X2_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 30
|
X2_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.5000
|
||||||
X2_0, 4, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 20
|
X2_0, 4, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.3333
|
||||||
X2_0, 6, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 10
|
X2_0, 6, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.1667
|
||||||
X2_0, 8, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0
|
X2_0, 8, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.0000
|
||||||
|
|
||||||
formation: 15
|
formation: 15
|
||||||
# Cinco enemigos BALLOON2. Hacia la izquierda. Separados
|
# Cinco enemigos BALLOON2. Hacia la izquierda. Separados
|
||||||
X2_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 40
|
X2_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.6667
|
||||||
X2_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 30
|
X2_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.5000
|
||||||
X2_100, -4, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 20
|
X2_100, -4, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.3333
|
||||||
X2_100, -6, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 10
|
X2_100, -6, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.1667
|
||||||
X2_100, -8, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0
|
X2_100, -8, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.0000
|
||||||
|
|
||||||
formation: 16
|
formation: 16
|
||||||
# Cinco enemigos BALLOON2. Hacia la derecha. Juntos
|
# Cinco enemigos BALLOON2. Hacia la derecha. Juntos
|
||||||
X2_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 40
|
X2_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.6667
|
||||||
X2_0, 1, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 30
|
X2_0, 1, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.5000
|
||||||
X2_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 20
|
X2_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.3333
|
||||||
X2_0, 3, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 10
|
X2_0, 3, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.1667
|
||||||
X2_0, 4, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0
|
X2_0, 4, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.0000
|
||||||
|
|
||||||
formation: 17
|
formation: 17
|
||||||
# Cinco enemigos BALLOON2. Hacia la izquierda. Juntos
|
# Cinco enemigos BALLOON2. Hacia la izquierda. Juntos
|
||||||
X2_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 40
|
X2_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.6667
|
||||||
X2_100, -1, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 30
|
X2_100, -1, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.5000
|
||||||
X2_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 20
|
X2_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.3333
|
||||||
X2_100, -3, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 10
|
X2_100, -3, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.1667
|
||||||
X2_100, -4, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0
|
X2_100, -4, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.0000
|
||||||
|
|
||||||
formation: 18
|
formation: 18
|
||||||
# Doce enemigos BALLOON0. Hacia la derecha. Juntos
|
# Doce enemigos BALLOON0. Hacia la derecha. Juntos
|
||||||
X0_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 110
|
X0_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 1.8333
|
||||||
X0_0, 1, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 100
|
X0_0, 1, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 1.6667
|
||||||
X0_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 90
|
X0_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 1.5000
|
||||||
X0_0, 3, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 80
|
X0_0, 3, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 1.3333
|
||||||
X0_0, 4, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 70
|
X0_0, 4, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 1.1667
|
||||||
X0_0, 5, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 60
|
X0_0, 5, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 1.0000
|
||||||
X0_0, 6, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 50
|
X0_0, 6, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.8333
|
||||||
X0_0, 7, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 40
|
X0_0, 7, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.6667
|
||||||
X0_0, 8, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 30
|
X0_0, 8, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.5000
|
||||||
X0_0, 9, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 20
|
X0_0, 9, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.3333
|
||||||
X0_0, 10, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 10
|
X0_0, 10, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.1667
|
||||||
X0_0, 11, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0
|
X0_0, 11, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.0000
|
||||||
|
|
||||||
formation: 19
|
formation: 19
|
||||||
# Doce enemigos BALLOON0. Hacia la izquierda. Juntos
|
# Doce enemigos BALLOON0. Hacia la izquierda. Juntos
|
||||||
X0_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 110
|
X0_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 1.8333
|
||||||
X0_100, -1, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 100
|
X0_100, -1, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 1.6667
|
||||||
X0_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 90
|
X0_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 1.5000
|
||||||
X0_100, -3, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 80
|
X0_100, -3, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 1.3333
|
||||||
X0_100, -4, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 70
|
X0_100, -4, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 1.1667
|
||||||
X0_100, -5, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 60
|
X0_100, -5, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 1.0000
|
||||||
X0_100, -6, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 50
|
X0_100, -6, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.8333
|
||||||
X0_100, -7, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 40
|
X0_100, -7, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.6667
|
||||||
X0_100, -8, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 30
|
X0_100, -8, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.5000
|
||||||
X0_100, -9, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 20
|
X0_100, -9, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.3333
|
||||||
X0_100, -10, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 10
|
X0_100, -10, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.1667
|
||||||
X0_100, -11, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0
|
X0_100, -11, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.0000
|
||||||
|
|
||||||
formation: 20
|
formation: 20
|
||||||
# Cuatro enemigos BALLOON3 seguidos desde la izquierda/derecha. Simétricos
|
# Cuatro enemigos BALLOON3 seguidos desde la izquierda/derecha. Simétricos
|
||||||
X3_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, EXTRALARGE, 0
|
X3_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, EXTRALARGE, 0.0000
|
||||||
X3_0, 1, DEFAULT_POS_Y, RIGHT, BALLOON, EXTRALARGE, 0
|
X3_0, 1, DEFAULT_POS_Y, RIGHT, BALLOON, EXTRALARGE, 0.0000
|
||||||
X3_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, EXTRALARGE, 0
|
X3_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, EXTRALARGE, 0.0000
|
||||||
X3_100, -1, DEFAULT_POS_Y, LEFT, BALLOON, EXTRALARGE, 0
|
X3_100, -1, DEFAULT_POS_Y, LEFT, BALLOON, EXTRALARGE, 0.0000
|
||||||
|
|
||||||
formation: 21
|
formation: 21
|
||||||
# Diez enemigos BALLOON1 uno detrás del otro. Izquierda/derecha. Simétricos
|
# Diez enemigos BALLOON1 uno detrás del otro. Izquierda/derecha. Simétricos
|
||||||
X1_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 12
|
X1_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 0.2000
|
||||||
X1_0, 1, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 9
|
X1_0, 1, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 0.1500
|
||||||
X1_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 6
|
X1_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 0.1000
|
||||||
X1_0, 3, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 3
|
X1_0, 3, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 0.0500
|
||||||
X1_0, 4, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 0
|
X1_0, 4, DEFAULT_POS_Y, RIGHT, BALLOON, MEDIUM, 0.0000
|
||||||
X1_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 12
|
X1_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 0.2000
|
||||||
X1_100, -1, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 9
|
X1_100, -1, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 0.1500
|
||||||
X1_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 6
|
X1_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 0.1000
|
||||||
X1_100, -3, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 3
|
X1_100, -3, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 0.0500
|
||||||
X1_100, -4, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 0
|
X1_100, -4, DEFAULT_POS_Y, LEFT, BALLOON, MEDIUM, 0.0000
|
||||||
|
|
||||||
formation: 22
|
formation: 22
|
||||||
# Diez enemigos BALLOON2. Hacia la derecha/izquierda. Separados. Simétricos
|
# Diez enemigos BALLOON2. Hacia la derecha/izquierda. Separados. Simétricos
|
||||||
X2_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 40
|
X2_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.6667
|
||||||
X2_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 30
|
X2_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.5000
|
||||||
X2_0, 4, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 20
|
X2_0, 4, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.3333
|
||||||
X2_0, 6, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 10
|
X2_0, 6, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.1667
|
||||||
X2_0, 8, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0
|
X2_0, 8, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.0000
|
||||||
X2_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 40
|
X2_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.6667
|
||||||
X2_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 30
|
X2_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.5000
|
||||||
X2_100, -4, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 20
|
X2_100, -4, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.3333
|
||||||
X2_100, -6, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 10
|
X2_100, -6, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.1667
|
||||||
X2_100, -8, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0
|
X2_100, -8, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.0000
|
||||||
|
|
||||||
formation: 23
|
formation: 23
|
||||||
# Diez enemigos BALLOON2. Hacia la derecha. Juntos. Simétricos
|
# Diez enemigos BALLOON2. Hacia la derecha. Juntos. Simétricos
|
||||||
X2_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 40
|
X2_0, 0, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.6667
|
||||||
X2_0, 1, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 30
|
X2_0, 1, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.5000
|
||||||
X2_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 20
|
X2_0, 2, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.3333
|
||||||
X2_0, 3, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 10
|
X2_0, 3, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.1667
|
||||||
X2_0, 4, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0
|
X2_0, 4, DEFAULT_POS_Y, RIGHT, BALLOON, LARGE, 0.0000
|
||||||
X2_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 40
|
X2_100, 0, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.6667
|
||||||
X2_100, -1, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 30
|
X2_100, -1, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.5000
|
||||||
X2_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 20
|
X2_100, -2, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.3333
|
||||||
X2_100, -3, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 10
|
X2_100, -3, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.1667
|
||||||
X2_100, -4, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0
|
X2_100, -4, DEFAULT_POS_Y, LEFT, BALLOON, LARGE, 0.0000
|
||||||
|
|
||||||
formation: 24
|
formation: 24
|
||||||
# Treinta enemigos BALLOON0. Del centro hacia los extremos. Juntos. Simétricos
|
# Treinta enemigos BALLOON0. Del centro hacia los extremos. Juntos. Simétricos
|
||||||
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0
|
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.0000
|
||||||
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 5
|
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.0833
|
||||||
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 10
|
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.1667
|
||||||
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 15
|
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.2500
|
||||||
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 20
|
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.3333
|
||||||
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 25
|
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.4167
|
||||||
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 30
|
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.5000
|
||||||
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 35
|
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.5833
|
||||||
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 40
|
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.6667
|
||||||
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 45
|
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.7500
|
||||||
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 50
|
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.8333
|
||||||
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 55
|
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.9167
|
||||||
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 60
|
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 1.0000
|
||||||
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 65
|
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 1.0833
|
||||||
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 70
|
X0_50, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 1.1667
|
||||||
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0
|
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.0000
|
||||||
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 5
|
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.0833
|
||||||
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 10
|
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.1667
|
||||||
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 15
|
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.2500
|
||||||
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 20
|
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.3333
|
||||||
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 25
|
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.4167
|
||||||
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 30
|
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.5000
|
||||||
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 35
|
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.5833
|
||||||
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 40
|
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.6667
|
||||||
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 45
|
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.7500
|
||||||
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 50
|
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.8333
|
||||||
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 55
|
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.9167
|
||||||
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 60
|
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 1.0000
|
||||||
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 65
|
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 1.0833
|
||||||
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 70
|
X0_50, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 1.1667
|
||||||
|
|
||||||
formation: 25
|
formation: 25
|
||||||
# Treinta enemigos BALLOON0. Del centro hacia adentro. Juntos. Simétricos
|
# Treinta enemigos BALLOON0. Del centro hacia adentro. Juntos. Simétricos
|
||||||
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 70
|
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 1.1667
|
||||||
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 65
|
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 1.0833
|
||||||
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 60
|
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 1.0000
|
||||||
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 55
|
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.9167
|
||||||
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 50
|
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.8333
|
||||||
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 45
|
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.7500
|
||||||
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 40
|
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.6667
|
||||||
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 35
|
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.5833
|
||||||
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 30
|
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.5000
|
||||||
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 25
|
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.4167
|
||||||
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 20
|
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.3333
|
||||||
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 15
|
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.2500
|
||||||
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 10
|
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.1667
|
||||||
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 5
|
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.0833
|
||||||
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0
|
X0_50 + 20, 0, DEFAULT_POS_Y, LEFT, BALLOON, SMALL, 0.0000
|
||||||
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 70
|
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 1.1667
|
||||||
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 65
|
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 1.0833
|
||||||
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 60
|
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 1.0000
|
||||||
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 55
|
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.9167
|
||||||
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 50
|
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.8333
|
||||||
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 45
|
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.7500
|
||||||
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 40
|
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.6667
|
||||||
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 35
|
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.5833
|
||||||
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 30
|
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.5000
|
||||||
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 25
|
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.4167
|
||||||
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 20
|
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.3333
|
||||||
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 15
|
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.2500
|
||||||
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 10
|
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.1667
|
||||||
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 5
|
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.0833
|
||||||
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0
|
X0_50 - 20, 0, DEFAULT_POS_Y, RIGHT, BALLOON, SMALL, 0.0000
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
# Formato: PARAMETRO VALOR
|
# Formato: PARAMETRO VALOR
|
||||||
|
|
||||||
# --- GAME ---
|
# --- GAME ---
|
||||||
game.item_size 20 # Tamaño de los items del juego (en píxeles)
|
|
||||||
game.item_text_outline_color E0E0E0F0 # Color del outline del texto de los items (RGBA hex)
|
game.item_text_outline_color E0E0E0F0 # Color del outline del texto de los items (RGBA hex)
|
||||||
game.width 320 # Ancho de la resolución nativa del juego (en píxeles)
|
game.width 320 # Ancho de la resolución nativa del juego (en píxeles)
|
||||||
game.height 240 # Alto de la resolución nativa del juego (en píxeles)
|
game.height 240 # Alto de la resolución nativa del juego (en píxeles)
|
||||||
@@ -12,8 +11,6 @@ game.play_area.rect.w 320 # Ancho de la zona jugable
|
|||||||
game.play_area.rect.h 200 # Alto de la zona jugable
|
game.play_area.rect.h 200 # Alto de la zona jugable
|
||||||
game.name_entry_idle_time 10 # Segundos para introducir el nombre al finalizar la partida si no se pulsa nada
|
game.name_entry_idle_time 10 # Segundos para introducir el nombre al finalizar la partida si no se pulsa nada
|
||||||
game.name_entry_total_time 60 # Segundos totales para introducir el nombre al finalizar la partida
|
game.name_entry_total_time 60 # Segundos totales para introducir el nombre al finalizar la partida
|
||||||
game.hit_stop false # Indica si debe haber un paro cuando el jugador es golpeado por un globo
|
|
||||||
game.hit_stop_ms 500 # Cantidad de milisegundos que dura el hit_stop
|
|
||||||
|
|
||||||
# --- FADE ---
|
# --- FADE ---
|
||||||
fade.color 1F2B30 # Color hexadecimal para el efecto de fundido
|
fade.color 1F2B30 # Color hexadecimal para el efecto de fundido
|
||||||
@@ -39,24 +36,24 @@ scoreboard.text_color2 FFFFFF # Color secundario del texto del marca
|
|||||||
scoreboard.skip_countdown_value 8 # Valor para saltar la cuenta atrás (segundos)
|
scoreboard.skip_countdown_value 8 # Valor para saltar la cuenta atrás (segundos)
|
||||||
|
|
||||||
# --- TITLE ---
|
# --- TITLE ---
|
||||||
title.press_start_position 180 # Posición Y del texto "Press Start"
|
title.press_start_position 180 # Posición Y del texto "Press Start"
|
||||||
title.title_duration 800 # Duración de la pantalla de título (frames)
|
title.title_duration 14 # Duración de la pantalla de título (segundos)
|
||||||
title.arcade_edition_position 123 # Posición Y del subtítulo "Arcade Edition"
|
title.arcade_edition_position 123 # Posición Y del subtítulo "Arcade Edition"
|
||||||
title.title_c_c_position 80 # Posición Y del título principal
|
title.title_c_c_position 80 # Posición Y del título principal
|
||||||
title.bg_color 41526F # Color de fondo en la sección titulo
|
title.bg_color 41526F # Color de fondo en la sección titulo
|
||||||
|
|
||||||
# --- BACKGROUND ---
|
# --- BACKGROUND ---
|
||||||
background.attenuate_color FFFFFF00 # Color de atenuación del fondo (RGBA hexadecimal)
|
background.attenuate_color FFFFFF00 # Color de atenuación del fondo (RGBA hexadecimal)
|
||||||
|
|
||||||
# --- BALLOONS ---
|
# --- BALLOONS --- (deltaTime en segundos: vel en pixels/s, grav en pixels/s²)
|
||||||
balloon.settings[0].vel 2.75f # Velocidad inicial del globo 1
|
balloon.settings[0].vel 165.0f # Velocidad inicial del globo 1 (pixels/s)
|
||||||
balloon.settings[0].grav 0.09f # Gravedad aplicada al globo 1
|
balloon.settings[0].grav 320.0f # Gravedad aplicada al globo 1 (pixels/s²)
|
||||||
balloon.settings[1].vel 3.70f # Velocidad inicial del globo 2
|
balloon.settings[1].vel 222.0f # Velocidad inicial del globo 2 (pixels/s)
|
||||||
balloon.settings[1].grav 0.10f # Gravedad aplicada al globo 2
|
balloon.settings[1].grav 360.0f # Gravedad aplicada al globo 2 (pixels/s²)
|
||||||
balloon.settings[2].vel 4.70f # Velocidad inicial del globo 3
|
balloon.settings[2].vel 282.0f # Velocidad inicial del globo 3 (pixels/s)
|
||||||
balloon.settings[2].grav 0.10f # Gravedad aplicada al globo 3
|
balloon.settings[2].grav 360.0f # Gravedad aplicada al globo 3 (pixels/s²)
|
||||||
balloon.settings[3].vel 5.45f # Velocidad inicial del globo 4
|
balloon.settings[3].vel 327.0f # Velocidad inicial del globo 4 (pixels/s)
|
||||||
balloon.settings[3].grav 0.10f # Gravedad aplicada al globo 4
|
balloon.settings[3].grav 360.0f # Gravedad aplicada al globo 4 (pixels/s²)
|
||||||
|
|
||||||
balloon.color[0] blue # Color de creación del globo normal
|
balloon.color[0] blue # Color de creación del globo normal
|
||||||
balloon.color[1] orange # Color del globo normal
|
balloon.color[1] orange # Color del globo normal
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
# Formato: PARAMETRO VALOR
|
# Formato: PARAMETRO VALOR
|
||||||
|
|
||||||
# --- GAME ---
|
# --- GAME ---
|
||||||
game.item_size 20 # Tamaño de los items del juego (en píxeles)
|
|
||||||
game.item_text_outline_color E0E0E0F0 # Color del outline del texto de los items (RGBA hex)
|
game.item_text_outline_color E0E0E0F0 # Color del outline del texto de los items (RGBA hex)
|
||||||
game.width 320 # Ancho de la resolución nativa del juego (en píxeles)
|
game.width 320 # Ancho de la resolución nativa del juego (en píxeles)
|
||||||
game.height 256 # Alto de la resolución nativa del juego (en píxeles)
|
game.height 256 # Alto de la resolución nativa del juego (en píxeles)
|
||||||
@@ -12,8 +11,6 @@ game.play_area.rect.w 320 # Ancho de la zona jugable
|
|||||||
game.play_area.rect.h 216 # Alto de la zona jugable
|
game.play_area.rect.h 216 # Alto de la zona jugable
|
||||||
game.name_entry_idle_time 10 # Segundos para introducir el nombre al finalizar la partida si no se pulsa nada
|
game.name_entry_idle_time 10 # Segundos para introducir el nombre al finalizar la partida si no se pulsa nada
|
||||||
game.name_entry_total_time 60 # Segundos totales para introducir el nombre al finalizar la partida
|
game.name_entry_total_time 60 # Segundos totales para introducir el nombre al finalizar la partida
|
||||||
game.hit_stop false # Indica si debe haber un paro cuando el jugador es golpeado por un globo
|
|
||||||
game.hit_stop_ms 500 # Cantidad de milisegundos que dura el hit_stop
|
|
||||||
|
|
||||||
# --- FADE ---
|
# --- FADE ---
|
||||||
fade.color 1F2B30 # Color hexadecimal para el efecto de fundido
|
fade.color 1F2B30 # Color hexadecimal para el efecto de fundido
|
||||||
@@ -39,24 +36,24 @@ scoreboard.text_color2 FFFFFF # Color secundario del texto del marca
|
|||||||
scoreboard.skip_countdown_value 8 # Valor para saltar la cuenta atrás (segundos)
|
scoreboard.skip_countdown_value 8 # Valor para saltar la cuenta atrás (segundos)
|
||||||
|
|
||||||
# --- TITLE ---
|
# --- TITLE ---
|
||||||
title.press_start_position 180 # Posición Y del texto "Press Start"
|
title.press_start_position 180 # Posición Y del texto "Press Start"
|
||||||
title.title_duration 800 # Duración de la pantalla de título (frames)
|
title.title_duration 14 # Duración de la pantalla de título (segundos)
|
||||||
title.arcade_edition_position 123 # Posición Y del subtítulo "Arcade Edition"
|
title.arcade_edition_position 123 # Posición Y del subtítulo "Arcade Edition"
|
||||||
title.title_c_c_position 80 # Posición Y del título principal
|
title.title_c_c_position 80 # Posición Y del título principal
|
||||||
title.bg_color 41526F # Color de fondo en la sección titulo
|
title.bg_color 41526F # Color de fondo en la sección titulo
|
||||||
|
|
||||||
# --- BACKGROUND ---
|
# --- BACKGROUND ---
|
||||||
background.attenuate_color FFFFFF00 # Color de atenuación del fondo (RGBA hexadecimal)
|
background.attenuate_color FFFFFF00 # Color de atenuación del fondo (RGBA hexadecimal)
|
||||||
|
|
||||||
# --- BALLOONS ---
|
# --- BALLOONS --- (deltaTime en segundos: vel en pixels/s, grav en pixels/s²)
|
||||||
balloon.settings[0].vel 2.75f # Velocidad inicial del globo 1
|
balloon.settings[0].vel 165.0f # Velocidad inicial del globo 1 (pixels/s)
|
||||||
balloon.settings[0].grav 0.09f # Gravedad aplicada al globo 1
|
balloon.settings[0].grav 320.0f # Gravedad aplicada al globo 1 (pixels/s²)
|
||||||
balloon.settings[1].vel 3.70f # Velocidad inicial del globo 2
|
balloon.settings[1].vel 222.0f # Velocidad inicial del globo 2 (pixels/s)
|
||||||
balloon.settings[1].grav 0.10f # Gravedad aplicada al globo 2
|
balloon.settings[1].grav 360.0f # Gravedad aplicada al globo 2 (pixels/s²)
|
||||||
balloon.settings[2].vel 4.70f # Velocidad inicial del globo 3
|
balloon.settings[2].vel 282.0f # Velocidad inicial del globo 3 (pixels/s)
|
||||||
balloon.settings[2].grav 0.10f # Gravedad aplicada al globo 3
|
balloon.settings[2].grav 360.0f # Gravedad aplicada al globo 3 (pixels/s²)
|
||||||
balloon.settings[3].vel 5.45f # Velocidad inicial del globo 4
|
balloon.settings[3].vel 327.0f # Velocidad inicial del globo 4 (pixels/s)
|
||||||
balloon.settings[3].grav 0.10f # Gravedad aplicada al globo 4
|
balloon.settings[3].grav 360.0f # Gravedad aplicada al globo 4 (pixels/s²)
|
||||||
|
|
||||||
balloon.color[0] blue # Color de creación del globo normal
|
balloon.color[0] blue # Color de creación del globo normal
|
||||||
balloon.color[1] orange # Color del globo normal
|
balloon.color[1] orange # Color del globo normal
|
||||||
|
|||||||
@@ -4,31 +4,31 @@
|
|||||||
# Los pools no necesitan estar ordenados ni ser consecutivos
|
# Los pools no necesitan estar ordenados ni ser consecutivos
|
||||||
|
|
||||||
# Pool para la fase 1
|
# Pool para la fase 1
|
||||||
POOL: 0 FORMATIONS: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
POOL: 0 FORMATIONS: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
||||||
|
|
||||||
# Pool para la fase 2
|
# Pool para la fase 2
|
||||||
POOL: 1 FORMATIONS: 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
|
POOL: 1 FORMATIONS: 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
|
||||||
|
|
||||||
# Pool para la fase 3
|
# Pool para la fase 3
|
||||||
POOL: 2 FORMATIONS: 0, 1, 2, 3, 4, 55, 56, 57, 58, 59
|
POOL: 2 FORMATIONS: 0, 1, 2, 3, 4, 55, 56, 57, 58, 59
|
||||||
|
|
||||||
# Pool para la fase 4
|
# Pool para la fase 4
|
||||||
POOL: 3 FORMATIONS: 50, 51, 52, 53, 54, 5, 6, 7, 8, 9
|
POOL: 3 FORMATIONS: 50, 51, 52, 53, 54, 5, 6, 7, 8, 9
|
||||||
|
|
||||||
# Pool para la fase 5
|
# Pool para la fase 5
|
||||||
POOL: 4 FORMATIONS: 60, 61, 62, 63, 64, 65, 66, 67, 68, 69
|
POOL: 4 FORMATIONS: 60, 61, 62, 63, 64, 65, 66, 67, 68, 69
|
||||||
|
|
||||||
# Pool para la fase 6
|
# Pool para la fase 6
|
||||||
POOL: 5 FORMATIONS: 10, 61, 12, 63, 14, 65, 16, 67, 18, 69
|
POOL: 5 FORMATIONS: 10, 61, 12, 63, 14, 65, 16, 67, 18, 69
|
||||||
|
|
||||||
# Pool para la fase 7
|
# Pool para la fase 7
|
||||||
POOL: 6 FORMATIONS: 60, 11, 62, 13, 64, 15, 66, 17, 68, 19
|
POOL: 6 FORMATIONS: 60, 11, 62, 13, 64, 15, 66, 17, 68, 19
|
||||||
|
|
||||||
# Pool para la fase 8
|
# Pool para la fase 8
|
||||||
POOL: 7 FORMATIONS: 20, 21, 22, 23, 24, 65, 66, 67, 68, 69
|
POOL: 7 FORMATIONS: 20, 21, 22, 23, 24, 65, 66, 67, 68, 69
|
||||||
|
|
||||||
# Pool para la fase 9
|
# Pool para la fase 9
|
||||||
POOL: 8 FORMATIONS: 70, 71, 72, 73, 74, 15, 16, 17, 18, 19
|
POOL: 8 FORMATIONS: 70, 71, 72, 73, 74, 15, 16, 17, 18, 19
|
||||||
|
|
||||||
# Pool para la fase 10
|
# Pool para la fase 10
|
||||||
POOL: 9 FORMATIONS: 20, 21, 22, 23, 24, 70, 71, 72, 73, 74
|
POOL: 9 FORMATIONS: 20, 21, 22, 23, 24, 70, 71, 72, 73, 74
|
||||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
BIN
data/demo/demo3.bin
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
data/font/04b_25_2x_white.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -185,7 +185,7 @@
|
|||||||
# 122 z
|
# 122 z
|
||||||
5
|
5
|
||||||
# 123 {
|
# 123 {
|
||||||
3
|
7
|
||||||
# 124 |
|
# 124 |
|
||||||
2
|
2
|
||||||
# 125 }
|
# 125 }
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 872 B After Width: | Height: | Size: 882 B |
@@ -3,28 +3,28 @@ frame_height=10
|
|||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=orange
|
name=orange
|
||||||
speed=10
|
speed=0.1667
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,1,2,3,4,5,6,7,8,9
|
frames=0,1,2,3,4,5,6,7,8,9
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=blue
|
name=blue
|
||||||
speed=20
|
speed=0.3333
|
||||||
loop=0
|
loop=0
|
||||||
frames=10,11,12,13,14,15,16,17,18,19
|
frames=10,11,12,13,14,15,16,17,18,19
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=green
|
name=green
|
||||||
speed=10
|
speed=0.1667
|
||||||
loop=0
|
loop=0
|
||||||
frames=20,21,22,23,24,25,26,27,28,29
|
frames=20,21,22,23,24,25,26,27,28,29
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=red
|
name=red
|
||||||
speed=20
|
speed=0.3333
|
||||||
loop=0
|
loop=0
|
||||||
frames=30,31,32,33,34,35,36,37,38,39
|
frames=30,31,32,33,34,35,36,37,38,39
|
||||||
[/animation]
|
[/animation]
|
||||||
@@ -3,28 +3,28 @@ frame_height=16
|
|||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=orange
|
name=orange
|
||||||
speed=10
|
speed=0.1667
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,1,2,3,4,5,6,7,8,9
|
frames=0,1,2,3,4,5,6,7,8,9
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=blue
|
name=blue
|
||||||
speed=20
|
speed=0.3333
|
||||||
loop=0
|
loop=0
|
||||||
frames=10,11,12,13,14,15,16,17,18,19
|
frames=10,11,12,13,14,15,16,17,18,19
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=green
|
name=green
|
||||||
speed=10
|
speed=0.1667
|
||||||
loop=0
|
loop=0
|
||||||
frames=20,21,22,23,24,25,26,27,28,29
|
frames=20,21,22,23,24,25,26,27,28,29
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=red
|
name=red
|
||||||
speed=20
|
speed=0.3333
|
||||||
loop=0
|
loop=0
|
||||||
frames=30,31,32,33,34,35,36,37,38,39
|
frames=30,31,32,33,34,35,36,37,38,39
|
||||||
[/animation]
|
[/animation]
|
||||||
@@ -3,28 +3,28 @@ frame_height=26
|
|||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=orange
|
name=orange
|
||||||
speed=10
|
speed=0.1667
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,1,2,3,4,5,6,7,8,9
|
frames=0,1,2,3,4,5,6,7,8,9
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=blue
|
name=blue
|
||||||
speed=20
|
speed=0.3333
|
||||||
loop=0
|
loop=0
|
||||||
frames=10,11,12,13,14,15,16,17,18,19
|
frames=10,11,12,13,14,15,16,17,18,19
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=green
|
name=green
|
||||||
speed=10
|
speed=0.1667
|
||||||
loop=0
|
loop=0
|
||||||
frames=20,21,22,23,24,25,26,27,28,29
|
frames=20,21,22,23,24,25,26,27,28,29
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=red
|
name=red
|
||||||
speed=20
|
speed=0.3333
|
||||||
loop=0
|
loop=0
|
||||||
frames=30,31,32,33,34,35,36,37,38,39
|
frames=30,31,32,33,34,35,36,37,38,39
|
||||||
[/animation]
|
[/animation]
|
||||||
@@ -3,28 +3,28 @@ frame_height=48
|
|||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=orange
|
name=orange
|
||||||
speed=10
|
speed=0.1667
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,1,2,3,4,5,6,7,8,9
|
frames=0,1,2,3,4,5,6,7,8,9
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=blue
|
name=blue
|
||||||
speed=20
|
speed=0.3333
|
||||||
loop=0
|
loop=0
|
||||||
frames=10,11,12,13,14,15,16,17,18,19
|
frames=10,11,12,13,14,15,16,17,18,19
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=green
|
name=green
|
||||||
speed=10
|
speed=0.1667
|
||||||
loop=0
|
loop=0
|
||||||
frames=20,21,22,23,24,25,26,27,28,29
|
frames=20,21,22,23,24,25,26,27,28,29
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=red
|
name=red
|
||||||
speed=20
|
speed=0.3333
|
||||||
loop=0
|
loop=0
|
||||||
frames=30,31,32,33,34,35,36,37,38,39
|
frames=30,31,32,33,34,35,36,37,38,39
|
||||||
[/animation]
|
[/animation]
|
||||||
@@ -3,7 +3,7 @@ frame_height=10
|
|||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
speed=5
|
speed=0.0833
|
||||||
loop=-1
|
loop=-1
|
||||||
frames=0,1,2,3,4,5,6,7,8,9
|
frames=0,1,2,3,4,5,6,7,8,9
|
||||||
[/animation]
|
[/animation]
|
||||||
@@ -3,7 +3,7 @@ frame_height=16
|
|||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
speed=5
|
speed=0.0833
|
||||||
loop=-1
|
loop=-1
|
||||||
frames=0,1,2,3,4,5,6,7,8,9
|
frames=0,1,2,3,4,5,6,7,8,9
|
||||||
[/animation]
|
[/animation]
|
||||||
@@ -3,7 +3,7 @@ frame_height=26
|
|||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
speed=5
|
speed=0.0833
|
||||||
loop=-1
|
loop=-1
|
||||||
frames=0,1,2,3,4,5,6,7,8,9
|
frames=0,1,2,3,4,5,6,7,8,9
|
||||||
[/animation]
|
[/animation]
|
||||||
@@ -3,7 +3,7 @@ frame_height=48
|
|||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
speed=5
|
speed=0.0833
|
||||||
loop=-1
|
loop=-1
|
||||||
frames=0,1,2,3,4,5,6,7,8,9
|
frames=0,1,2,3,4,5,6,7,8,9
|
||||||
[/animation]
|
[/animation]
|
||||||
@@ -3,7 +3,7 @@ frame_height=49
|
|||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=powerball
|
name=powerball
|
||||||
speed=10
|
speed=0.0167
|
||||||
loop=-1
|
loop=-1
|
||||||
frames=1
|
frames=1
|
||||||
[/animation]
|
[/animation]
|
||||||
@@ -2,43 +2,85 @@ frame_width=12
|
|||||||
frame_height=12
|
frame_height=12
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=normal_up
|
name=yellow_up
|
||||||
speed=5
|
speed=20
|
||||||
loop=0
|
loop=-1
|
||||||
frames=0,1,2
|
frames=0
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=normal_left
|
name=yellow_left
|
||||||
speed=5
|
speed=20
|
||||||
loop=0
|
loop=-1
|
||||||
frames=3,4,5,5,4,3
|
frames=1
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=normal_right
|
name=yellow_right
|
||||||
speed=5
|
speed=20
|
||||||
loop=0
|
loop=-1
|
||||||
frames=6,7,8,8,7,6
|
frames=2
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=powered_up
|
name=green_up
|
||||||
speed=5
|
speed=20
|
||||||
loop=0
|
loop=-1
|
||||||
frames=9,10,11,11,10,9
|
frames=3
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=powered_left
|
name=green_left
|
||||||
speed=5
|
speed=20
|
||||||
loop=0
|
loop=-1
|
||||||
frames=12,13,14,14,13,12
|
frames=4
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=powered_right
|
name=green_right
|
||||||
speed=5
|
speed=20
|
||||||
loop=0
|
loop=-1
|
||||||
frames=15,16,17,17,26,15
|
frames=5
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=red_up
|
||||||
|
speed=20
|
||||||
|
loop=-1
|
||||||
|
frames=6
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=red_left
|
||||||
|
speed=20
|
||||||
|
loop=-1
|
||||||
|
frames=7
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=red_right
|
||||||
|
speed=20
|
||||||
|
loop=-1
|
||||||
|
frames=8
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=purple_up
|
||||||
|
speed=20
|
||||||
|
loop=-1
|
||||||
|
frames=9
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=purple_left
|
||||||
|
speed=20
|
||||||
|
loop=-1
|
||||||
|
frames=10
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=purple_right
|
||||||
|
speed=20
|
||||||
|
loop=-1
|
||||||
|
frames=11
|
||||||
[/animation]
|
[/animation]
|
||||||
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.7 KiB |
9
data/gfx/game/game_grass.ani
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
frame_width=320
|
||||||
|
frame_height=10
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=default
|
||||||
|
speed=0.2
|
||||||
|
loop=0
|
||||||
|
frames=0,1,2,1
|
||||||
|
[/animation]
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.6 KiB |
@@ -2,8 +2,15 @@ frame_width=20
|
|||||||
frame_height=20
|
frame_height=20
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=blink
|
||||||
speed=8
|
speed=0.2
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,0,1
|
frames=0,1
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=no-blink
|
||||||
|
speed=0
|
||||||
|
loop=-1
|
||||||
|
frames=1
|
||||||
[/animation]
|
[/animation]
|
||||||
@@ -2,8 +2,15 @@ frame_width=20
|
|||||||
frame_height=20
|
frame_height=20
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=blink
|
||||||
speed=8
|
speed=0.2
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,0,1
|
frames=0,1
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=no-blink
|
||||||
|
speed=0
|
||||||
|
loop=-1
|
||||||
|
frames=1
|
||||||
[/animation]
|
[/animation]
|
||||||
@@ -3,7 +3,7 @@ frame_height=39
|
|||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
speed=6
|
speed=0.1
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,1,2,3,4,5,6,7,8
|
frames=0,1,2,3,4,5,6,7,8
|
||||||
[/animation]
|
[/animation]
|
||||||
@@ -2,8 +2,15 @@ frame_width=20
|
|||||||
frame_height=20
|
frame_height=20
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=blink
|
||||||
speed=8
|
speed=0.2
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,0,1
|
frames=0,1
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=no-blink
|
||||||
|
speed=0
|
||||||
|
loop=-1
|
||||||
|
frames=1
|
||||||
[/animation]
|
[/animation]
|
||||||
@@ -2,8 +2,15 @@ frame_width=20
|
|||||||
frame_height=20
|
frame_height=20
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=blink
|
||||||
speed=8
|
speed=0.2
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,0,1
|
frames=0,1
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=no-blink
|
||||||
|
speed=0
|
||||||
|
loop=-1
|
||||||
|
frames=1
|
||||||
[/animation]
|
[/animation]
|
||||||
@@ -2,8 +2,15 @@ frame_width=20
|
|||||||
frame_height=20
|
frame_height=20
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=blink
|
||||||
speed=8
|
speed=0.2
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,0,1
|
frames=0,1
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=no-blink
|
||||||
|
speed=0
|
||||||
|
loop=-1
|
||||||
|
frames=1
|
||||||
[/animation]
|
[/animation]
|
||||||
@@ -2,8 +2,15 @@ frame_width=20
|
|||||||
frame_height=20
|
frame_height=20
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=blink
|
||||||
speed=8
|
speed=0.2
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,0,1
|
frames=0,1
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=no-blink
|
||||||
|
speed=0
|
||||||
|
loop=-1
|
||||||
|
frames=1
|
||||||
[/animation]
|
[/animation]
|
||||||
|
Before Width: | Height: | Size: 717 B After Width: | Height: | Size: 696 B |
|
Before Width: | Height: | Size: 720 B After Width: | Height: | Size: 624 B |
|
Before Width: | Height: | Size: 312 B |
@@ -3,133 +3,133 @@ frame_height=32
|
|||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=walk
|
name=walk
|
||||||
speed=5
|
speed=0.0833
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,1,2,3
|
frames=0,1,2,3
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=stand
|
name=stand
|
||||||
speed=10
|
speed=0.167
|
||||||
loop=0
|
loop=0
|
||||||
frames=4,5,6,7
|
frames=4,5,6,7
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=walk-fire-side
|
name=walk-fire-side
|
||||||
speed=5
|
speed=0.0833
|
||||||
loop=0
|
loop=0
|
||||||
frames=8,9,10,11
|
frames=8,9,10,11
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=walk-recoil-side
|
name=walk-recoil-side
|
||||||
speed=5
|
speed=0.0833
|
||||||
loop=0
|
loop=0
|
||||||
frames=12,13,14,15
|
frames=12,13,14,15
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=walk-cool-side
|
name=walk-cool-side
|
||||||
speed=5
|
speed=0.0833
|
||||||
loop=0
|
loop=0
|
||||||
frames=16,17,18,19
|
frames=16,17,18,19
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=stand-fire-side
|
name=stand-fire-side
|
||||||
speed=5
|
speed=0.0833
|
||||||
loop=0
|
loop=0
|
||||||
frames=20
|
frames=20
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=stand-recoil-side
|
name=stand-recoil-side
|
||||||
speed=5
|
speed=0.0833
|
||||||
loop=0
|
loop=0
|
||||||
frames=21
|
frames=21
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=stand-cool-side
|
name=stand-cool-side
|
||||||
speed=5
|
speed=0.0833
|
||||||
loop=0
|
loop=0
|
||||||
frames=22
|
frames=22
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=walk-fire-center
|
name=walk-fire-center
|
||||||
speed=5
|
speed=0.0833
|
||||||
loop=0
|
loop=0
|
||||||
frames=23,24,25,26
|
frames=23,24,25,26
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=walk-recoil-center
|
name=walk-recoil-center
|
||||||
speed=5
|
speed=0.0833
|
||||||
loop=0
|
loop=0
|
||||||
frames=27,28,29,30
|
frames=27,28,29,30
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=walk-cool-center
|
name=walk-cool-center
|
||||||
speed=5
|
speed=0.0833
|
||||||
loop=0
|
loop=0
|
||||||
frames=31,32,33,34
|
frames=31,32,33,34
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=stand-fire-center
|
name=stand-fire-center
|
||||||
speed=5
|
speed=0.0833
|
||||||
loop=0
|
loop=0
|
||||||
frames=35
|
frames=35
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=stand-recoil-center
|
name=stand-recoil-center
|
||||||
speed=5
|
speed=0.0833
|
||||||
loop=0
|
loop=0
|
||||||
frames=36
|
frames=36
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=stand-cool-center
|
name=stand-cool-center
|
||||||
speed=5
|
speed=0.0833
|
||||||
loop=0
|
loop=0
|
||||||
frames=37
|
frames=37
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=rolling
|
name=rolling
|
||||||
speed=10
|
speed=0.167
|
||||||
loop=0
|
loop=0
|
||||||
frames=38,39,40,41
|
frames=38,39,40,41
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=celebration
|
name=celebration
|
||||||
speed=10
|
speed=0.167
|
||||||
loop=-1
|
loop=0
|
||||||
frames=42,42,42,42,42,42,43,44,45,46,46,46,46,46,46,45,45,45,46,46,46,45,45,45,44,43,42,42,42
|
frames=42,42,42,43,44,45,44,43,42,43,44,45,44,43,42,43,44,45,44,43,42,46,46,46,46,46,46,47,48,49,50,50,50,50,50,50,49,49,49,50,50,50,49,49,49,48,47,46,46,46
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=dizzy
|
name=dizzy
|
||||||
speed=5
|
speed=0.0833
|
||||||
loop=0
|
loop=0
|
||||||
frames=47,48,49,50,51,52,53
|
frames=51,52,53,54,55,56,57
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=recover
|
name=recover
|
||||||
speed=3
|
speed=0.05
|
||||||
loop=-1
|
loop=-1
|
||||||
frames=54,54,54,54,55,56,57,58,58,58,59,60,61,58,59,60,61,58,59,60,61,62,62,62,62
|
frames=58,58,58,58,59,60,61,62,62,62,63,64,65,62,63,64,65,62,63,64,65,66,66,66,66
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=hello
|
name=hello
|
||||||
speed=3
|
speed=0.05
|
||||||
loop=-1
|
loop=-1
|
||||||
frames=63,64,65,66,67,68,69,70,71,72,73,73,73,73,73,73,73,73,73,73,73,73,73,74,75,76,77,78,79,80,81,82,82,81,80,79,79,80,81,82,82,81,80,79,79,80,81,82,82,81,80,79,79,80,81,82,82,81,80,79,78,77,76,75,74,73,72,71,70,69,68,67,66,65,64,63
|
frames=67,68,69,70,71,72,73,74,75,76,77,77,77,77,77,77,77,77,77,77,77,77,77,78,79,80,81,82,83,84,85,86,86,85,84,83,83,84,85,86,86,85,84,83,83,84,85,86,86,85,84,83,83,84,85,86,86,85,84,83,82,81,80,79,78,77,76,75,74,73,72,71,70,69,68,67
|
||||||
[/animation]
|
[/animation]
|
||||||
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
135
data/gfx/player/player2.ani
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
frame_width=32
|
||||||
|
frame_height=32
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=walk
|
||||||
|
speed=0.0833
|
||||||
|
loop=0
|
||||||
|
frames=0,1,2,3
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=stand
|
||||||
|
speed=0.167
|
||||||
|
loop=0
|
||||||
|
frames=4,5,6,7
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=walk-fire-side
|
||||||
|
speed=0.0833
|
||||||
|
loop=0
|
||||||
|
frames=8,9,10,11
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=walk-recoil-side
|
||||||
|
speed=0.0833
|
||||||
|
loop=0
|
||||||
|
frames=12,13,14,15
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=walk-cool-side
|
||||||
|
speed=0.0833
|
||||||
|
loop=0
|
||||||
|
frames=16,17,18,19
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=stand-fire-side
|
||||||
|
speed=0.0833
|
||||||
|
loop=0
|
||||||
|
frames=20
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=stand-recoil-side
|
||||||
|
speed=0.0833
|
||||||
|
loop=0
|
||||||
|
frames=21
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=stand-cool-side
|
||||||
|
speed=0.0833
|
||||||
|
loop=0
|
||||||
|
frames=22
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=walk-fire-center
|
||||||
|
speed=0.0833
|
||||||
|
loop=0
|
||||||
|
frames=23,24,25,26
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=walk-recoil-center
|
||||||
|
speed=0.0833
|
||||||
|
loop=0
|
||||||
|
frames=27,28,29,30
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=walk-cool-center
|
||||||
|
speed=0.0833
|
||||||
|
loop=0
|
||||||
|
frames=31,32,33,34
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=stand-fire-center
|
||||||
|
speed=0.0833
|
||||||
|
loop=0
|
||||||
|
frames=35
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=stand-recoil-center
|
||||||
|
speed=0.0833
|
||||||
|
loop=0
|
||||||
|
frames=36
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=stand-cool-center
|
||||||
|
speed=0.0833
|
||||||
|
loop=0
|
||||||
|
frames=37
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=rolling
|
||||||
|
speed=0.167
|
||||||
|
loop=0
|
||||||
|
frames=38,39,40,41
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=celebration
|
||||||
|
speed=0.167
|
||||||
|
loop=0
|
||||||
|
frames=47,47,47,47,47,47,48,49,50,51,51,51,51,51,51,50,50,50,51,51,51,50,50,50,49,48,47,47,47,42,42,42,43,44,45,46,45,46,45,46,45,46,45,46,45,46,45,44,43,42
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=dizzy
|
||||||
|
speed=0.0833
|
||||||
|
loop=0
|
||||||
|
frames=52,53,54,55,56,57,58
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=recover
|
||||||
|
speed=0.05
|
||||||
|
loop=-1
|
||||||
|
frames=59,59,59,59,60,61,62,63,63,63,64,65,66,63,64,65,66,63,64,65,66,67,67,67,67
|
||||||
|
[/animation]
|
||||||
|
|
||||||
|
[animation]
|
||||||
|
name=hello
|
||||||
|
speed=0.05
|
||||||
|
loop=-1
|
||||||
|
frames=68,69,70,71,72,73,74,75,76,77,78,78,78,78,78,78,78,78,78,78,78,78,78,79,80,81,82,83,84,85,86,87,87,86,85,84,84,85,86,87,87,86,85,84,84,85,86,87,87,86,85,84,84,85,86,87,87,86,85,84,83,82,81,80,79,78,77,76,75,74,73,72,71,70,69,68
|
||||||
|
[/animation]
|
||||||
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
@@ -3,7 +3,7 @@ frame_height=44
|
|||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
speed=5
|
speed=0.0833
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,1,2,3
|
frames=0,1,2,3
|
||||||
[/animation]
|
[/animation]
|
||||||
@@ -3,14 +3,14 @@ frame_height=32
|
|||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=fly
|
name=fly
|
||||||
speed=2
|
speed=0.0333
|
||||||
loop=0
|
loop=0
|
||||||
frames=0,1
|
frames=0,1
|
||||||
[/animation]
|
[/animation]
|
||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=hit
|
name=hit
|
||||||
speed=2
|
speed=0.0333
|
||||||
loop=0
|
loop=0
|
||||||
frames=2,3
|
frames=2,3
|
||||||
[/animation]
|
[/animation]
|
||||||
@@ -3,7 +3,7 @@ frame_height=16
|
|||||||
|
|
||||||
[animation]
|
[animation]
|
||||||
name=default
|
name=default
|
||||||
speed=8
|
speed=0.1333
|
||||||
loop=-1
|
loop=-1
|
||||||
frames=0,1,2,3,4,5,6
|
frames=0,1,2,3,4,5,6
|
||||||
[/animation]
|
[/animation]
|
||||||
@@ -21,12 +21,13 @@
|
|||||||
"[GAME_TEXT] 2": "Queden ",
|
"[GAME_TEXT] 2": "Queden ",
|
||||||
"[GAME_TEXT] 2A": " fases mes!",
|
"[GAME_TEXT] 2A": " fases mes!",
|
||||||
"[GAME_TEXT] 3": "Ultima fase!",
|
"[GAME_TEXT] 3": "Ultima fase!",
|
||||||
"[GAME_TEXT] 4": "SuperPoder!",
|
"[GAME_TEXT] 4": "Automatic!",
|
||||||
"[GAME_TEXT] 5": "+1 Colp",
|
"[GAME_TEXT] 5": "+1 Colp",
|
||||||
"[GAME_TEXT] 6": "Temps!",
|
"[GAME_TEXT] 6": "Temps!",
|
||||||
"[GAME_TEXT] 7": "Endavant!",
|
"[GAME_TEXT] 7": "Endavant!",
|
||||||
"[GAME_TEXT] 8": "1.000.000 de punts!",
|
"[GAME_TEXT] 8": "1.000.000 de punts!",
|
||||||
"[GAME_TEXT] THANK_YOU": "Gracies!",
|
"[GAME_TEXT] THANK_YOU": "Gracies!",
|
||||||
|
"[GAME_TEXT] NEW_RECORD": "Nou record!",
|
||||||
|
|
||||||
"[HIGHSCORE_TABLE] CAPTION": "Millors puntuacions",
|
"[HIGHSCORE_TABLE] CAPTION": "Millors puntuacions",
|
||||||
|
|
||||||
|
|||||||
@@ -20,12 +20,13 @@
|
|||||||
"[GAME_TEXT] 2": "",
|
"[GAME_TEXT] 2": "",
|
||||||
"[GAME_TEXT] 2A": " stages left!",
|
"[GAME_TEXT] 2A": " stages left!",
|
||||||
"[GAME_TEXT] 3": "Last stage!",
|
"[GAME_TEXT] 3": "Last stage!",
|
||||||
"[GAME_TEXT] 4": "PowerUp",
|
"[GAME_TEXT] 4": "AutoFire!",
|
||||||
"[GAME_TEXT] 5": "+1 Hit",
|
"[GAME_TEXT] 5": "+1 Hit",
|
||||||
"[GAME_TEXT] 6": "Stop!",
|
"[GAME_TEXT] 6": "Stop!",
|
||||||
"[GAME_TEXT] 7": "Get Ready!",
|
"[GAME_TEXT] 7": "Get Ready!",
|
||||||
"[GAME_TEXT] 8": "1,000,000 points!",
|
"[GAME_TEXT] 8": "1,000,000 points!",
|
||||||
"[GAME_TEXT] THANK_YOU": "Thank you!",
|
"[GAME_TEXT] THANK_YOU": "Thank you!",
|
||||||
|
"[GAME_TEXT] NEW_RECORD": "New record!",
|
||||||
|
|
||||||
"[HIGHSCORE_TABLE] CAPTION": "Best scores",
|
"[HIGHSCORE_TABLE] CAPTION": "Best scores",
|
||||||
|
|
||||||
|
|||||||
@@ -20,12 +20,13 @@
|
|||||||
"[GAME_TEXT] 2": "!Quedan ",
|
"[GAME_TEXT] 2": "!Quedan ",
|
||||||
"[GAME_TEXT] 2A": " fases!",
|
"[GAME_TEXT] 2A": " fases!",
|
||||||
"[GAME_TEXT] 3": "Ultima fase!",
|
"[GAME_TEXT] 3": "Ultima fase!",
|
||||||
"[GAME_TEXT] 4": "Potenciador",
|
"[GAME_TEXT] 4": "Automatico!",
|
||||||
"[GAME_TEXT] 5": "+1 Golpe",
|
"[GAME_TEXT] 5": "+1 Golpe",
|
||||||
"[GAME_TEXT] 6": "Tiempo!",
|
"[GAME_TEXT] 6": "Tiempo!",
|
||||||
"[GAME_TEXT] 7": "Adelante!",
|
"[GAME_TEXT] 7": "Adelante!",
|
||||||
"[GAME_TEXT] 8": "1.000.000 de puntos!",
|
"[GAME_TEXT] 8": "1.000.000 de puntos!",
|
||||||
"[GAME_TEXT] THANK_YOU": "Gracias!",
|
"[GAME_TEXT] THANK_YOU": "Gracias!",
|
||||||
|
"[GAME_TEXT] NEW_RECORD": "Nuevo record!",
|
||||||
|
|
||||||
"[HIGHSCORE_TABLE] CAPTION": "Mejores puntuaciones",
|
"[HIGHSCORE_TABLE] CAPTION": "Mejores puntuaciones",
|
||||||
|
|
||||||
|
|||||||
BIN
data/music/congratulations.ogg
Normal file
@@ -1,234 +0,0 @@
|
|||||||
/*
|
|
||||||
crt-pi - A Raspberry Pi friendly CRT shader.
|
|
||||||
|
|
||||||
Copyright (C) 2015-2016 davej
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by the Free
|
|
||||||
Software Foundation; either version 2 of the License, or (at your option)
|
|
||||||
any later version.
|
|
||||||
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
|
|
||||||
This shader is designed to work well on Raspberry Pi GPUs (i.e. 1080P @ 60Hz on a game with a 4:3 aspect ratio). It pushes the Pi's GPU hard and enabling some features will slow it down so that it is no longer able to match 1080P @ 60Hz. You will need to overclock your Pi to the fastest setting in raspi-config to get the best results from this shader: 'Pi2' for Pi2 and 'Turbo' for original Pi and Pi Zero. Note: Pi2s are slower at running the shader than other Pis, this seems to be down to Pi2s lower maximum memory speed. Pi2s don't quite manage 1080P @ 60Hz - they drop about 1 in 1000 frames. You probably won't notice this, but if you do, try enabling FAKE_GAMMA.
|
|
||||||
|
|
||||||
SCANLINES enables scanlines. You'll almost certainly want to use it with MULTISAMPLE to reduce moire effects. SCANLINE_WEIGHT defines how wide scanlines are (it is an inverse value so a higher number = thinner lines). SCANLINE_GAP_BRIGHTNESS defines how dark the gaps between the scan lines are. Darker gaps between scan lines make moire effects more likely.
|
|
||||||
|
|
||||||
GAMMA enables gamma correction using the values in INPUT_GAMMA and OUTPUT_GAMMA. FAKE_GAMMA causes it to ignore the values in INPUT_GAMMA and OUTPUT_GAMMA and approximate gamma correction in a way which is faster than true gamma whilst still looking better than having none. You must have GAMMA defined to enable FAKE_GAMMA.
|
|
||||||
|
|
||||||
CURVATURE distorts the screen by CURVATURE_X and CURVATURE_Y. Curvature slows things down a lot.
|
|
||||||
|
|
||||||
By default the shader uses linear blending horizontally. If you find this too blury, enable SHARPER.
|
|
||||||
|
|
||||||
BLOOM_FACTOR controls the increase in width for bright scanlines.
|
|
||||||
|
|
||||||
MASK_TYPE defines what, if any, shadow mask to use. MASK_BRIGHTNESS defines how much the mask type darkens the screen.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma parameter CURVATURE_X "Screen curvature - horizontal" 0.10 0.0 1.0 0.01
|
|
||||||
#pragma parameter CURVATURE_Y "Screen curvature - vertical" 0.15 0.0 1.0 0.01
|
|
||||||
#pragma parameter MASK_BRIGHTNESS "Mask brightness" 0.70 0.0 1.0 0.01
|
|
||||||
#pragma parameter SCANLINE_WEIGHT "Scanline weight" 6.0 0.0 15.0 0.1
|
|
||||||
#pragma parameter SCANLINE_GAP_BRIGHTNESS "Scanline gap brightness" 0.12 0.0 1.0 0.01
|
|
||||||
#pragma parameter BLOOM_FACTOR "Bloom factor" 1.5 0.0 5.0 0.01
|
|
||||||
#pragma parameter INPUT_GAMMA "Input gamma" 2.4 0.0 5.0 0.01
|
|
||||||
#pragma parameter OUTPUT_GAMMA "Output gamma" 2.2 0.0 5.0 0.01
|
|
||||||
|
|
||||||
// Haven't put these as parameters as it would slow the code down.
|
|
||||||
#define SCANLINES
|
|
||||||
#define MULTISAMPLE
|
|
||||||
#define GAMMA
|
|
||||||
//#define FAKE_GAMMA
|
|
||||||
//#define CURVATURE
|
|
||||||
//#define SHARPER
|
|
||||||
// MASK_TYPE: 0 = none, 1 = green/magenta, 2 = trinitron(ish)
|
|
||||||
#define MASK_TYPE 2
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef GL_ES
|
|
||||||
#define COMPAT_PRECISION mediump
|
|
||||||
precision mediump float;
|
|
||||||
#else
|
|
||||||
#define COMPAT_PRECISION
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PARAMETER_UNIFORM
|
|
||||||
uniform COMPAT_PRECISION float CURVATURE_X;
|
|
||||||
uniform COMPAT_PRECISION float CURVATURE_Y;
|
|
||||||
uniform COMPAT_PRECISION float MASK_BRIGHTNESS;
|
|
||||||
uniform COMPAT_PRECISION float SCANLINE_WEIGHT;
|
|
||||||
uniform COMPAT_PRECISION float SCANLINE_GAP_BRIGHTNESS;
|
|
||||||
uniform COMPAT_PRECISION float BLOOM_FACTOR;
|
|
||||||
uniform COMPAT_PRECISION float INPUT_GAMMA;
|
|
||||||
uniform COMPAT_PRECISION float OUTPUT_GAMMA;
|
|
||||||
#else
|
|
||||||
#define CURVATURE_X 0.05
|
|
||||||
#define CURVATURE_Y 0.1
|
|
||||||
#define MASK_BRIGHTNESS 0.80
|
|
||||||
#define SCANLINE_WEIGHT 6.0
|
|
||||||
#define SCANLINE_GAP_BRIGHTNESS 0.12
|
|
||||||
#define BLOOM_FACTOR 3.5
|
|
||||||
#define INPUT_GAMMA 2.4
|
|
||||||
#define OUTPUT_GAMMA 2.2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* COMPATIBILITY
|
|
||||||
- GLSL compilers
|
|
||||||
*/
|
|
||||||
|
|
||||||
//uniform vec2 TextureSize;
|
|
||||||
#if defined(CURVATURE)
|
|
||||||
varying vec2 screenScale;
|
|
||||||
#endif
|
|
||||||
varying vec2 TEX0;
|
|
||||||
varying float filterWidth;
|
|
||||||
|
|
||||||
#if defined(VERTEX)
|
|
||||||
//uniform mat4 MVPMatrix;
|
|
||||||
//attribute vec4 VertexCoord;
|
|
||||||
//attribute vec2 TexCoord;
|
|
||||||
//uniform vec2 InputSize;
|
|
||||||
//uniform vec2 OutputSize;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
#if defined(CURVATURE)
|
|
||||||
screenScale = vec2(1.0, 1.0); //TextureSize / InputSize;
|
|
||||||
#endif
|
|
||||||
filterWidth = (768.0 / 240.0) / 3.0;
|
|
||||||
TEX0 = vec2(gl_MultiTexCoord0.x, 1.0-gl_MultiTexCoord0.y)*1.0001;
|
|
||||||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
|
||||||
}
|
|
||||||
#elif defined(FRAGMENT)
|
|
||||||
|
|
||||||
uniform sampler2D Texture;
|
|
||||||
|
|
||||||
#if defined(CURVATURE)
|
|
||||||
vec2 Distort(vec2 coord)
|
|
||||||
{
|
|
||||||
vec2 CURVATURE_DISTORTION = vec2(CURVATURE_X, CURVATURE_Y);
|
|
||||||
// Barrel distortion shrinks the display area a bit, this will allow us to counteract that.
|
|
||||||
vec2 barrelScale = 1.0 - (0.23 * CURVATURE_DISTORTION);
|
|
||||||
coord *= screenScale;
|
|
||||||
coord -= vec2(0.5);
|
|
||||||
float rsq = coord.x * coord.x + coord.y * coord.y;
|
|
||||||
coord += coord * (CURVATURE_DISTORTION * rsq);
|
|
||||||
coord *= barrelScale;
|
|
||||||
if (abs(coord.x) >= 0.5 || abs(coord.y) >= 0.5)
|
|
||||||
coord = vec2(-1.0); // If out of bounds, return an invalid value.
|
|
||||||
else
|
|
||||||
{
|
|
||||||
coord += vec2(0.5);
|
|
||||||
coord /= screenScale;
|
|
||||||
}
|
|
||||||
|
|
||||||
return coord;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
float CalcScanLineWeight(float dist)
|
|
||||||
{
|
|
||||||
return max(1.0-dist*dist*SCANLINE_WEIGHT, SCANLINE_GAP_BRIGHTNESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
float CalcScanLine(float dy)
|
|
||||||
{
|
|
||||||
float scanLineWeight = CalcScanLineWeight(dy);
|
|
||||||
#if defined(MULTISAMPLE)
|
|
||||||
scanLineWeight += CalcScanLineWeight(dy-filterWidth);
|
|
||||||
scanLineWeight += CalcScanLineWeight(dy+filterWidth);
|
|
||||||
scanLineWeight *= 0.3333333;
|
|
||||||
#endif
|
|
||||||
return scanLineWeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
vec2 TextureSize = vec2(320.0, 240.0);
|
|
||||||
#if defined(CURVATURE)
|
|
||||||
vec2 texcoord = Distort(TEX0);
|
|
||||||
if (texcoord.x < 0.0)
|
|
||||||
gl_FragColor = vec4(0.0);
|
|
||||||
else
|
|
||||||
#else
|
|
||||||
vec2 texcoord = TEX0;
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
vec2 texcoordInPixels = texcoord * TextureSize;
|
|
||||||
#if defined(SHARPER)
|
|
||||||
vec2 tempCoord = floor(texcoordInPixels) + 0.5;
|
|
||||||
vec2 coord = tempCoord / TextureSize;
|
|
||||||
vec2 deltas = texcoordInPixels - tempCoord;
|
|
||||||
float scanLineWeight = CalcScanLine(deltas.y);
|
|
||||||
vec2 signs = sign(deltas);
|
|
||||||
deltas.x *= 2.0;
|
|
||||||
deltas = deltas * deltas;
|
|
||||||
deltas.y = deltas.y * deltas.y;
|
|
||||||
deltas.x *= 0.5;
|
|
||||||
deltas.y *= 8.0;
|
|
||||||
deltas /= TextureSize;
|
|
||||||
deltas *= signs;
|
|
||||||
vec2 tc = coord + deltas;
|
|
||||||
#else
|
|
||||||
float tempY = floor(texcoordInPixels.y) + 0.5;
|
|
||||||
float yCoord = tempY / TextureSize.y;
|
|
||||||
float dy = texcoordInPixels.y - tempY;
|
|
||||||
float scanLineWeight = CalcScanLine(dy);
|
|
||||||
float signY = sign(dy);
|
|
||||||
dy = dy * dy;
|
|
||||||
dy = dy * dy;
|
|
||||||
dy *= 8.0;
|
|
||||||
dy /= TextureSize.y;
|
|
||||||
dy *= signY;
|
|
||||||
vec2 tc = vec2(texcoord.x, yCoord + dy);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
vec3 colour = texture2D(Texture, tc).rgb;
|
|
||||||
|
|
||||||
#if defined(SCANLINES)
|
|
||||||
#if defined(GAMMA)
|
|
||||||
#if defined(FAKE_GAMMA)
|
|
||||||
colour = colour * colour;
|
|
||||||
#else
|
|
||||||
colour = pow(colour, vec3(INPUT_GAMMA));
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
scanLineWeight *= BLOOM_FACTOR;
|
|
||||||
colour *= scanLineWeight;
|
|
||||||
|
|
||||||
#if defined(GAMMA)
|
|
||||||
#if defined(FAKE_GAMMA)
|
|
||||||
colour = sqrt(colour);
|
|
||||||
#else
|
|
||||||
colour = pow(colour, vec3(1.0/OUTPUT_GAMMA));
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if MASK_TYPE == 0
|
|
||||||
gl_FragColor = vec4(colour, 1.0);
|
|
||||||
#else
|
|
||||||
#if MASK_TYPE == 1
|
|
||||||
float whichMask = fract((gl_FragCoord.x*1.0001) * 0.5);
|
|
||||||
vec3 mask;
|
|
||||||
if (whichMask < 0.5)
|
|
||||||
mask = vec3(MASK_BRIGHTNESS, 1.0, MASK_BRIGHTNESS);
|
|
||||||
else
|
|
||||||
mask = vec3(1.0, MASK_BRIGHTNESS, 1.0);
|
|
||||||
#elif MASK_TYPE == 2
|
|
||||||
float whichMask = fract((gl_FragCoord.x*1.0001) * 0.3333333);
|
|
||||||
vec3 mask = vec3(MASK_BRIGHTNESS, MASK_BRIGHTNESS, MASK_BRIGHTNESS);
|
|
||||||
if (whichMask < 0.3333333)
|
|
||||||
mask.x = 1.0;
|
|
||||||
else if (whichMask < 0.6666666)
|
|
||||||
mask.y = 1.0;
|
|
||||||
else
|
|
||||||
mask.z = 1.0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gl_FragColor = vec4(colour * mask, 1.0);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -1,234 +0,0 @@
|
|||||||
/*
|
|
||||||
crt-pi - A Raspberry Pi friendly CRT shader.
|
|
||||||
|
|
||||||
Copyright (C) 2015-2016 davej
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by the Free
|
|
||||||
Software Foundation; either version 2 of the License, or (at your option)
|
|
||||||
any later version.
|
|
||||||
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
|
|
||||||
This shader is designed to work well on Raspberry Pi GPUs (i.e. 1080P @ 60Hz on a game with a 4:3 aspect ratio). It pushes the Pi's GPU hard and enabling some features will slow it down so that it is no longer able to match 1080P @ 60Hz. You will need to overclock your Pi to the fastest setting in raspi-config to get the best results from this shader: 'Pi2' for Pi2 and 'Turbo' for original Pi and Pi Zero. Note: Pi2s are slower at running the shader than other Pis, this seems to be down to Pi2s lower maximum memory speed. Pi2s don't quite manage 1080P @ 60Hz - they drop about 1 in 1000 frames. You probably won't notice this, but if you do, try enabling FAKE_GAMMA.
|
|
||||||
|
|
||||||
SCANLINES enables scanlines. You'll almost certainly want to use it with MULTISAMPLE to reduce moire effects. SCANLINE_WEIGHT defines how wide scanlines are (it is an inverse value so a higher number = thinner lines). SCANLINE_GAP_BRIGHTNESS defines how dark the gaps between the scan lines are. Darker gaps between scan lines make moire effects more likely.
|
|
||||||
|
|
||||||
GAMMA enables gamma correction using the values in INPUT_GAMMA and OUTPUT_GAMMA. FAKE_GAMMA causes it to ignore the values in INPUT_GAMMA and OUTPUT_GAMMA and approximate gamma correction in a way which is faster than true gamma whilst still looking better than having none. You must have GAMMA defined to enable FAKE_GAMMA.
|
|
||||||
|
|
||||||
CURVATURE distorts the screen by CURVATURE_X and CURVATURE_Y. Curvature slows things down a lot.
|
|
||||||
|
|
||||||
By default the shader uses linear blending horizontally. If you find this too blury, enable SHARPER.
|
|
||||||
|
|
||||||
BLOOM_FACTOR controls the increase in width for bright scanlines.
|
|
||||||
|
|
||||||
MASK_TYPE defines what, if any, shadow mask to use. MASK_BRIGHTNESS defines how much the mask type darkens the screen.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma parameter CURVATURE_X "Screen curvature - horizontal" 0.10 0.0 1.0 0.01
|
|
||||||
#pragma parameter CURVATURE_Y "Screen curvature - vertical" 0.15 0.0 1.0 0.01
|
|
||||||
#pragma parameter MASK_BRIGHTNESS "Mask brightness" 0.70 0.0 1.0 0.01
|
|
||||||
#pragma parameter SCANLINE_WEIGHT "Scanline weight" 6.0 0.0 15.0 0.1
|
|
||||||
#pragma parameter SCANLINE_GAP_BRIGHTNESS "Scanline gap brightness" 0.12 0.0 1.0 0.01
|
|
||||||
#pragma parameter BLOOM_FACTOR "Bloom factor" 1.5 0.0 5.0 0.01
|
|
||||||
#pragma parameter INPUT_GAMMA "Input gamma" 2.4 0.0 5.0 0.01
|
|
||||||
#pragma parameter OUTPUT_GAMMA "Output gamma" 2.2 0.0 5.0 0.01
|
|
||||||
|
|
||||||
// Haven't put these as parameters as it would slow the code down.
|
|
||||||
#define SCANLINES
|
|
||||||
#define MULTISAMPLE
|
|
||||||
#define GAMMA
|
|
||||||
//#define FAKE_GAMMA
|
|
||||||
//#define CURVATURE
|
|
||||||
//#define SHARPER
|
|
||||||
// MASK_TYPE: 0 = none, 1 = green/magenta, 2 = trinitron(ish)
|
|
||||||
#define MASK_TYPE 2
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef GL_ES
|
|
||||||
#define COMPAT_PRECISION mediump
|
|
||||||
precision mediump float;
|
|
||||||
#else
|
|
||||||
#define COMPAT_PRECISION
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PARAMETER_UNIFORM
|
|
||||||
uniform COMPAT_PRECISION float CURVATURE_X;
|
|
||||||
uniform COMPAT_PRECISION float CURVATURE_Y;
|
|
||||||
uniform COMPAT_PRECISION float MASK_BRIGHTNESS;
|
|
||||||
uniform COMPAT_PRECISION float SCANLINE_WEIGHT;
|
|
||||||
uniform COMPAT_PRECISION float SCANLINE_GAP_BRIGHTNESS;
|
|
||||||
uniform COMPAT_PRECISION float BLOOM_FACTOR;
|
|
||||||
uniform COMPAT_PRECISION float INPUT_GAMMA;
|
|
||||||
uniform COMPAT_PRECISION float OUTPUT_GAMMA;
|
|
||||||
#else
|
|
||||||
#define CURVATURE_X 0.05
|
|
||||||
#define CURVATURE_Y 0.1
|
|
||||||
#define MASK_BRIGHTNESS 0.80
|
|
||||||
#define SCANLINE_WEIGHT 6.0
|
|
||||||
#define SCANLINE_GAP_BRIGHTNESS 0.12
|
|
||||||
#define BLOOM_FACTOR 3.5
|
|
||||||
#define INPUT_GAMMA 2.4
|
|
||||||
#define OUTPUT_GAMMA 2.2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* COMPATIBILITY
|
|
||||||
- GLSL compilers
|
|
||||||
*/
|
|
||||||
|
|
||||||
//uniform vec2 TextureSize;
|
|
||||||
#if defined(CURVATURE)
|
|
||||||
varying vec2 screenScale;
|
|
||||||
#endif
|
|
||||||
varying vec2 TEX0;
|
|
||||||
varying float filterWidth;
|
|
||||||
|
|
||||||
#if defined(VERTEX)
|
|
||||||
//uniform mat4 MVPMatrix;
|
|
||||||
//attribute vec4 VertexCoord;
|
|
||||||
//attribute vec2 TexCoord;
|
|
||||||
//uniform vec2 InputSize;
|
|
||||||
//uniform vec2 OutputSize;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
#if defined(CURVATURE)
|
|
||||||
screenScale = vec2(1.0, 1.0); //TextureSize / InputSize;
|
|
||||||
#endif
|
|
||||||
filterWidth = (768.0 / 256.0) / 3.0;
|
|
||||||
TEX0 = vec2(gl_MultiTexCoord0.x, 1.0-gl_MultiTexCoord0.y)*1.0001;
|
|
||||||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
|
||||||
}
|
|
||||||
#elif defined(FRAGMENT)
|
|
||||||
|
|
||||||
uniform sampler2D Texture;
|
|
||||||
|
|
||||||
#if defined(CURVATURE)
|
|
||||||
vec2 Distort(vec2 coord)
|
|
||||||
{
|
|
||||||
vec2 CURVATURE_DISTORTION = vec2(CURVATURE_X, CURVATURE_Y);
|
|
||||||
// Barrel distortion shrinks the display area a bit, this will allow us to counteract that.
|
|
||||||
vec2 barrelScale = 1.0 - (0.23 * CURVATURE_DISTORTION);
|
|
||||||
coord *= screenScale;
|
|
||||||
coord -= vec2(0.5);
|
|
||||||
float rsq = coord.x * coord.x + coord.y * coord.y;
|
|
||||||
coord += coord * (CURVATURE_DISTORTION * rsq);
|
|
||||||
coord *= barrelScale;
|
|
||||||
if (abs(coord.x) >= 0.5 || abs(coord.y) >= 0.5)
|
|
||||||
coord = vec2(-1.0); // If out of bounds, return an invalid value.
|
|
||||||
else
|
|
||||||
{
|
|
||||||
coord += vec2(0.5);
|
|
||||||
coord /= screenScale;
|
|
||||||
}
|
|
||||||
|
|
||||||
return coord;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
float CalcScanLineWeight(float dist)
|
|
||||||
{
|
|
||||||
return max(1.0-dist*dist*SCANLINE_WEIGHT, SCANLINE_GAP_BRIGHTNESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
float CalcScanLine(float dy)
|
|
||||||
{
|
|
||||||
float scanLineWeight = CalcScanLineWeight(dy);
|
|
||||||
#if defined(MULTISAMPLE)
|
|
||||||
scanLineWeight += CalcScanLineWeight(dy-filterWidth);
|
|
||||||
scanLineWeight += CalcScanLineWeight(dy+filterWidth);
|
|
||||||
scanLineWeight *= 0.3333333;
|
|
||||||
#endif
|
|
||||||
return scanLineWeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
vec2 TextureSize = vec2(320.0, 256.0);
|
|
||||||
#if defined(CURVATURE)
|
|
||||||
vec2 texcoord = Distort(TEX0);
|
|
||||||
if (texcoord.x < 0.0)
|
|
||||||
gl_FragColor = vec4(0.0);
|
|
||||||
else
|
|
||||||
#else
|
|
||||||
vec2 texcoord = TEX0;
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
vec2 texcoordInPixels = texcoord * TextureSize;
|
|
||||||
#if defined(SHARPER)
|
|
||||||
vec2 tempCoord = floor(texcoordInPixels) + 0.5;
|
|
||||||
vec2 coord = tempCoord / TextureSize;
|
|
||||||
vec2 deltas = texcoordInPixels - tempCoord;
|
|
||||||
float scanLineWeight = CalcScanLine(deltas.y);
|
|
||||||
vec2 signs = sign(deltas);
|
|
||||||
deltas.x *= 2.0;
|
|
||||||
deltas = deltas * deltas;
|
|
||||||
deltas.y = deltas.y * deltas.y;
|
|
||||||
deltas.x *= 0.5;
|
|
||||||
deltas.y *= 8.0;
|
|
||||||
deltas /= TextureSize;
|
|
||||||
deltas *= signs;
|
|
||||||
vec2 tc = coord + deltas;
|
|
||||||
#else
|
|
||||||
float tempY = floor(texcoordInPixels.y) + 0.5;
|
|
||||||
float yCoord = tempY / TextureSize.y;
|
|
||||||
float dy = texcoordInPixels.y - tempY;
|
|
||||||
float scanLineWeight = CalcScanLine(dy);
|
|
||||||
float signY = sign(dy);
|
|
||||||
dy = dy * dy;
|
|
||||||
dy = dy * dy;
|
|
||||||
dy *= 8.0;
|
|
||||||
dy /= TextureSize.y;
|
|
||||||
dy *= signY;
|
|
||||||
vec2 tc = vec2(texcoord.x, yCoord + dy);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
vec3 colour = texture2D(Texture, tc).rgb;
|
|
||||||
|
|
||||||
#if defined(SCANLINES)
|
|
||||||
#if defined(GAMMA)
|
|
||||||
#if defined(FAKE_GAMMA)
|
|
||||||
colour = colour * colour;
|
|
||||||
#else
|
|
||||||
colour = pow(colour, vec3(INPUT_GAMMA));
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
scanLineWeight *= BLOOM_FACTOR;
|
|
||||||
colour *= scanLineWeight;
|
|
||||||
|
|
||||||
#if defined(GAMMA)
|
|
||||||
#if defined(FAKE_GAMMA)
|
|
||||||
colour = sqrt(colour);
|
|
||||||
#else
|
|
||||||
colour = pow(colour, vec3(1.0/OUTPUT_GAMMA));
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if MASK_TYPE == 0
|
|
||||||
gl_FragColor = vec4(colour, 1.0);
|
|
||||||
#else
|
|
||||||
#if MASK_TYPE == 1
|
|
||||||
float whichMask = fract((gl_FragCoord.x*1.0001) * 0.5);
|
|
||||||
vec3 mask;
|
|
||||||
if (whichMask < 0.5)
|
|
||||||
mask = vec3(MASK_BRIGHTNESS, 1.0, MASK_BRIGHTNESS);
|
|
||||||
else
|
|
||||||
mask = vec3(1.0, MASK_BRIGHTNESS, 1.0);
|
|
||||||
#elif MASK_TYPE == 2
|
|
||||||
float whichMask = fract((gl_FragCoord.x*1.0001) * 0.3333333);
|
|
||||||
vec3 mask = vec3(MASK_BRIGHTNESS, MASK_BRIGHTNESS, MASK_BRIGHTNESS);
|
|
||||||
if (whichMask < 0.3333333)
|
|
||||||
mask.x = 1.0;
|
|
||||||
else if (whichMask < 0.6666666)
|
|
||||||
mask.y = 1.0;
|
|
||||||
else
|
|
||||||
mask.z = 1.0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gl_FragColor = vec4(colour * mask, 1.0);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
157
data/shaders/crtpi_fragment.glsl
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
#version 330 core
|
||||||
|
|
||||||
|
// Configuración
|
||||||
|
#define SCANLINES
|
||||||
|
#define MULTISAMPLE
|
||||||
|
#define GAMMA
|
||||||
|
//#define FAKE_GAMMA
|
||||||
|
//#define CURVATURE
|
||||||
|
//#define SHARPER
|
||||||
|
#define MASK_TYPE 2
|
||||||
|
|
||||||
|
#define CURVATURE_X 0.05
|
||||||
|
#define CURVATURE_Y 0.1
|
||||||
|
#define MASK_BRIGHTNESS 0.80
|
||||||
|
#define SCANLINE_WEIGHT 6.0
|
||||||
|
#define SCANLINE_GAP_BRIGHTNESS 0.12
|
||||||
|
#define BLOOM_FACTOR 3.5
|
||||||
|
#define INPUT_GAMMA 2.4
|
||||||
|
#define OUTPUT_GAMMA 2.2
|
||||||
|
|
||||||
|
// Inputs desde vertex shader
|
||||||
|
in vec2 vTexCoord;
|
||||||
|
in float vFilterWidth;
|
||||||
|
#if defined(CURVATURE)
|
||||||
|
in vec2 vScreenScale;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Output
|
||||||
|
out vec4 FragColor;
|
||||||
|
|
||||||
|
// Uniforms
|
||||||
|
uniform sampler2D Texture;
|
||||||
|
uniform vec2 TextureSize;
|
||||||
|
|
||||||
|
#if defined(CURVATURE)
|
||||||
|
vec2 Distort(vec2 coord)
|
||||||
|
{
|
||||||
|
vec2 CURVATURE_DISTORTION = vec2(CURVATURE_X, CURVATURE_Y);
|
||||||
|
vec2 barrelScale = 1.0 - (0.23 * CURVATURE_DISTORTION);
|
||||||
|
coord *= vScreenScale;
|
||||||
|
coord -= vec2(0.5);
|
||||||
|
float rsq = coord.x * coord.x + coord.y * coord.y;
|
||||||
|
coord += coord * (CURVATURE_DISTORTION * rsq);
|
||||||
|
coord *= barrelScale;
|
||||||
|
if (abs(coord.x) >= 0.5 || abs(coord.y) >= 0.5)
|
||||||
|
coord = vec2(-1.0);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
coord += vec2(0.5);
|
||||||
|
coord /= vScreenScale;
|
||||||
|
}
|
||||||
|
return coord;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
float CalcScanLineWeight(float dist)
|
||||||
|
{
|
||||||
|
return max(1.0 - dist * dist * SCANLINE_WEIGHT, SCANLINE_GAP_BRIGHTNESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
float CalcScanLine(float dy)
|
||||||
|
{
|
||||||
|
float scanLineWeight = CalcScanLineWeight(dy);
|
||||||
|
#if defined(MULTISAMPLE)
|
||||||
|
scanLineWeight += CalcScanLineWeight(dy - vFilterWidth);
|
||||||
|
scanLineWeight += CalcScanLineWeight(dy + vFilterWidth);
|
||||||
|
scanLineWeight *= 0.3333333;
|
||||||
|
#endif
|
||||||
|
return scanLineWeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
#if defined(CURVATURE)
|
||||||
|
vec2 texcoord = Distort(vTexCoord);
|
||||||
|
if (texcoord.x < 0.0) {
|
||||||
|
FragColor = vec4(0.0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
vec2 texcoord = vTexCoord;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
vec2 texcoordInPixels = texcoord * TextureSize;
|
||||||
|
|
||||||
|
#if defined(SHARPER)
|
||||||
|
vec2 tempCoord = floor(texcoordInPixels) + 0.5;
|
||||||
|
vec2 coord = tempCoord / TextureSize;
|
||||||
|
vec2 deltas = texcoordInPixels - tempCoord;
|
||||||
|
float scanLineWeight = CalcScanLine(deltas.y);
|
||||||
|
vec2 signs = sign(deltas);
|
||||||
|
deltas.x *= 2.0;
|
||||||
|
deltas = deltas * deltas;
|
||||||
|
deltas.y = deltas.y * deltas.y;
|
||||||
|
deltas.x *= 0.5;
|
||||||
|
deltas.y *= 8.0;
|
||||||
|
deltas /= TextureSize;
|
||||||
|
deltas *= signs;
|
||||||
|
vec2 tc = coord + deltas;
|
||||||
|
#else
|
||||||
|
float tempY = floor(texcoordInPixels.y) + 0.5;
|
||||||
|
float yCoord = tempY / TextureSize.y;
|
||||||
|
float dy = texcoordInPixels.y - tempY;
|
||||||
|
float scanLineWeight = CalcScanLine(dy);
|
||||||
|
float signY = sign(dy);
|
||||||
|
dy = dy * dy;
|
||||||
|
dy = dy * dy;
|
||||||
|
dy *= 8.0;
|
||||||
|
dy /= TextureSize.y;
|
||||||
|
dy *= signY;
|
||||||
|
vec2 tc = vec2(texcoord.x, yCoord + dy);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
vec3 colour = texture(Texture, tc).rgb;
|
||||||
|
|
||||||
|
#if defined(SCANLINES)
|
||||||
|
#if defined(GAMMA)
|
||||||
|
#if defined(FAKE_GAMMA)
|
||||||
|
colour = colour * colour;
|
||||||
|
#else
|
||||||
|
colour = pow(colour, vec3(INPUT_GAMMA));
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
scanLineWeight *= BLOOM_FACTOR;
|
||||||
|
colour *= scanLineWeight;
|
||||||
|
|
||||||
|
#if defined(GAMMA)
|
||||||
|
#if defined(FAKE_GAMMA)
|
||||||
|
colour = sqrt(colour);
|
||||||
|
#else
|
||||||
|
colour = pow(colour, vec3(1.0 / OUTPUT_GAMMA));
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MASK_TYPE == 0
|
||||||
|
FragColor = vec4(colour, 1.0);
|
||||||
|
#elif MASK_TYPE == 1
|
||||||
|
float whichMask = fract(gl_FragCoord.x * 0.5);
|
||||||
|
vec3 mask;
|
||||||
|
if (whichMask < 0.5)
|
||||||
|
mask = vec3(MASK_BRIGHTNESS, 1.0, MASK_BRIGHTNESS);
|
||||||
|
else
|
||||||
|
mask = vec3(1.0, MASK_BRIGHTNESS, 1.0);
|
||||||
|
FragColor = vec4(colour * mask, 1.0);
|
||||||
|
#elif MASK_TYPE == 2
|
||||||
|
float whichMask = fract(gl_FragCoord.x * 0.3333333);
|
||||||
|
vec3 mask = vec3(MASK_BRIGHTNESS, MASK_BRIGHTNESS, MASK_BRIGHTNESS);
|
||||||
|
if (whichMask < 0.3333333)
|
||||||
|
mask.x = 1.0;
|
||||||
|
else if (whichMask < 0.6666666)
|
||||||
|
mask.y = 1.0;
|
||||||
|
else
|
||||||
|
mask.z = 1.0;
|
||||||
|
FragColor = vec4(colour * mask, 1.0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
160
data/shaders/crtpi_fragment_es.glsl
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
#version 300 es
|
||||||
|
|
||||||
|
// OpenGL ES 3.0 - Compatible con Raspberry Pi 5
|
||||||
|
precision highp float;
|
||||||
|
|
||||||
|
// Configuración
|
||||||
|
#define SCANLINES
|
||||||
|
#define MULTISAMPLE
|
||||||
|
#define GAMMA
|
||||||
|
//#define FAKE_GAMMA
|
||||||
|
//#define CURVATURE
|
||||||
|
//#define SHARPER
|
||||||
|
#define MASK_TYPE 2
|
||||||
|
|
||||||
|
#define CURVATURE_X 0.05
|
||||||
|
#define CURVATURE_Y 0.1
|
||||||
|
#define MASK_BRIGHTNESS 0.80
|
||||||
|
#define SCANLINE_WEIGHT 6.0
|
||||||
|
#define SCANLINE_GAP_BRIGHTNESS 0.12
|
||||||
|
#define BLOOM_FACTOR 3.5
|
||||||
|
#define INPUT_GAMMA 2.4
|
||||||
|
#define OUTPUT_GAMMA 2.2
|
||||||
|
|
||||||
|
// Inputs desde vertex shader
|
||||||
|
in vec2 vTexCoord;
|
||||||
|
in float vFilterWidth;
|
||||||
|
#if defined(CURVATURE)
|
||||||
|
in vec2 vScreenScale;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Output
|
||||||
|
out vec4 FragColor;
|
||||||
|
|
||||||
|
// Uniforms
|
||||||
|
uniform sampler2D Texture;
|
||||||
|
uniform vec2 TextureSize;
|
||||||
|
|
||||||
|
#if defined(CURVATURE)
|
||||||
|
vec2 Distort(vec2 coord)
|
||||||
|
{
|
||||||
|
vec2 CURVATURE_DISTORTION = vec2(CURVATURE_X, CURVATURE_Y);
|
||||||
|
vec2 barrelScale = vec2(1.0) - (0.23 * CURVATURE_DISTORTION);
|
||||||
|
coord *= vScreenScale;
|
||||||
|
coord -= vec2(0.5);
|
||||||
|
float rsq = coord.x * coord.x + coord.y * coord.y;
|
||||||
|
coord += coord * (CURVATURE_DISTORTION * rsq);
|
||||||
|
coord *= barrelScale;
|
||||||
|
if (abs(coord.x) >= 0.5 || abs(coord.y) >= 0.5)
|
||||||
|
coord = vec2(-1.0);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
coord += vec2(0.5);
|
||||||
|
coord /= vScreenScale;
|
||||||
|
}
|
||||||
|
return coord;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
float CalcScanLineWeight(float dist)
|
||||||
|
{
|
||||||
|
return max(1.0 - dist * dist * SCANLINE_WEIGHT, SCANLINE_GAP_BRIGHTNESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
float CalcScanLine(float dy)
|
||||||
|
{
|
||||||
|
float scanLineWeight = CalcScanLineWeight(dy);
|
||||||
|
#if defined(MULTISAMPLE)
|
||||||
|
scanLineWeight += CalcScanLineWeight(dy - vFilterWidth);
|
||||||
|
scanLineWeight += CalcScanLineWeight(dy + vFilterWidth);
|
||||||
|
scanLineWeight *= 0.3333333;
|
||||||
|
#endif
|
||||||
|
return scanLineWeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
#if defined(CURVATURE)
|
||||||
|
vec2 texcoord = Distort(vTexCoord);
|
||||||
|
if (texcoord.x < 0.0) {
|
||||||
|
FragColor = vec4(0.0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
vec2 texcoord = vTexCoord;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
vec2 texcoordInPixels = texcoord * TextureSize;
|
||||||
|
|
||||||
|
#if defined(SHARPER)
|
||||||
|
vec2 tempCoord = floor(texcoordInPixels) + vec2(0.5);
|
||||||
|
vec2 coord = tempCoord / TextureSize;
|
||||||
|
vec2 deltas = texcoordInPixels - tempCoord;
|
||||||
|
float scanLineWeight = CalcScanLine(deltas.y);
|
||||||
|
vec2 signs = sign(deltas);
|
||||||
|
deltas.x *= 2.0;
|
||||||
|
deltas = deltas * deltas;
|
||||||
|
deltas.y = deltas.y * deltas.y;
|
||||||
|
deltas.x *= 0.5;
|
||||||
|
deltas.y *= 8.0;
|
||||||
|
deltas /= TextureSize;
|
||||||
|
deltas *= signs;
|
||||||
|
vec2 tc = coord + deltas;
|
||||||
|
#else
|
||||||
|
float tempY = floor(texcoordInPixels.y) + 0.5;
|
||||||
|
float yCoord = tempY / TextureSize.y;
|
||||||
|
float dy = texcoordInPixels.y - tempY;
|
||||||
|
float scanLineWeight = CalcScanLine(dy);
|
||||||
|
float signY = sign(dy);
|
||||||
|
dy = dy * dy;
|
||||||
|
dy = dy * dy;
|
||||||
|
dy *= 8.0;
|
||||||
|
dy /= TextureSize.y;
|
||||||
|
dy *= signY;
|
||||||
|
vec2 tc = vec2(texcoord.x, yCoord + dy);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
vec3 colour = texture(Texture, tc).rgb;
|
||||||
|
|
||||||
|
#if defined(SCANLINES)
|
||||||
|
#if defined(GAMMA)
|
||||||
|
#if defined(FAKE_GAMMA)
|
||||||
|
colour = colour * colour;
|
||||||
|
#else
|
||||||
|
colour = pow(colour, vec3(INPUT_GAMMA));
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
scanLineWeight *= BLOOM_FACTOR;
|
||||||
|
colour *= scanLineWeight;
|
||||||
|
|
||||||
|
#if defined(GAMMA)
|
||||||
|
#if defined(FAKE_GAMMA)
|
||||||
|
colour = sqrt(colour);
|
||||||
|
#else
|
||||||
|
colour = pow(colour, vec3(1.0 / OUTPUT_GAMMA));
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MASK_TYPE == 0
|
||||||
|
FragColor = vec4(colour, 1.0);
|
||||||
|
#elif MASK_TYPE == 1
|
||||||
|
float whichMask = fract(gl_FragCoord.x * 0.5);
|
||||||
|
vec3 mask;
|
||||||
|
if (whichMask < 0.5)
|
||||||
|
mask = vec3(MASK_BRIGHTNESS, 1.0, MASK_BRIGHTNESS);
|
||||||
|
else
|
||||||
|
mask = vec3(1.0, MASK_BRIGHTNESS, 1.0);
|
||||||
|
FragColor = vec4(colour * mask, 1.0);
|
||||||
|
#elif MASK_TYPE == 2
|
||||||
|
float whichMask = fract(gl_FragCoord.x * 0.3333333);
|
||||||
|
vec3 mask = vec3(MASK_BRIGHTNESS, MASK_BRIGHTNESS, MASK_BRIGHTNESS);
|
||||||
|
if (whichMask < 0.3333333)
|
||||||
|
mask.x = 1.0;
|
||||||
|
else if (whichMask < 0.6666666)
|
||||||
|
mask.y = 1.0;
|
||||||
|
else
|
||||||
|
mask.z = 1.0;
|
||||||
|
FragColor = vec4(colour * mask, 1.0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
48
data/shaders/crtpi_vertex.glsl
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#version 330 core
|
||||||
|
|
||||||
|
// Configuración
|
||||||
|
#define SCANLINES
|
||||||
|
#define MULTISAMPLE
|
||||||
|
#define GAMMA
|
||||||
|
//#define FAKE_GAMMA
|
||||||
|
//#define CURVATURE
|
||||||
|
//#define SHARPER
|
||||||
|
#define MASK_TYPE 2
|
||||||
|
|
||||||
|
#define CURVATURE_X 0.05
|
||||||
|
#define CURVATURE_Y 0.1
|
||||||
|
#define MASK_BRIGHTNESS 0.80
|
||||||
|
#define SCANLINE_WEIGHT 6.0
|
||||||
|
#define SCANLINE_GAP_BRIGHTNESS 0.12
|
||||||
|
#define BLOOM_FACTOR 3.5
|
||||||
|
#define INPUT_GAMMA 2.4
|
||||||
|
#define OUTPUT_GAMMA 2.2
|
||||||
|
|
||||||
|
// Inputs (desde VAO)
|
||||||
|
layout(location = 0) in vec2 aPosition;
|
||||||
|
layout(location = 1) in vec2 aTexCoord;
|
||||||
|
|
||||||
|
// Outputs al fragment shader
|
||||||
|
out vec2 vTexCoord;
|
||||||
|
out float vFilterWidth;
|
||||||
|
#if defined(CURVATURE)
|
||||||
|
out vec2 vScreenScale;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Uniforms
|
||||||
|
uniform vec2 TextureSize;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
#if defined(CURVATURE)
|
||||||
|
vScreenScale = vec2(1.0, 1.0);
|
||||||
|
#endif
|
||||||
|
// Calcula filterWidth dinámicamente basándose en la altura de la textura
|
||||||
|
vFilterWidth = (768.0 / TextureSize.y) / 3.0;
|
||||||
|
|
||||||
|
// Pasar coordenadas de textura (invertir Y para SDL)
|
||||||
|
vTexCoord = vec2(aTexCoord.x, 1.0 - aTexCoord.y) * 1.0001;
|
||||||
|
|
||||||
|
// Posición del vértice (ya en espacio de clip [-1, 1])
|
||||||
|
gl_Position = vec4(aPosition, 0.0, 1.0);
|
||||||
|
}
|
||||||
51
data/shaders/crtpi_vertex_es.glsl
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#version 300 es
|
||||||
|
|
||||||
|
// OpenGL ES 3.0 - Compatible con Raspberry Pi 5
|
||||||
|
precision highp float;
|
||||||
|
|
||||||
|
// Configuración
|
||||||
|
#define SCANLINES
|
||||||
|
#define MULTISAMPLE
|
||||||
|
#define GAMMA
|
||||||
|
//#define FAKE_GAMMA
|
||||||
|
//#define CURVATURE
|
||||||
|
//#define SHARPER
|
||||||
|
#define MASK_TYPE 2
|
||||||
|
|
||||||
|
#define CURVATURE_X 0.05
|
||||||
|
#define CURVATURE_Y 0.1
|
||||||
|
#define MASK_BRIGHTNESS 0.80
|
||||||
|
#define SCANLINE_WEIGHT 6.0
|
||||||
|
#define SCANLINE_GAP_BRIGHTNESS 0.12
|
||||||
|
#define BLOOM_FACTOR 3.5
|
||||||
|
#define INPUT_GAMMA 2.4
|
||||||
|
#define OUTPUT_GAMMA 2.2
|
||||||
|
|
||||||
|
// Inputs (desde VAO)
|
||||||
|
layout(location = 0) in vec2 aPosition;
|
||||||
|
layout(location = 1) in vec2 aTexCoord;
|
||||||
|
|
||||||
|
// Outputs al fragment shader
|
||||||
|
out vec2 vTexCoord;
|
||||||
|
out float vFilterWidth;
|
||||||
|
#if defined(CURVATURE)
|
||||||
|
out vec2 vScreenScale;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Uniforms
|
||||||
|
uniform vec2 TextureSize;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
#if defined(CURVATURE)
|
||||||
|
vScreenScale = vec2(1.0, 1.0);
|
||||||
|
#endif
|
||||||
|
// Calcula filterWidth dinámicamente basándose en la altura de la textura
|
||||||
|
vFilterWidth = (768.0 / TextureSize.y) / 3.0;
|
||||||
|
|
||||||
|
// Pasar coordenadas de textura (invertir Y para SDL)
|
||||||
|
vTexCoord = vec2(aTexCoord.x, 1.0 - aTexCoord.y) * 1.0001;
|
||||||
|
|
||||||
|
// Posición del vértice (ya en espacio de clip [-1, 1])
|
||||||
|
gl_Position = vec4(aPosition, 0.0, 1.0);
|
||||||
|
}
|
||||||
BIN
data/sound/bullet2p.wav
Normal file
BIN
data/sound/name_input_accept.wav
Normal file
BIN
data/sound/service_menu_back.wav
Normal file
BIN
data/sound/voice_game_over.wav
Normal file
553
linux_utils/iwyu_tool.py
Executable file
@@ -0,0 +1,553 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
##===--- iwyu_tool.py -----------------------------------------------------===##
|
||||||
|
#
|
||||||
|
# The LLVM Compiler Infrastructure
|
||||||
|
#
|
||||||
|
# This file is distributed under the University of Illinois Open Source
|
||||||
|
# License. See LICENSE.TXT for details.
|
||||||
|
#
|
||||||
|
##===----------------------------------------------------------------------===##
|
||||||
|
|
||||||
|
""" Driver to consume a Clang compilation database and invoke IWYU.
|
||||||
|
|
||||||
|
Example usage with CMake:
|
||||||
|
|
||||||
|
# Unix systems
|
||||||
|
$ mkdir build && cd build
|
||||||
|
$ CC="clang" CXX="clang++" cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ...
|
||||||
|
$ iwyu_tool.py -p .
|
||||||
|
|
||||||
|
# Windows systems
|
||||||
|
$ mkdir build && cd build
|
||||||
|
$ cmake -DCMAKE_CXX_COMPILER="%VCINSTALLDIR%/bin/cl.exe" \
|
||||||
|
-DCMAKE_C_COMPILER="%VCINSTALLDIR%/VC/bin/cl.exe" \
|
||||||
|
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
||||||
|
-G Ninja ...
|
||||||
|
$ python3 iwyu_tool.py -p .
|
||||||
|
|
||||||
|
See iwyu_tool.py -h for more details on command-line arguments.
|
||||||
|
"""
|
||||||
|
from __future__ import print_function
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
import time
|
||||||
|
import shlex
|
||||||
|
import shutil
|
||||||
|
import argparse
|
||||||
|
import tempfile
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
|
CORRECT_RE = re.compile(r'^\((.*?) has correct #includes/fwd-decls\)$')
|
||||||
|
SHOULD_ADD_RE = re.compile(r'^(.*?) should add these lines:$')
|
||||||
|
ADD_RE = re.compile('^(.*?) +// (.*)$')
|
||||||
|
SHOULD_REMOVE_RE = re.compile(r'^(.*?) should remove these lines:$')
|
||||||
|
FULL_LIST_RE = re.compile(r'The full include-list for (.*?):$')
|
||||||
|
END_RE = re.compile(r'^---$')
|
||||||
|
LINES_RE = re.compile(r'^- (.*?) // lines ([0-9]+)-[0-9]+$')
|
||||||
|
|
||||||
|
|
||||||
|
GENERAL, ADD, REMOVE, LIST = range(4)
|
||||||
|
|
||||||
|
|
||||||
|
def clang_formatter(output, style):
|
||||||
|
""" Process iwyu's output into something clang-like. """
|
||||||
|
formatted = []
|
||||||
|
|
||||||
|
state = (GENERAL, None)
|
||||||
|
for line in output.splitlines():
|
||||||
|
match = CORRECT_RE.match(line)
|
||||||
|
if match:
|
||||||
|
# See PR#1806 for more info
|
||||||
|
continue
|
||||||
|
match = SHOULD_ADD_RE.match(line)
|
||||||
|
if match:
|
||||||
|
state = (ADD, match.group(1))
|
||||||
|
continue
|
||||||
|
match = SHOULD_REMOVE_RE.match(line)
|
||||||
|
if match:
|
||||||
|
state = (REMOVE, match.group(1))
|
||||||
|
continue
|
||||||
|
match = FULL_LIST_RE.match(line)
|
||||||
|
if match:
|
||||||
|
state = (LIST, match.group(1))
|
||||||
|
elif END_RE.match(line):
|
||||||
|
state = (GENERAL, None)
|
||||||
|
elif not line.strip():
|
||||||
|
continue
|
||||||
|
elif state[0] == GENERAL:
|
||||||
|
formatted.append(line)
|
||||||
|
elif state[0] == ADD:
|
||||||
|
match = ADD_RE.match(line)
|
||||||
|
if match:
|
||||||
|
formatted.append("%s:1:1: %s: add '%s' (%s)" %
|
||||||
|
(state[1],
|
||||||
|
style,
|
||||||
|
match.group(1),
|
||||||
|
match.group(2)))
|
||||||
|
else:
|
||||||
|
formatted.append("%s:1:1: %s: add '%s'" %
|
||||||
|
(state[1], style, line))
|
||||||
|
elif state[0] == REMOVE:
|
||||||
|
match = LINES_RE.match(line)
|
||||||
|
line_no = match.group(2) if match else '1'
|
||||||
|
formatted.append("%s:%s:1: %s: superfluous '%s'" %
|
||||||
|
(state[1], line_no, style, match.group(1)))
|
||||||
|
|
||||||
|
return os.linesep.join(formatted)
|
||||||
|
|
||||||
|
|
||||||
|
DEFAULT_FORMAT = 'iwyu'
|
||||||
|
FORMATTERS = {
|
||||||
|
'iwyu': lambda output: output,
|
||||||
|
'clang': lambda output: clang_formatter(output, style="error"),
|
||||||
|
'clang-warning': lambda output: clang_formatter(output, style="warning"),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if sys.platform.startswith('win'):
|
||||||
|
# Case-insensitive match on Windows
|
||||||
|
def normcase(s):
|
||||||
|
return s.lower()
|
||||||
|
else:
|
||||||
|
def normcase(s):
|
||||||
|
return s
|
||||||
|
|
||||||
|
|
||||||
|
def is_subpath_of(path, parent):
|
||||||
|
""" Return True if path is equal to or fully contained within parent.
|
||||||
|
|
||||||
|
Assumes both paths are canonicalized with os.path.realpath.
|
||||||
|
"""
|
||||||
|
parent = normcase(parent)
|
||||||
|
path = normcase(path)
|
||||||
|
|
||||||
|
if path == parent:
|
||||||
|
return True
|
||||||
|
|
||||||
|
if not path.startswith(parent):
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Now we know parent is a prefix of path, but they only share lineage if the
|
||||||
|
# difference between them starts with a path separator, e.g. /a/b/c/file
|
||||||
|
# is not a parent of /a/b/c/file.cpp, but /a/b/c and /a/b/c/ are.
|
||||||
|
parent = parent.rstrip(os.path.sep)
|
||||||
|
suffix = path[len(parent):]
|
||||||
|
return suffix.startswith(os.path.sep)
|
||||||
|
|
||||||
|
|
||||||
|
def is_msvc_driver(compile_command):
|
||||||
|
""" Return True if compile_command matches an MSVC CL-style driver. """
|
||||||
|
compile_command = normcase(compile_command)
|
||||||
|
|
||||||
|
if compile_command.endswith('cl.exe'):
|
||||||
|
# Native MSVC compiler or clang-cl.exe
|
||||||
|
return True
|
||||||
|
|
||||||
|
if compile_command.endswith('clang-cl'):
|
||||||
|
# Cross clang-cl on non-Windows
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def win_split(cmdline):
|
||||||
|
""" Minimal implementation of shlex.split for Windows following
|
||||||
|
https://msdn.microsoft.com/en-us/library/windows/desktop/17w5ykft.aspx.
|
||||||
|
"""
|
||||||
|
def split_iter(cmdline):
|
||||||
|
in_quotes = False
|
||||||
|
backslashes = 0
|
||||||
|
arg = ''
|
||||||
|
for c in cmdline:
|
||||||
|
if c == '\\':
|
||||||
|
# MSDN: Backslashes are interpreted literally, unless they
|
||||||
|
# immediately precede a double quotation mark.
|
||||||
|
# Buffer them until we know what comes next.
|
||||||
|
backslashes += 1
|
||||||
|
elif c == '"':
|
||||||
|
# Quotes can either be an escaped quote or the start of a quoted
|
||||||
|
# string. Paraphrasing MSDN:
|
||||||
|
# Before quotes, place one backslash in the arg for every pair
|
||||||
|
# of leading backslashes. If the number of backslashes is odd,
|
||||||
|
# retain the double quotation mark, otherwise interpret it as a
|
||||||
|
# string delimiter and switch state.
|
||||||
|
arg += '\\' * (backslashes // 2)
|
||||||
|
if backslashes % 2 == 1:
|
||||||
|
arg += c
|
||||||
|
else:
|
||||||
|
in_quotes = not in_quotes
|
||||||
|
backslashes = 0
|
||||||
|
elif c in (' ', '\t') and not in_quotes:
|
||||||
|
# MSDN: Arguments are delimited by white space, which is either
|
||||||
|
# a space or a tab [but only outside of a string].
|
||||||
|
# Flush any buffered backslashes and yield arg, unless empty.
|
||||||
|
arg += '\\' * backslashes
|
||||||
|
if arg:
|
||||||
|
yield arg
|
||||||
|
arg = ''
|
||||||
|
backslashes = 0
|
||||||
|
else:
|
||||||
|
# Flush buffered backslashes and append.
|
||||||
|
arg += '\\' * backslashes
|
||||||
|
arg += c
|
||||||
|
backslashes = 0
|
||||||
|
|
||||||
|
if arg:
|
||||||
|
arg += '\\' * backslashes
|
||||||
|
yield arg
|
||||||
|
|
||||||
|
return list(split_iter(cmdline))
|
||||||
|
|
||||||
|
|
||||||
|
def split_command(cmdstr):
|
||||||
|
""" Split a command string into a list, respecting shell quoting. """
|
||||||
|
if sys.platform.startswith('win'):
|
||||||
|
# shlex.split does not work for Windows command-lines, so special-case
|
||||||
|
# to our own implementation.
|
||||||
|
cmd = win_split(cmdstr)
|
||||||
|
else:
|
||||||
|
cmd = shlex.split(cmdstr)
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
|
||||||
|
|
||||||
|
def find_include_what_you_use():
|
||||||
|
""" Find IWYU executable and return its full pathname. """
|
||||||
|
env_iwyu_path = os.environ.get('IWYU_BINARY')
|
||||||
|
if env_iwyu_path:
|
||||||
|
return os.path.realpath(env_iwyu_path)
|
||||||
|
|
||||||
|
# Search in same dir as this script.
|
||||||
|
iwyu_path = shutil.which('include-what-you-use',
|
||||||
|
path=os.path.dirname(__file__))
|
||||||
|
if iwyu_path:
|
||||||
|
return os.path.realpath(iwyu_path)
|
||||||
|
|
||||||
|
# Search the system PATH.
|
||||||
|
iwyu_path = shutil.which('include-what-you-use')
|
||||||
|
if iwyu_path:
|
||||||
|
return os.path.realpath(iwyu_path)
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
IWYU_EXECUTABLE = find_include_what_you_use()
|
||||||
|
|
||||||
|
|
||||||
|
class Process(object):
|
||||||
|
""" Manages an IWYU process in flight """
|
||||||
|
def __init__(self, proc, outfile):
|
||||||
|
self.proc = proc
|
||||||
|
self.outfile = outfile
|
||||||
|
self.output = None
|
||||||
|
|
||||||
|
def poll(self):
|
||||||
|
""" Return the exit code if the process has completed, None otherwise.
|
||||||
|
"""
|
||||||
|
return self.proc.poll()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def returncode(self):
|
||||||
|
return self.proc.returncode
|
||||||
|
|
||||||
|
def get_output(self):
|
||||||
|
""" Return stdout+stderr output of the process.
|
||||||
|
|
||||||
|
This call blocks until the process is complete, then returns the output.
|
||||||
|
"""
|
||||||
|
if not self.output:
|
||||||
|
self.proc.wait()
|
||||||
|
self.outfile.seek(0)
|
||||||
|
self.output = self.outfile.read().decode("utf-8")
|
||||||
|
self.outfile.close()
|
||||||
|
|
||||||
|
return self.output
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def start(cls, invocation):
|
||||||
|
""" Start a Process for the invocation and capture stdout+stderr. """
|
||||||
|
outfile = tempfile.TemporaryFile(prefix='iwyu')
|
||||||
|
process = subprocess.Popen(
|
||||||
|
invocation.command,
|
||||||
|
cwd=invocation.cwd,
|
||||||
|
stdout=outfile,
|
||||||
|
stderr=subprocess.STDOUT)
|
||||||
|
return cls(process, outfile)
|
||||||
|
|
||||||
|
|
||||||
|
KNOWN_COMPILER_WRAPPERS=frozenset([
|
||||||
|
"ccache"
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
class Invocation(object):
|
||||||
|
""" Holds arguments of an IWYU invocation. """
|
||||||
|
def __init__(self, command, cwd):
|
||||||
|
self.command = command
|
||||||
|
self.cwd = cwd
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return ' '.join(self.command)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_compile_command(cls, entry, extra_args):
|
||||||
|
""" Parse a JSON compilation database entry into new Invocation. """
|
||||||
|
if 'arguments' in entry:
|
||||||
|
# arguments is a command-line in list form.
|
||||||
|
command = entry['arguments']
|
||||||
|
elif 'command' in entry:
|
||||||
|
# command is a command-line in string form, split to list.
|
||||||
|
command = split_command(entry['command'])
|
||||||
|
else:
|
||||||
|
raise ValueError('Invalid compilation database entry: %s' % entry)
|
||||||
|
|
||||||
|
if command[0] in KNOWN_COMPILER_WRAPPERS:
|
||||||
|
# Remove the compiler wrapper from the command.
|
||||||
|
command = command[1:]
|
||||||
|
|
||||||
|
# Rewrite the compile command for IWYU
|
||||||
|
compile_command, compile_args = command[0], command[1:]
|
||||||
|
if is_msvc_driver(compile_command):
|
||||||
|
# If the compiler is cl-compatible, let IWYU be cl-compatible.
|
||||||
|
extra_args = ['--driver-mode=cl'] + extra_args
|
||||||
|
|
||||||
|
command = [IWYU_EXECUTABLE] + extra_args + compile_args
|
||||||
|
return cls(command, entry['directory'])
|
||||||
|
|
||||||
|
def start(self, verbose):
|
||||||
|
""" Run invocation and collect output. """
|
||||||
|
if verbose:
|
||||||
|
print('# %s' % self, file=sys.stderr)
|
||||||
|
|
||||||
|
return Process.start(self)
|
||||||
|
|
||||||
|
|
||||||
|
def fixup_compilation_db(compilation_db):
|
||||||
|
""" Canonicalize paths in JSON compilation database. """
|
||||||
|
for entry in compilation_db:
|
||||||
|
# Convert relative paths to absolute ones if possible, based on the entry's directory.
|
||||||
|
if 'directory' in entry and not os.path.isabs(entry['file']):
|
||||||
|
entry['file'] = os.path.join(entry['directory'], entry['file'])
|
||||||
|
|
||||||
|
# Expand relative paths and symlinks
|
||||||
|
entry['file'] = os.path.realpath(entry['file'])
|
||||||
|
|
||||||
|
return compilation_db
|
||||||
|
|
||||||
|
|
||||||
|
def select_compilation_db(compilation_db, selection):
|
||||||
|
""" Return a new compilation database reduced to the paths in selection. """
|
||||||
|
if not selection:
|
||||||
|
return compilation_db
|
||||||
|
|
||||||
|
# Canonicalize selection paths to match compilation database.
|
||||||
|
selection = [os.path.realpath(p) for p in selection]
|
||||||
|
|
||||||
|
new_db = []
|
||||||
|
for path in selection:
|
||||||
|
if not os.path.exists(path):
|
||||||
|
print('warning: \'%s\' not found on disk.' % path, file=sys.stderr)
|
||||||
|
continue
|
||||||
|
|
||||||
|
found = [e for e in compilation_db if is_subpath_of(e['file'], path)]
|
||||||
|
if not found:
|
||||||
|
print('warning: \'%s\' not found in compilation database.' % path,
|
||||||
|
file=sys.stderr)
|
||||||
|
continue
|
||||||
|
|
||||||
|
new_db.extend(found)
|
||||||
|
|
||||||
|
return new_db
|
||||||
|
|
||||||
|
def slice_compilation_db(compilation_db, selection, exclude):
|
||||||
|
""" Return a new compilation database with filtered entries. """
|
||||||
|
|
||||||
|
new_db = select_compilation_db(compilation_db, selection)
|
||||||
|
|
||||||
|
# Canonicalize selection paths to match compilation database.
|
||||||
|
exclude = [os.path.realpath(p) for p in exclude]
|
||||||
|
|
||||||
|
for path in exclude:
|
||||||
|
if not os.path.exists(path):
|
||||||
|
print('warning: excluded path \'%s\' not found on disk.' % path,
|
||||||
|
file=sys.stderr)
|
||||||
|
continue
|
||||||
|
|
||||||
|
new_db = [e for e in new_db if not is_subpath_of(e['file'], path)]
|
||||||
|
|
||||||
|
return new_db
|
||||||
|
|
||||||
|
|
||||||
|
def worst_exit_code(worst, cur):
|
||||||
|
"""Return the most extreme exit code of two.
|
||||||
|
|
||||||
|
Negative exit codes occur if the program exits due to a signal (Unix) or
|
||||||
|
structured exception (Windows). If we've seen a negative one before, keep
|
||||||
|
it, as it usually indicates a critical error.
|
||||||
|
|
||||||
|
Otherwise return the biggest positive exit code.
|
||||||
|
"""
|
||||||
|
if cur < 0:
|
||||||
|
# Negative results take precedence, return the minimum
|
||||||
|
return min(worst, cur)
|
||||||
|
elif worst < 0:
|
||||||
|
# We know cur is non-negative, negative worst must be minimum
|
||||||
|
return worst
|
||||||
|
else:
|
||||||
|
# We know neither are negative, return the maximum
|
||||||
|
return max(worst, cur)
|
||||||
|
|
||||||
|
|
||||||
|
def execute(invocations, verbose, formatter, jobs, max_load_average=0):
|
||||||
|
""" Launch processes described by invocations. """
|
||||||
|
exit_code = 0
|
||||||
|
if jobs == 1:
|
||||||
|
for invocation in invocations:
|
||||||
|
proc = invocation.start(verbose)
|
||||||
|
print(formatter(proc.get_output()))
|
||||||
|
exit_code = worst_exit_code(exit_code, proc.returncode)
|
||||||
|
return exit_code
|
||||||
|
|
||||||
|
pending = []
|
||||||
|
while invocations or pending:
|
||||||
|
# Collect completed IWYU processes and print results.
|
||||||
|
complete = [proc for proc in pending if proc.poll() is not None]
|
||||||
|
for proc in complete:
|
||||||
|
pending.remove(proc)
|
||||||
|
print(formatter(proc.get_output()))
|
||||||
|
exit_code = worst_exit_code(exit_code, proc.returncode)
|
||||||
|
|
||||||
|
# Schedule new processes if there's room.
|
||||||
|
capacity = jobs - len(pending)
|
||||||
|
|
||||||
|
if max_load_average > 0:
|
||||||
|
one_min_load_average, _, _ = os.getloadavg()
|
||||||
|
load_capacity = max_load_average - one_min_load_average
|
||||||
|
if load_capacity < 0:
|
||||||
|
load_capacity = 0
|
||||||
|
if load_capacity < capacity:
|
||||||
|
capacity = int(load_capacity)
|
||||||
|
if not capacity and not pending:
|
||||||
|
# Ensure there is at least one job running.
|
||||||
|
capacity = 1
|
||||||
|
|
||||||
|
pending.extend(i.start(verbose) for i in invocations[:capacity])
|
||||||
|
invocations = invocations[capacity:]
|
||||||
|
|
||||||
|
# Yield CPU.
|
||||||
|
time.sleep(0.0001)
|
||||||
|
return exit_code
|
||||||
|
|
||||||
|
|
||||||
|
def main(compilation_db_path, source_files, exclude, verbose, formatter, jobs,
|
||||||
|
max_load_average, extra_args):
|
||||||
|
""" Entry point. """
|
||||||
|
|
||||||
|
if not IWYU_EXECUTABLE:
|
||||||
|
print('error: include-what-you-use executable not found',
|
||||||
|
file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
|
||||||
|
try:
|
||||||
|
if os.path.isdir(compilation_db_path):
|
||||||
|
compilation_db_path = os.path.join(compilation_db_path,
|
||||||
|
'compile_commands.json')
|
||||||
|
|
||||||
|
# Read compilation db from disk.
|
||||||
|
compilation_db_path = os.path.realpath(compilation_db_path)
|
||||||
|
with open(compilation_db_path, 'r') as fileobj:
|
||||||
|
compilation_db = json.load(fileobj)
|
||||||
|
except IOError as why:
|
||||||
|
print('error: failed to parse compilation database: %s' % why,
|
||||||
|
file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
|
||||||
|
compilation_db = fixup_compilation_db(compilation_db)
|
||||||
|
compilation_db = slice_compilation_db(compilation_db, source_files, exclude)
|
||||||
|
|
||||||
|
# Transform compilation db entries into a list of IWYU invocations.
|
||||||
|
invocations = [
|
||||||
|
Invocation.from_compile_command(e, extra_args) for e in compilation_db
|
||||||
|
]
|
||||||
|
|
||||||
|
return execute(invocations, verbose, formatter, jobs, max_load_average)
|
||||||
|
|
||||||
|
|
||||||
|
def _bootstrap(sys_argv):
|
||||||
|
""" Parse arguments and dispatch to main(). """
|
||||||
|
|
||||||
|
# This hackery is necessary to add the forwarded IWYU args to the
|
||||||
|
# usage and help strings.
|
||||||
|
def customize_usage(parser):
|
||||||
|
""" Rewrite the parser's format_usage. """
|
||||||
|
original_format_usage = parser.format_usage
|
||||||
|
parser.format_usage = lambda: original_format_usage().rstrip() + \
|
||||||
|
' -- [<IWYU args>]' + os.linesep
|
||||||
|
|
||||||
|
def customize_help(parser):
|
||||||
|
""" Rewrite the parser's format_help. """
|
||||||
|
original_format_help = parser.format_help
|
||||||
|
|
||||||
|
def custom_help():
|
||||||
|
""" Customized help string, calls the adjusted format_usage. """
|
||||||
|
helpmsg = original_format_help()
|
||||||
|
helplines = helpmsg.splitlines()
|
||||||
|
helplines[0] = parser.format_usage().rstrip()
|
||||||
|
return os.linesep.join(helplines) + os.linesep
|
||||||
|
|
||||||
|
parser.format_help = custom_help
|
||||||
|
|
||||||
|
# Parse arguments.
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description='Include-what-you-use compilation database driver.',
|
||||||
|
epilog='Assumes include-what-you-use is available on the PATH.')
|
||||||
|
customize_usage(parser)
|
||||||
|
customize_help(parser)
|
||||||
|
|
||||||
|
parser.add_argument('-v', '--verbose', action='store_true',
|
||||||
|
help='Print IWYU commands')
|
||||||
|
parser.add_argument('-o', '--output-format', type=str,
|
||||||
|
choices=FORMATTERS.keys(), default=DEFAULT_FORMAT,
|
||||||
|
help='Output format (default: %s)' % DEFAULT_FORMAT)
|
||||||
|
parser.add_argument('-j', '--jobs', type=int, default=1,
|
||||||
|
nargs='?', const=0,
|
||||||
|
help=('Number of concurrent subprocesses. If zero, '
|
||||||
|
'will try to match the logical cores of the '
|
||||||
|
'system.'))
|
||||||
|
parser.add_argument('-l', '--load', type=float, default=0,
|
||||||
|
help=('Do not start new jobs if the 1min load average '
|
||||||
|
'is greater than the provided value'))
|
||||||
|
parser.add_argument('-p', metavar='<build-path>', required=True,
|
||||||
|
help='Compilation database path', dest='dbpath')
|
||||||
|
parser.add_argument('-e', '--exclude', action='append', default=[],
|
||||||
|
help=('Do not run IWYU on source files (or directories) '
|
||||||
|
'below this path.'))
|
||||||
|
parser.add_argument('source', nargs='*',
|
||||||
|
help=('Zero or more source files (or directories) to '
|
||||||
|
'run IWYU on. Defaults to all in compilation '
|
||||||
|
'database.'))
|
||||||
|
|
||||||
|
def partition_args(argv):
|
||||||
|
""" Split around '--' into driver args and IWYU args. """
|
||||||
|
try:
|
||||||
|
double_dash = argv.index('--')
|
||||||
|
return argv[:double_dash], argv[double_dash+1:]
|
||||||
|
except ValueError:
|
||||||
|
return argv, []
|
||||||
|
argv, extra_args = partition_args(sys_argv[1:])
|
||||||
|
args = parser.parse_args(argv)
|
||||||
|
|
||||||
|
jobs = args.jobs
|
||||||
|
if jobs == 0:
|
||||||
|
jobs = os.cpu_count() or 1
|
||||||
|
|
||||||
|
return main(args.dbpath, args.source, args.exclude, args.verbose,
|
||||||
|
FORMATTERS[args.output_format], jobs, args.load, extra_args)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(_bootstrap(sys.argv))
|
||||||
@@ -1,11 +1,24 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Script para ejecutar clang-tidy en múltiples directorios
|
# Script para ejecutar clang-tidy en múltiples directorios
|
||||||
# Uso: ./run_clang-tidy.sh
|
# Uso: ./run_clang-tidy.sh [--fix]
|
||||||
|
# --fix: Aplica las correcciones automáticamente (opcional)
|
||||||
|
|
||||||
|
# Detectar si se pasó el parámetro --fix
|
||||||
|
FIX_FLAG=""
|
||||||
|
if [[ "$1" == "--fix" ]]; then
|
||||||
|
FIX_FLAG="--fix"
|
||||||
|
echo "Modo: Aplicando correcciones automáticamente (--fix)"
|
||||||
|
else
|
||||||
|
echo "Modo: Solo análisis (sin --fix)"
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
# Lista de rutas donde ejecutar clang-tidy
|
# Lista de rutas donde ejecutar clang-tidy
|
||||||
PATHS=(
|
PATHS=(
|
||||||
"/home/sergio/gitea/coffee_crisis_arcade_edition/source"
|
"/home/sergio/gitea/coffee_crisis_arcade_edition/source"
|
||||||
|
"/home/sergio/gitea/coffee_crisis_arcade_edition/source/rendering"
|
||||||
|
"/home/sergio/gitea/coffee_crisis_arcade_edition/source/rendering/opengl"
|
||||||
"/home/sergio/gitea/coffee_crisis_arcade_edition/source/sections"
|
"/home/sergio/gitea/coffee_crisis_arcade_edition/source/sections"
|
||||||
"/home/sergio/gitea/coffee_crisis_arcade_edition/source/ui"
|
"/home/sergio/gitea/coffee_crisis_arcade_edition/source/ui"
|
||||||
)
|
)
|
||||||
@@ -29,8 +42,8 @@ process_directory() {
|
|||||||
cd "$dir" || return 1
|
cd "$dir" || return 1
|
||||||
|
|
||||||
# Buscar archivos .cpp, .h, .hpp solo en el nivel actual (no subdirectorios)
|
# Buscar archivos .cpp, .h, .hpp solo en el nivel actual (no subdirectorios)
|
||||||
find . -maxdepth 1 \( -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) | \
|
find . -maxdepth 1 \( -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) -print0 | \
|
||||||
xargs -P4 -I{} bash -c 'echo "Procesando: {}"; clang-tidy {} -p '"$BUILD_DIR"' --fix'
|
xargs -0 -P4 -I{} bash -c 'echo "Procesando: {}"; clang-tidy {} -p '"$BUILD_DIR"' '"$FIX_FLAG"
|
||||||
|
|
||||||
echo "=== Completado: $dir ==="
|
echo "=== Completado: $dir ==="
|
||||||
echo
|
echo
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -S "$BASE_DIR" -B "$BUILD_DIR"
|
|||||||
|
|
||||||
# 🛠️ Ejecutar IWYU con fix_includes.py
|
# 🛠️ Ejecutar IWYU con fix_includes.py
|
||||||
echo "🚀 Ejecutando IWYU..."
|
echo "🚀 Ejecutando IWYU..."
|
||||||
iwyu_tool.py -p "$BUILD_DIR" -- -Xiwyu --mapping_file="$MAPPING_FILE" -Xiwyu --verbose=3 \
|
./iwyu_tool.py -p "$BUILD_DIR" -- -Xiwyu --mapping_file="$MAPPING_FILE" -Xiwyu --verbose=3 \
|
||||||
| python3 /usr/bin/fix_includes.py --update_comments --reorder --nosafe_headers
|
| fix_include --update_comments --reorder --nosafe_headers
|
||||||
|
|
||||||
# 🧹 Reemplazar // for por // Para en líneas de #include
|
# 🧹 Reemplazar // for por // Para en líneas de #include
|
||||||
echo "✍️ Corrigiendo comentarios en includes..."
|
echo "✍️ Corrigiendo comentarios en includes..."
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.1 KiB |
BIN
release/SDL3.dll
BIN
release/icon.ico
|
Before Width: | Height: | Size: 128 KiB After Width: | Height: | Size: 134 KiB |
BIN
release/icon.png
|
Before Width: | Height: | Size: 438 KiB After Width: | Height: | Size: 504 KiB |
BIN
resources.pack
@@ -1,17 +1,17 @@
|
|||||||
#include "animated_sprite.h"
|
#include "animated_sprite.hpp"
|
||||||
|
|
||||||
#include <SDL3/SDL.h> // Para SDL_LogWarn, SDL_LogCategory, SDL_LogError, SDL_FRect
|
#include <SDL3/SDL.h> // Para SDL_LogWarn, SDL_LogCategory, SDL_LogError, SDL_FRect
|
||||||
|
|
||||||
#include <algorithm> // Para min, max
|
#include <algorithm> // Para min
|
||||||
#include <cstddef> // Para size_t
|
#include <cstddef> // Para size_t
|
||||||
#include <fstream> // Para basic_istream, basic_ifstream, basic_ios, ifstream, stringstream
|
#include <fstream> // Para basic_istream, basic_ifstream, istream, basic_ios, ifstream, istringstream, stringstream
|
||||||
#include <sstream> // Para basic_stringstream
|
#include <sstream> // Para basic_istringstream, basic_stringstream
|
||||||
#include <stdexcept> // Para runtime_error
|
#include <stdexcept> // Para runtime_error
|
||||||
#include <utility> // Para pair
|
#include <utility> // Para move, pair
|
||||||
|
|
||||||
#include "texture.h" // Para Texture
|
#include "resource_helper.hpp" // Para loadFile
|
||||||
#include "resource_helper.h" // Para ResourceHelper
|
#include "texture.hpp" // Para Texture
|
||||||
#include "utils.h" // Para printWithDots
|
#include "ui/logger.hpp" // Para dots
|
||||||
|
|
||||||
// Carga las animaciones en un vector(Animations) desde un fichero
|
// Carga las animaciones en un vector(Animations) desde un fichero
|
||||||
auto loadAnimationsFromFile(const std::string& file_path) -> AnimationsFileBuffer {
|
auto loadAnimationsFromFile(const std::string& file_path) -> AnimationsFileBuffer {
|
||||||
@@ -19,13 +19,13 @@ auto loadAnimationsFromFile(const std::string& file_path) -> AnimationsFileBuffe
|
|||||||
auto resource_data = ResourceHelper::loadFile(file_path);
|
auto resource_data = ResourceHelper::loadFile(file_path);
|
||||||
std::istringstream stream;
|
std::istringstream stream;
|
||||||
bool using_resource_data = false;
|
bool using_resource_data = false;
|
||||||
|
|
||||||
if (!resource_data.empty()) {
|
if (!resource_data.empty()) {
|
||||||
std::string content(resource_data.begin(), resource_data.end());
|
std::string content(resource_data.begin(), resource_data.end());
|
||||||
stream.str(content);
|
stream.str(content);
|
||||||
using_resource_data = true;
|
using_resource_data = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback a archivo directo
|
// Fallback a archivo directo
|
||||||
std::ifstream file;
|
std::ifstream file;
|
||||||
if (!using_resource_data) {
|
if (!using_resource_data) {
|
||||||
@@ -35,14 +35,18 @@ auto loadAnimationsFromFile(const std::string& file_path) -> AnimationsFileBuffe
|
|||||||
throw std::runtime_error("Fichero no encontrado: " + file_path);
|
throw std::runtime_error("Fichero no encontrado: " + file_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::istream& input_stream = using_resource_data ? stream : static_cast<std::istream&>(file);
|
std::istream& input_stream = using_resource_data ? stream : static_cast<std::istream&>(file);
|
||||||
|
|
||||||
printWithDots("Animation : ", file_path.substr(file_path.find_last_of("\\/") + 1), "[ LOADED ]");
|
Logger::dots("Animation : ", file_path.substr(file_path.find_last_of("\\/") + 1), "[ LOADED ]");
|
||||||
|
|
||||||
std::vector<std::string> buffer;
|
std::vector<std::string> buffer;
|
||||||
std::string line;
|
std::string line;
|
||||||
while (std::getline(input_stream, line)) {
|
while (std::getline(input_stream, line)) {
|
||||||
|
// Eliminar caracteres de retorno de carro (\r) al final de la línea
|
||||||
|
if (!line.empty() && line.back() == '\r') {
|
||||||
|
line.pop_back();
|
||||||
|
}
|
||||||
if (!line.empty()) {
|
if (!line.empty()) {
|
||||||
buffer.push_back(line);
|
buffer.push_back(line);
|
||||||
}
|
}
|
||||||
@@ -82,33 +86,33 @@ auto AnimatedSprite::getAnimationIndex(const std::string& name) -> int {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calcula el frame correspondiente a la animación
|
// Calcula el frame correspondiente a la animación (time-based)
|
||||||
void AnimatedSprite::animate() {
|
void AnimatedSprite::animate(float delta_time) {
|
||||||
if (animations_[current_animation_].speed == 0 || animations_[current_animation_].paused) {
|
if (animations_[current_animation_].speed == 0 || animations_[current_animation_].paused) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calcula el frame actual a partir del contador
|
// Acumular tiempo transcurrido
|
||||||
animations_[current_animation_].current_frame = animations_[current_animation_].counter / animations_[current_animation_].speed;
|
animations_[current_animation_].time_accumulator += delta_time;
|
||||||
|
|
||||||
// Si alcanza el final de la animación, reinicia el contador de la animación
|
// Verificar si es momento de cambiar frame
|
||||||
// en función de la variable loop y coloca el nuevo frame
|
if (animations_[current_animation_].time_accumulator >= animations_[current_animation_].speed) {
|
||||||
if (animations_[current_animation_].current_frame >= animations_[current_animation_].frames.size()) {
|
animations_[current_animation_].time_accumulator -= animations_[current_animation_].speed;
|
||||||
if (animations_[current_animation_].loop == -1) { // Si no hay loop, deja el último frame
|
animations_[current_animation_].current_frame++;
|
||||||
animations_[current_animation_].current_frame = animations_[current_animation_].frames.size();
|
|
||||||
animations_[current_animation_].completed = true;
|
// Si alcanza el final de la animación
|
||||||
} else { // Si hay loop, vuelve al frame indicado
|
if (animations_[current_animation_].current_frame >= animations_[current_animation_].frames.size()) {
|
||||||
animations_[current_animation_].counter = 0;
|
if (animations_[current_animation_].loop == -1) { // Si no hay loop, deja el último frame
|
||||||
animations_[current_animation_].current_frame = animations_[current_animation_].loop;
|
animations_[current_animation_].current_frame = animations_[current_animation_].frames.size() - 1;
|
||||||
|
animations_[current_animation_].completed = true;
|
||||||
|
} else { // Si hay loop, vuelve al frame indicado
|
||||||
|
animations_[current_animation_].time_accumulator = 0.0F;
|
||||||
|
animations_[current_animation_].current_frame = animations_[current_animation_].loop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// En caso contrario
|
|
||||||
else {
|
|
||||||
// Escoge el frame correspondiente de la animación
|
|
||||||
updateSpriteClip();
|
|
||||||
|
|
||||||
// Incrementa el contador de la animacion
|
// Actualizar el sprite clip
|
||||||
animations_[current_animation_].counter++;
|
updateSpriteClip();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,11 +129,11 @@ void AnimatedSprite::setCurrentAnimation(const std::string& name, bool reset) {
|
|||||||
current_animation_ = NEW_ANIMATION;
|
current_animation_ = NEW_ANIMATION;
|
||||||
if (reset) {
|
if (reset) {
|
||||||
animations_[current_animation_].current_frame = 0;
|
animations_[current_animation_].current_frame = 0;
|
||||||
animations_[current_animation_].counter = 0;
|
animations_[current_animation_].time_accumulator = 0.0F;
|
||||||
animations_[current_animation_].completed = false;
|
animations_[current_animation_].completed = false;
|
||||||
} else {
|
} else {
|
||||||
animations_[current_animation_].current_frame = std::min(animations_[OLD_ANIMATION].current_frame, animations_[current_animation_].frames.size() - 1);
|
animations_[current_animation_].current_frame = std::min(animations_[OLD_ANIMATION].current_frame, animations_[current_animation_].frames.size() - 1);
|
||||||
animations_[current_animation_].counter = animations_[OLD_ANIMATION].counter;
|
animations_[current_animation_].time_accumulator = animations_[OLD_ANIMATION].time_accumulator;
|
||||||
animations_[current_animation_].completed = animations_[OLD_ANIMATION].completed;
|
animations_[current_animation_].completed = animations_[OLD_ANIMATION].completed;
|
||||||
}
|
}
|
||||||
updateSpriteClip();
|
updateSpriteClip();
|
||||||
@@ -144,27 +148,27 @@ void AnimatedSprite::setCurrentAnimation(int index, bool reset) {
|
|||||||
current_animation_ = NEW_ANIMATION;
|
current_animation_ = NEW_ANIMATION;
|
||||||
if (reset) {
|
if (reset) {
|
||||||
animations_[current_animation_].current_frame = 0;
|
animations_[current_animation_].current_frame = 0;
|
||||||
animations_[current_animation_].counter = 0;
|
animations_[current_animation_].time_accumulator = 0.0F;
|
||||||
animations_[current_animation_].completed = false;
|
animations_[current_animation_].completed = false;
|
||||||
} else {
|
} else {
|
||||||
animations_[current_animation_].current_frame = std::min(animations_[OLD_ANIMATION].current_frame, animations_[current_animation_].frames.size());
|
animations_[current_animation_].current_frame = std::min(animations_[OLD_ANIMATION].current_frame, animations_[current_animation_].frames.size());
|
||||||
animations_[current_animation_].counter = animations_[OLD_ANIMATION].counter;
|
animations_[current_animation_].time_accumulator = animations_[OLD_ANIMATION].time_accumulator;
|
||||||
animations_[current_animation_].completed = animations_[OLD_ANIMATION].completed;
|
animations_[current_animation_].completed = animations_[OLD_ANIMATION].completed;
|
||||||
}
|
}
|
||||||
updateSpriteClip();
|
updateSpriteClip();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las variables del objeto
|
// Actualiza las variables del objeto (time-based)
|
||||||
void AnimatedSprite::update() {
|
void AnimatedSprite::update(float delta_time) {
|
||||||
animate();
|
animate(delta_time);
|
||||||
MovingSprite::update();
|
MovingSprite::update(delta_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reinicia la animación
|
// Reinicia la animación
|
||||||
void AnimatedSprite::resetAnimation() {
|
void AnimatedSprite::resetAnimation() {
|
||||||
animations_[current_animation_].current_frame = 0;
|
animations_[current_animation_].current_frame = 0;
|
||||||
animations_[current_animation_].counter = 0;
|
animations_[current_animation_].time_accumulator = 0.0F;
|
||||||
animations_[current_animation_].completed = false;
|
animations_[current_animation_].completed = false;
|
||||||
animations_[current_animation_].paused = false;
|
animations_[current_animation_].paused = false;
|
||||||
updateSpriteClip();
|
updateSpriteClip();
|
||||||
@@ -190,6 +194,12 @@ void AnimatedSprite::loadFromAnimationsFileBuffer(const AnimationsFileBuffer& so
|
|||||||
// Pone un valor por defecto
|
// Pone un valor por defecto
|
||||||
setWidth(config.frame_width);
|
setWidth(config.frame_width);
|
||||||
setHeight(config.frame_height);
|
setHeight(config.frame_height);
|
||||||
|
|
||||||
|
// Establece el primer frame inmediatamente si hay animaciones
|
||||||
|
if (!animations_.empty()) {
|
||||||
|
current_animation_ = 0;
|
||||||
|
updateSpriteClip();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Procesa una línea de configuración
|
// Procesa una línea de configuración
|
||||||
@@ -259,7 +269,7 @@ void AnimatedSprite::processAnimationParameter(const std::string& line, Animatio
|
|||||||
if (key == "name") {
|
if (key == "name") {
|
||||||
animation.name = value;
|
animation.name = value;
|
||||||
} else if (key == "speed") {
|
} else if (key == "speed") {
|
||||||
animation.speed = std::stoi(value);
|
animation.speed = std::stof(value);
|
||||||
} else if (key == "loop") {
|
} else if (key == "loop") {
|
||||||
animation.loop = std::stoi(value);
|
animation.loop = std::stoi(value);
|
||||||
} else if (key == "frames") {
|
} else if (key == "frames") {
|
||||||
@@ -286,7 +296,7 @@ void AnimatedSprite::parseFramesParameter(const std::string& frames_str, Animati
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Establece la velocidad de la animación
|
// Establece la velocidad de la animación
|
||||||
void AnimatedSprite::setAnimationSpeed(size_t value) {
|
void AnimatedSprite::setAnimationSpeed(float value) {
|
||||||
animations_[current_animation_].speed = value;
|
animations_[current_animation_].speed = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,30 +2,29 @@
|
|||||||
|
|
||||||
#include <SDL3/SDL.h> // Para SDL_FRect
|
#include <SDL3/SDL.h> // Para SDL_FRect
|
||||||
|
|
||||||
#include <algorithm> // Para max
|
|
||||||
#include <cstddef> // Para size_t
|
#include <cstddef> // Para size_t
|
||||||
#include <memory> // Para allocator, shared_ptr
|
#include <memory> // Para shared_ptr
|
||||||
#include <string> // Para string, hash
|
#include <string> // Para basic_string, string, hash
|
||||||
#include <unordered_map> // Para unordered_map
|
#include <unordered_map> // Para unordered_map
|
||||||
#include <utility>
|
#include <utility> // Para move
|
||||||
#include <vector> // Para vector
|
#include <vector> // Para vector
|
||||||
|
|
||||||
#include "moving_sprite.h" // Para MovingSprite
|
#include "moving_sprite.hpp" // for MovingSprite
|
||||||
|
|
||||||
// Declaración adelantada
|
// Declaración adelantada
|
||||||
class Texture;
|
class Texture;
|
||||||
|
|
||||||
// --- Estructuras ---
|
// --- Estructuras ---
|
||||||
struct Animation {
|
struct Animation {
|
||||||
static constexpr int DEFAULT_SPEED = 5;
|
static constexpr float DEFAULT_SPEED = 80.0F;
|
||||||
|
|
||||||
std::string name; // Nombre de la animación
|
std::string name; // Nombre de la animación
|
||||||
std::vector<SDL_FRect> frames; // Frames que componen la animación
|
std::vector<SDL_FRect> frames; // Frames que componen la animación
|
||||||
int speed{DEFAULT_SPEED}; // Velocidad de reproducción
|
float speed{DEFAULT_SPEED}; // Velocidad de reproducción (ms entre frames)
|
||||||
int loop{0}; // Frame de vuelta al terminar (-1 para no repetir)
|
int loop{0}; // Frame de vuelta al terminar (-1 para no repetir)
|
||||||
bool completed{false}; // Indica si la animación ha finalizado
|
bool completed{false}; // Indica si la animación ha finalizado
|
||||||
size_t current_frame{0}; // Frame actual en reproducción
|
size_t current_frame{0}; // Frame actual en reproducción
|
||||||
int counter{0}; // Contador para la animación
|
float time_accumulator{0.0F}; // Acumulador de tiempo para animaciones time-based
|
||||||
bool paused{false}; // La animación no avanza
|
bool paused{false}; // La animación no avanza
|
||||||
|
|
||||||
Animation() = default;
|
Animation() = default;
|
||||||
@@ -50,18 +49,19 @@ class AnimatedSprite : public MovingSprite {
|
|||||||
// --- Constructores y destructor ---
|
// --- Constructores y destructor ---
|
||||||
AnimatedSprite(std::shared_ptr<Texture> texture, const std::string& file_path);
|
AnimatedSprite(std::shared_ptr<Texture> texture, const std::string& file_path);
|
||||||
AnimatedSprite(std::shared_ptr<Texture> texture, const AnimationsFileBuffer& animations);
|
AnimatedSprite(std::shared_ptr<Texture> texture, const AnimationsFileBuffer& animations);
|
||||||
explicit AnimatedSprite(std::shared_ptr<Texture> texture) : MovingSprite(std::move(texture)) {}
|
explicit AnimatedSprite(std::shared_ptr<Texture> texture)
|
||||||
|
: MovingSprite(std::move(texture)) {}
|
||||||
~AnimatedSprite() override = default;
|
~AnimatedSprite() override = default;
|
||||||
|
|
||||||
// --- Métodos principales ---
|
// --- Métodos principales ---
|
||||||
void update() override; // Actualiza la animación
|
void update(float delta_time) override; // Actualiza la animación (time-based)
|
||||||
|
|
||||||
// --- Control de animaciones ---
|
// --- Control de animaciones ---
|
||||||
void setCurrentAnimation(const std::string& name = "default", bool reset = true); // Establece la animación por nombre
|
void setCurrentAnimation(const std::string& name = "default", bool reset = true); // Establece la animación por nombre
|
||||||
void setCurrentAnimation(int index = 0, bool reset = true); // Establece la animación por índice
|
void setCurrentAnimation(int index = 0, bool reset = true); // Establece la animación por índice
|
||||||
void resetAnimation(); // Reinicia la animación actual
|
void resetAnimation(); // Reinicia la animación actual
|
||||||
void setAnimationSpeed(size_t value); // Establece la velocidad de la animación
|
void setAnimationSpeed(float value); // Establece la velocidad de la animación
|
||||||
auto getAnimationSpeed() const -> size_t { return animations_[current_animation_].speed; } // Obtiene la velocidad de la animación actual
|
auto getAnimationSpeed() const -> float { return animations_[current_animation_].speed; } // Obtiene la velocidad de la animación actual
|
||||||
void animtionPause() { animations_[current_animation_].paused = true; } // Detiene la animación
|
void animtionPause() { animations_[current_animation_].paused = true; } // Detiene la animación
|
||||||
void animationResume() { animations_[current_animation_].paused = false; } // Reanuda la animación
|
void animationResume() { animations_[current_animation_].paused = false; } // Reanuda la animación
|
||||||
auto getCurrentAnimationFrame() const -> size_t { return animations_[current_animation_].current_frame; } // Obtiene el numero de frame de la animación actual
|
auto getCurrentAnimationFrame() const -> size_t { return animations_[current_animation_].current_frame; } // Obtiene el numero de frame de la animación actual
|
||||||
@@ -77,7 +77,7 @@ class AnimatedSprite : public MovingSprite {
|
|||||||
int current_animation_ = 0; // Índice de la animación activa
|
int current_animation_ = 0; // Índice de la animación activa
|
||||||
|
|
||||||
// --- Métodos internos ---
|
// --- Métodos internos ---
|
||||||
void animate(); // Calcula el frame correspondiente a la animación
|
void animate(float delta_time); // Calcula el frame correspondiente a la animación (time-based)
|
||||||
void loadFromAnimationsFileBuffer(const AnimationsFileBuffer& source); // Carga la animación desde un vector de cadenas
|
void loadFromAnimationsFileBuffer(const AnimationsFileBuffer& source); // Carga la animación desde un vector de cadenas
|
||||||
void processConfigLine(const std::string& line, AnimationConfig& config); // Procesa una línea de configuración
|
void processConfigLine(const std::string& line, AnimationConfig& config); // Procesa una línea de configuración
|
||||||
void updateFrameCalculations(AnimationConfig& config); // Actualiza los cálculos basados en las dimensiones del frame
|
void updateFrameCalculations(AnimationConfig& config); // Actualiza los cálculos basados en las dimensiones del frame
|
||||||
116
source/asset.cpp
@@ -1,20 +1,24 @@
|
|||||||
#include "asset.h"
|
#include "asset.hpp"
|
||||||
|
|
||||||
#include <SDL3/SDL.h> // Para SDL_LogCategory, SDL_LogInfo, SDL_LogError, SDL_LogWarn
|
#include <SDL3/SDL.h> // Para SDL_LogWarn, SDL_LogCategory, SDL_LogError
|
||||||
|
|
||||||
#include <cstddef> // Para size_t
|
#include <algorithm> // Para sort
|
||||||
#include <exception> // Para exception
|
#include <cstddef> // Para size_t
|
||||||
#include <fstream> // Para basic_istream, basic_ifstream, ifstream, istringstream
|
#include <exception> // Para exception
|
||||||
#include <sstream> // Para basic_istringstream
|
#include <filesystem> // Para exists, path
|
||||||
#include <stdexcept> // Para runtime_error
|
#include <fstream> // Para basic_ifstream, basic_istream, basic_ostream, operator<<, ifstream, istringstream, endl
|
||||||
|
#include <iostream> // Para cout
|
||||||
|
#include <sstream> // Para basic_istringstream
|
||||||
|
#include <stdexcept> // Para runtime_error
|
||||||
|
|
||||||
#include "utils.h" // Para getFileName
|
#include "resource_helper.hpp" // Para loadFile
|
||||||
#include "resource_helper.h" // Para ResourceHelper
|
#include "ui/logger.hpp" // Para info, section, CYAN
|
||||||
|
#include "utils.hpp" // Para getFileName
|
||||||
|
|
||||||
// Singleton
|
// Singleton
|
||||||
Asset *Asset::instance = nullptr;
|
Asset* Asset::instance = nullptr;
|
||||||
|
|
||||||
void Asset::init(const std::string &executable_path) {
|
void Asset::init(const std::string& executable_path) {
|
||||||
Asset::instance = new Asset(executable_path);
|
Asset::instance = new Asset(executable_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,12 +26,12 @@ void Asset::destroy() {
|
|||||||
delete Asset::instance;
|
delete Asset::instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Asset::get() -> Asset * {
|
auto Asset::get() -> Asset* {
|
||||||
return Asset::instance;
|
return Asset::instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Añade un elemento al mapa (función auxiliar)
|
// Añade un elemento al mapa (función auxiliar)
|
||||||
void Asset::addToMap(const std::string &file_path, Type type, bool required, bool absolute) {
|
void Asset::addToMap(const std::string& file_path, Type type, bool required, bool absolute) {
|
||||||
std::string full_path = absolute ? file_path : executable_path_ + file_path;
|
std::string full_path = absolute ? file_path : executable_path_ + file_path;
|
||||||
std::string filename = getFileName(full_path);
|
std::string filename = getFileName(full_path);
|
||||||
|
|
||||||
@@ -42,13 +46,12 @@ void Asset::addToMap(const std::string &file_path, Type type, bool required, boo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Añade un elemento a la lista
|
// Añade un elemento a la lista
|
||||||
void Asset::add(const std::string &file_path, Type type, bool required, bool absolute) {
|
void Asset::add(const std::string& file_path, Type type, bool required, bool absolute) {
|
||||||
addToMap(file_path, type, required, absolute);
|
addToMap(file_path, type, required, absolute);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carga recursos desde un archivo de configuración con soporte para variables
|
// Carga recursos desde un archivo de configuración con soporte para variables
|
||||||
// Carga recursos desde un archivo de configuración con soporte para variables
|
void Asset::loadFromFile(const std::string& config_file_path, const std::string& prefix, const std::string& system_folder) {
|
||||||
void Asset::loadFromFile(const std::string &config_file_path, const std::string &prefix, const std::string &system_folder) {
|
|
||||||
std::ifstream file(config_file_path);
|
std::ifstream file(config_file_path);
|
||||||
if (!file.is_open()) {
|
if (!file.is_open()) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
@@ -93,7 +96,7 @@ void Asset::loadFromFile(const std::string &config_file_path, const std::string
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const std::string &type_str = parts[0];
|
const std::string& type_str = parts[0];
|
||||||
std::string path = parts[1];
|
std::string path = parts[1];
|
||||||
|
|
||||||
// Valores por defecto
|
// Valores por defecto
|
||||||
@@ -114,7 +117,7 @@ void Asset::loadFromFile(const std::string &config_file_path, const std::string
|
|||||||
// Añadir al mapa
|
// Añadir al mapa
|
||||||
addToMap(path, type, required, absolute);
|
addToMap(path, type, required, absolute);
|
||||||
|
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception& e) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Error parsing line %d in config file: %s",
|
"Error parsing line %d in config file: %s",
|
||||||
line_number,
|
line_number,
|
||||||
@@ -122,15 +125,12 @@ void Asset::loadFromFile(const std::string &config_file_path, const std::string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
std::cout << "Loaded " << file_list_.size() << " assets from config file" << '\n';
|
||||||
"Loaded %d assets from config file",
|
|
||||||
static_cast<int>(file_list_.size()));
|
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Devuelve la ruta completa a un fichero (búsqueda O(1))
|
// Devuelve la ruta completa a un fichero (búsqueda O(1))
|
||||||
auto Asset::get(const std::string &filename) const -> std::string {
|
auto Asset::get(const std::string& filename) const -> std::string {
|
||||||
auto it = file_list_.find(filename);
|
auto it = file_list_.find(filename);
|
||||||
if (it != file_list_.end()) {
|
if (it != file_list_.end()) {
|
||||||
return it->second.file;
|
return it->second.file;
|
||||||
@@ -141,7 +141,7 @@ auto Asset::get(const std::string &filename) const -> std::string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carga datos del archivo usando ResourceHelper
|
// Carga datos del archivo usando ResourceHelper
|
||||||
auto Asset::loadData(const std::string &filename) const -> std::vector<uint8_t> {
|
auto Asset::loadData(const std::string& filename) const -> std::vector<uint8_t> {
|
||||||
auto it = file_list_.find(filename);
|
auto it = file_list_.find(filename);
|
||||||
if (it != file_list_.end()) {
|
if (it != file_list_.end()) {
|
||||||
return ResourceHelper::loadFile(it->second.file);
|
return ResourceHelper::loadFile(it->second.file);
|
||||||
@@ -152,7 +152,7 @@ auto Asset::loadData(const std::string &filename) const -> std::vector<uint8_t>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verifica si un recurso existe
|
// Verifica si un recurso existe
|
||||||
auto Asset::exists(const std::string &filename) const -> bool {
|
auto Asset::exists(const std::string& filename) const -> bool {
|
||||||
return file_list_.find(filename) != file_list_.end();
|
return file_list_.find(filename) != file_list_.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,12 +160,13 @@ auto Asset::exists(const std::string &filename) const -> bool {
|
|||||||
auto Asset::check() const -> bool {
|
auto Asset::check() const -> bool {
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n** CHECKING FILES");
|
// SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n** CHECKING FILES");
|
||||||
|
Logger::section("CHECKING FILES", Logger::CYAN);
|
||||||
|
|
||||||
// Agrupar por tipo para mostrar organizado
|
// Agrupar por tipo para mostrar organizado
|
||||||
std::unordered_map<Type, std::vector<const Item *>> by_type;
|
std::unordered_map<Type, std::vector<const Item*>> by_type;
|
||||||
|
|
||||||
for (const auto &[filename, item] : file_list_) {
|
for (const auto& [filename, item] : file_list_) {
|
||||||
if (item.required) {
|
if (item.required) {
|
||||||
by_type[item.type].push_back(&item);
|
by_type[item.type].push_back(&item);
|
||||||
}
|
}
|
||||||
@@ -176,12 +177,10 @@ auto Asset::check() const -> bool {
|
|||||||
Type asset_type = static_cast<Type>(type);
|
Type asset_type = static_cast<Type>(type);
|
||||||
|
|
||||||
if (by_type.find(asset_type) != by_type.end()) {
|
if (by_type.find(asset_type) != by_type.end()) {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
Logger::info(getTypeName(asset_type) + " FILES");
|
||||||
"\n>> %s FILES",
|
|
||||||
getTypeName(asset_type).c_str());
|
|
||||||
|
|
||||||
bool type_success = true;
|
bool type_success = true;
|
||||||
for (const auto *item : by_type[asset_type]) {
|
for (const auto* item : by_type[asset_type]) {
|
||||||
if (!checkFile(item->file)) {
|
if (!checkFile(item->file)) {
|
||||||
success = false;
|
success = false;
|
||||||
type_success = false;
|
type_success = false;
|
||||||
@@ -189,45 +188,43 @@ auto Asset::check() const -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type_success) {
|
if (type_success) {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, " All files are OK.");
|
Logger::info("All files are OK.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resultado
|
|
||||||
if (success) {
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n** CHECKING FILES COMPLETED.\n");
|
|
||||||
} else {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "\n** CHECKING FILES FAILED.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba que existe un fichero
|
// Comprueba que existe un fichero
|
||||||
auto Asset::checkFile(const std::string &path) -> bool {
|
auto Asset::checkFile(const std::string& path) const -> bool {
|
||||||
// Intentar primero con ResourceHelper
|
// Construir ruta del pack usando executable_path_ (misma lógica que Director::init)
|
||||||
auto data = ResourceHelper::loadFile(path);
|
#ifdef MACOS_BUNDLE
|
||||||
bool success = !data.empty();
|
std::string pack_path = executable_path_ + "../Resources/resources.pack";
|
||||||
|
#else
|
||||||
// Si no se encuentra en el pack, intentar con filesystem directo
|
std::string pack_path = executable_path_ + "resources.pack";
|
||||||
if (!success) {
|
#endif
|
||||||
std::ifstream file(path);
|
bool pack_exists = std::filesystem::exists(pack_path);
|
||||||
success = file.good();
|
|
||||||
file.close();
|
if (pack_exists) {
|
||||||
}
|
// MODO PACK: Usar ResourceHelper (igual que la carga real)
|
||||||
|
auto data = ResourceHelper::loadFile(path);
|
||||||
|
return !data.empty();
|
||||||
|
} // MODO FILESYSTEM: Verificación directa (modo desarrollo)
|
||||||
|
std::ifstream file(path);
|
||||||
|
bool success = file.good();
|
||||||
|
file.close();
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Checking file: %s [ ERROR ]",
|
"Error: Could not open file: %s",
|
||||||
getFileName(path).c_str());
|
path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parsea string a Type
|
// Parsea string a Type
|
||||||
auto Asset::parseAssetType(const std::string &type_str) -> Type {
|
auto Asset::parseAssetType(const std::string& type_str) -> Type {
|
||||||
if (type_str == "BITMAP") {
|
if (type_str == "BITMAP") {
|
||||||
return Type::BITMAP;
|
return Type::BITMAP;
|
||||||
}
|
}
|
||||||
@@ -289,17 +286,20 @@ auto Asset::getTypeName(Type type) -> std::string {
|
|||||||
auto Asset::getListByType(Type type) const -> std::vector<std::string> {
|
auto Asset::getListByType(Type type) const -> std::vector<std::string> {
|
||||||
std::vector<std::string> list;
|
std::vector<std::string> list;
|
||||||
|
|
||||||
for (const auto &[filename, item] : file_list_) {
|
for (const auto& [filename, item] : file_list_) {
|
||||||
if (item.type == type) {
|
if (item.type == type) {
|
||||||
list.push_back(item.file);
|
list.push_back(item.file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ordenar alfabéticamente para garantizar orden consistente
|
||||||
|
std::ranges::sort(list);
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reemplaza variables en las rutas
|
// Reemplaza variables en las rutas
|
||||||
auto Asset::replaceVariables(const std::string &path, const std::string &prefix, const std::string &system_folder) -> std::string {
|
auto Asset::replaceVariables(const std::string& path, const std::string& prefix, const std::string& system_folder) -> std::string {
|
||||||
std::string result = path;
|
std::string result = path;
|
||||||
|
|
||||||
// Reemplazar ${PREFIX}
|
// Reemplazar ${PREFIX}
|
||||||
@@ -320,7 +320,7 @@ auto Asset::replaceVariables(const std::string &path, const std::string &prefix,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parsea las opciones de una línea de configuración
|
// Parsea las opciones de una línea de configuración
|
||||||
auto Asset::parseOptions(const std::string &options, bool &required, bool &absolute) -> void {
|
auto Asset::parseOptions(const std::string& options, bool& required, bool& absolute) -> void {
|
||||||
if (options.empty()) {
|
if (options.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint> // Para uint8_t
|
||||||
#include <string> // Para string
|
#include <string> // Para string
|
||||||
#include <unordered_map> // Para unordered_map
|
#include <unordered_map> // Para unordered_map
|
||||||
#include <utility> // Para move
|
#include <utility> // Para move
|
||||||
#include <vector> // Para vector
|
#include <vector> // Para vector
|
||||||
#include <cstdint> // Para uint8_t
|
|
||||||
|
|
||||||
// --- Clase Asset: gestor optimizado de recursos (singleton) ---
|
// --- Clase Asset: gestor optimizado de recursos (singleton) ---
|
||||||
class Asset {
|
class Asset {
|
||||||
@@ -24,20 +24,20 @@ class Asset {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// --- Métodos de singleton ---
|
// --- Métodos de singleton ---
|
||||||
static void init(const std::string &executable_path);
|
static void init(const std::string& executable_path);
|
||||||
static void destroy();
|
static void destroy();
|
||||||
static auto get() -> Asset *;
|
static auto get() -> Asset*;
|
||||||
Asset(const Asset &) = delete;
|
Asset(const Asset&) = delete;
|
||||||
auto operator=(const Asset &) -> Asset & = delete;
|
auto operator=(const Asset&) -> Asset& = delete;
|
||||||
|
|
||||||
// --- Métodos para la gestión de recursos ---
|
// --- Métodos para la gestión de recursos ---
|
||||||
void add(const std::string &file_path, Type type, bool required = true, bool absolute = false);
|
void add(const std::string& file_path, Type type, bool required = true, bool absolute = false);
|
||||||
void loadFromFile(const std::string &config_file_path, const std::string &prefix = "", const std::string &system_folder = ""); // Con soporte para variables
|
void loadFromFile(const std::string& config_file_path, const std::string& prefix = "", const std::string& system_folder = ""); // Con soporte para variables
|
||||||
[[nodiscard]] auto get(const std::string &filename) const -> std::string; // Mantener nombre original
|
[[nodiscard]] auto get(const std::string& filename) const -> std::string; // Mantener nombre original
|
||||||
[[nodiscard]] auto loadData(const std::string &filename) const -> std::vector<uint8_t>; // Carga datos del archivo
|
[[nodiscard]] auto loadData(const std::string& filename) const -> std::vector<uint8_t>; // Carga datos del archivo
|
||||||
[[nodiscard]] auto check() const -> bool;
|
[[nodiscard]] auto check() const -> bool;
|
||||||
[[nodiscard]] auto getListByType(Type type) const -> std::vector<std::string>;
|
[[nodiscard]] auto getListByType(Type type) const -> std::vector<std::string>;
|
||||||
[[nodiscard]] auto exists(const std::string &filename) const -> bool; // Nueva función para verificar existencia
|
[[nodiscard]] auto exists(const std::string& filename) const -> bool; // Nueva función para verificar existencia
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// --- Estructuras privadas ---
|
// --- Estructuras privadas ---
|
||||||
@@ -47,7 +47,9 @@ class Asset {
|
|||||||
bool required; // Indica si el archivo es obligatorio
|
bool required; // Indica si el archivo es obligatorio
|
||||||
|
|
||||||
Item(std::string path, Type asset_type, bool is_required)
|
Item(std::string path, Type asset_type, bool is_required)
|
||||||
: file(std::move(path)), type(asset_type), required(is_required) {}
|
: file(std::move(path)),
|
||||||
|
type(asset_type),
|
||||||
|
required(is_required) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- Variables internas ---
|
// --- Variables internas ---
|
||||||
@@ -55,12 +57,12 @@ class Asset {
|
|||||||
std::string executable_path_; // Ruta del ejecutable
|
std::string executable_path_; // Ruta del ejecutable
|
||||||
|
|
||||||
// --- Métodos internos ---
|
// --- Métodos internos ---
|
||||||
[[nodiscard]] static auto checkFile(const std::string &path) -> bool; // Verifica si un archivo existe
|
[[nodiscard]] auto checkFile(const std::string& path) const -> bool; // Verifica si un archivo existe
|
||||||
[[nodiscard]] static auto getTypeName(Type type) -> std::string; // Obtiene el nombre del tipo
|
[[nodiscard]] static auto getTypeName(Type type) -> std::string; // Obtiene el nombre del tipo
|
||||||
[[nodiscard]] static auto parseAssetType(const std::string &type_str) -> Type; // Convierte string a tipo
|
[[nodiscard]] static auto parseAssetType(const std::string& type_str) -> Type; // Convierte string a tipo
|
||||||
void addToMap(const std::string &file_path, Type type, bool required, bool absolute); // Añade archivo al mapa
|
void addToMap(const std::string& file_path, Type type, bool required, bool absolute); // Añade archivo al mapa
|
||||||
[[nodiscard]] static auto replaceVariables(const std::string &path, const std::string &prefix, const std::string &system_folder) -> std::string; // Reemplaza variables en la ruta
|
[[nodiscard]] static auto replaceVariables(const std::string& path, const std::string& prefix, const std::string& system_folder) -> std::string; // Reemplaza variables en la ruta
|
||||||
static auto parseOptions(const std::string &options, bool &required, bool &absolute) -> void; // Parsea opciones
|
static auto parseOptions(const std::string& options, bool& required, bool& absolute) -> void; // Parsea opciones
|
||||||
|
|
||||||
// --- Constructores y destructor privados (singleton) ---
|
// --- Constructores y destructor privados (singleton) ---
|
||||||
explicit Asset(std::string executable_path) // Constructor privado
|
explicit Asset(std::string executable_path) // Constructor privado
|
||||||
@@ -68,5 +70,5 @@ class Asset {
|
|||||||
~Asset() = default; // Destructor privado
|
~Asset() = default; // Destructor privado
|
||||||
|
|
||||||
// --- Instancia singleton ---
|
// --- Instancia singleton ---
|
||||||
static Asset *instance; // Instancia única de Asset
|
static Asset* instance; // Instancia única de Asset
|
||||||
};
|
};
|
||||||
@@ -1,105 +1,106 @@
|
|||||||
#include "asset_integrated.h"
|
#include "asset_integrated.hpp"
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
bool AssetIntegrated::resource_pack_enabled_ = false;
|
bool AssetIntegrated::resource_pack_enabled = false;
|
||||||
|
|
||||||
void AssetIntegrated::initWithResourcePack(const std::string &executable_path,
|
void AssetIntegrated::initWithResourcePack(const std::string& executable_path,
|
||||||
const std::string &resource_pack_path) {
|
const std::string& resource_pack_path) {
|
||||||
// Inicializar Asset normal
|
// Inicializar Asset normal
|
||||||
Asset::init(executable_path);
|
Asset::init(executable_path);
|
||||||
|
|
||||||
// Inicializar ResourceLoader
|
// Inicializar ResourceLoader
|
||||||
auto& loader = ResourceLoader::getInstance();
|
auto& loader = ResourceLoader::getInstance();
|
||||||
if (loader.initialize(resource_pack_path, true)) {
|
if (loader.initialize(resource_pack_path, true)) {
|
||||||
resource_pack_enabled_ = true;
|
resource_pack_enabled = true;
|
||||||
std::cout << "Asset system initialized with resource pack: " << resource_pack_path << std::endl;
|
std::cout << "Asset system initialized with resource pack: " << resource_pack_path << '\n';
|
||||||
} else {
|
} else {
|
||||||
resource_pack_enabled_ = false;
|
resource_pack_enabled = false;
|
||||||
std::cout << "Asset system initialized in fallback mode (filesystem)" << std::endl;
|
std::cout << "Asset system initialized in fallback mode (filesystem)" << '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> AssetIntegrated::loadFile(const std::string &filename) {
|
auto AssetIntegrated::loadFile(const std::string& filename) -> std::vector<uint8_t> {
|
||||||
if (shouldUseResourcePack(filename) && resource_pack_enabled_) {
|
if (shouldUseResourcePack(filename) && resource_pack_enabled) {
|
||||||
// Intentar cargar del pack de recursos
|
// Intentar cargar del pack de recursos
|
||||||
auto& loader = ResourceLoader::getInstance();
|
auto& loader = ResourceLoader::getInstance();
|
||||||
|
|
||||||
// Convertir ruta completa a ruta relativa para el pack
|
// Convertir ruta completa a ruta relativa para el pack
|
||||||
std::string relativePath = filename;
|
std::string relative_path = filename;
|
||||||
|
|
||||||
// Si la ruta contiene "data/", extraer la parte relativa
|
// Si la ruta contiene "data/", extraer la parte relativa
|
||||||
size_t dataPos = filename.find("data/");
|
size_t data_pos = filename.find("data/");
|
||||||
if (dataPos != std::string::npos) {
|
if (data_pos != std::string::npos) {
|
||||||
relativePath = filename.substr(dataPos + 5); // +5 para saltar "data/"
|
relative_path = filename.substr(data_pos + 5); // +5 para saltar "data/"
|
||||||
}
|
}
|
||||||
|
|
||||||
auto data = loader.loadResource(relativePath);
|
auto data = loader.loadResource(relative_path);
|
||||||
if (!data.empty()) {
|
if (!data.empty()) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback: cargar del filesystem
|
// Fallback: cargar del filesystem
|
||||||
std::ifstream file(filename, std::ios::binary | std::ios::ate);
|
std::ifstream file(filename, std::ios::binary | std::ios::ate);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
std::cerr << "Error: Could not open file: " << filename << std::endl;
|
std::cerr << "Error: Could not open file: " << filename << '\n';
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::streamsize fileSize = file.tellg();
|
std::streamsize file_size = file.tellg();
|
||||||
file.seekg(0, std::ios::beg);
|
file.seekg(0, std::ios::beg);
|
||||||
|
|
||||||
std::vector<uint8_t> data(fileSize);
|
std::vector<uint8_t> data(file_size);
|
||||||
if (!file.read(reinterpret_cast<char*>(data.data()), fileSize)) {
|
if (!file.read(reinterpret_cast<char*>(data.data()), file_size)) {
|
||||||
std::cerr << "Error: Could not read file: " << filename << std::endl;
|
std::cerr << "Error: Could not read file: " << filename << '\n';
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AssetIntegrated::fileExists(const std::string &filename) const {
|
auto AssetIntegrated::fileExists(const std::string& filename) -> bool {
|
||||||
if (shouldUseResourcePack(filename) && resource_pack_enabled_) {
|
if (shouldUseResourcePack(filename) && resource_pack_enabled) {
|
||||||
auto& loader = ResourceLoader::getInstance();
|
auto& loader = ResourceLoader::getInstance();
|
||||||
|
|
||||||
// Convertir ruta completa a ruta relativa para el pack
|
// Convertir ruta completa a ruta relativa para el pack
|
||||||
std::string relativePath = filename;
|
std::string relative_path = filename;
|
||||||
size_t dataPos = filename.find("data/");
|
size_t data_pos = filename.find("data/");
|
||||||
if (dataPos != std::string::npos) {
|
if (data_pos != std::string::npos) {
|
||||||
relativePath = filename.substr(dataPos + 5);
|
relative_path = filename.substr(data_pos + 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loader.resourceExists(relativePath)) {
|
if (loader.resourceExists(relative_path)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verificar en filesystem
|
// Verificar en filesystem
|
||||||
return std::filesystem::exists(filename);
|
return std::filesystem::exists(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AssetIntegrated::getSystemPath(const std::string &filename) const {
|
auto AssetIntegrated::getSystemPath(const std::string& filename) -> std::string {
|
||||||
// Los archivos de sistema/config siempre van al filesystem
|
// Los archivos de sistema/config siempre van al filesystem
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AssetIntegrated::shouldUseResourcePack(const std::string &filepath) const {
|
auto AssetIntegrated::shouldUseResourcePack(const std::string& filepath) -> bool {
|
||||||
// Los archivos que NO van al pack:
|
// Los archivos que NO van al pack:
|
||||||
// - Archivos de config/ (ahora están fuera de data/)
|
// - Archivos de config/ (ahora están fuera de data/)
|
||||||
// - Archivos con absolute=true en assets.txt
|
// - Archivos con absolute=true en assets.txt
|
||||||
// - Archivos de sistema (${SYSTEM_FOLDER})
|
// - Archivos de sistema (${SYSTEM_FOLDER})
|
||||||
|
|
||||||
if (filepath.find("/config/") != std::string::npos ||
|
if (filepath.find("/config/") != std::string::npos ||
|
||||||
filepath.find("config/") == 0) {
|
filepath.starts_with("config/")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filepath.find("/data/") != std::string::npos ||
|
if (filepath.find("/data/") != std::string::npos ||
|
||||||
filepath.find("data/") == 0) {
|
filepath.starts_with("data/")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "asset.h"
|
|
||||||
#include "resource_loader.h"
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
// Extensión de Asset que integra ResourceLoader
|
|
||||||
class AssetIntegrated : public Asset {
|
|
||||||
public:
|
|
||||||
// Inicializa Asset con ResourceLoader
|
|
||||||
static void initWithResourcePack(const std::string &executable_path,
|
|
||||||
const std::string &resource_pack_path = "resources.pack");
|
|
||||||
|
|
||||||
// Carga un archivo usando ResourceLoader como primera opción
|
|
||||||
std::vector<uint8_t> loadFile(const std::string &filename);
|
|
||||||
|
|
||||||
// Verifica si un archivo existe (pack o filesystem)
|
|
||||||
bool fileExists(const std::string &filename) const;
|
|
||||||
|
|
||||||
// Obtiene la ruta completa para archivos del sistema/config
|
|
||||||
std::string getSystemPath(const std::string &filename) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
static bool resource_pack_enabled_;
|
|
||||||
|
|
||||||
// Determina si un archivo debe cargarse del pack o del filesystem
|
|
||||||
bool shouldUseResourcePack(const std::string &filepath) const;
|
|
||||||
};
|
|
||||||
29
source/asset_integrated.hpp
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "asset.hpp"
|
||||||
|
#include "resource_loader.hpp"
|
||||||
|
|
||||||
|
// Extensión de Asset que integra ResourceLoader
|
||||||
|
class AssetIntegrated : public Asset {
|
||||||
|
public:
|
||||||
|
// Inicializa Asset con ResourceLoader
|
||||||
|
static void initWithResourcePack(const std::string& executable_path,
|
||||||
|
const std::string& resource_pack_path = "resources.pack");
|
||||||
|
|
||||||
|
// Carga un archivo usando ResourceLoader como primera opción
|
||||||
|
static auto loadFile(const std::string& filename) -> std::vector<uint8_t>;
|
||||||
|
|
||||||
|
// Verifica si un archivo existe (pack o filesystem)
|
||||||
|
static auto fileExists(const std::string& filename) -> bool;
|
||||||
|
|
||||||
|
// Obtiene la ruta completa para archivos del sistema/config
|
||||||
|
static auto getSystemPath(const std::string& filename) -> std::string;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static bool resource_pack_enabled;
|
||||||
|
|
||||||
|
// Determina si un archivo debe cargarse del pack o del filesystem
|
||||||
|
static auto shouldUseResourcePack(const std::string& filepath) -> bool;
|
||||||
|
};
|
||||||
@@ -1,17 +1,16 @@
|
|||||||
#include "audio.h"
|
#include "audio.hpp"
|
||||||
|
|
||||||
#include <SDL3/SDL.h> // Para SDL_LogInfo, SDL_LogCategory, SDL_G...
|
#include <SDL3/SDL.h> // Para SDL_LogInfo, SDL_LogCategory, SDL_G...
|
||||||
|
|
||||||
#include <algorithm> // Para clamp
|
#include <algorithm> // Para clamp
|
||||||
|
|
||||||
#ifndef NO_AUDIO
|
|
||||||
#include "external/jail_audio.h" // Para JA_FadeOutMusic, JA_Init, JA_PauseM...
|
#include "external/jail_audio.h" // Para JA_FadeOutMusic, JA_Init, JA_PauseM...
|
||||||
#endif
|
#include "options.hpp" // Para AudioOptions, audio, MusicOptions
|
||||||
#include "options.h" // Para AudioOptions, audio, MusicOptions
|
#include "resource.hpp" // Para Resource
|
||||||
#include "resource.h" // Para Resource
|
#include "ui/logger.hpp" // Para logger
|
||||||
|
|
||||||
// Singleton
|
// Singleton
|
||||||
Audio *Audio::instance = nullptr;
|
Audio* Audio::instance = nullptr;
|
||||||
|
|
||||||
// Inicializa la instancia única del singleton
|
// Inicializa la instancia única del singleton
|
||||||
void Audio::init() { Audio::instance = new Audio(); }
|
void Audio::init() { Audio::instance = new Audio(); }
|
||||||
@@ -20,16 +19,14 @@ void Audio::init() { Audio::instance = new Audio(); }
|
|||||||
void Audio::destroy() { delete Audio::instance; }
|
void Audio::destroy() { delete Audio::instance; }
|
||||||
|
|
||||||
// Obtiene la instancia
|
// Obtiene la instancia
|
||||||
auto Audio::get() -> Audio * { return Audio::instance; }
|
auto Audio::get() -> Audio* { return Audio::instance; }
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Audio::Audio() { initSDLAudio(); }
|
Audio::Audio() { initSDLAudio(); }
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
Audio::~Audio() {
|
Audio::~Audio() {
|
||||||
#ifndef NO_AUDIO
|
|
||||||
JA_Quit();
|
JA_Quit();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Método principal
|
// Método principal
|
||||||
@@ -38,14 +35,12 @@ void Audio::update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reproduce la música
|
// Reproduce la música
|
||||||
void Audio::playMusic(const std::string &name, const int loop) {
|
void Audio::playMusic(const std::string& name, const int loop) {
|
||||||
music_.name = name;
|
music_.name = name;
|
||||||
music_.loop = (loop != 0);
|
music_.loop = (loop != 0);
|
||||||
|
|
||||||
if (music_enabled_ && music_.state != MusicState::PLAYING) {
|
if (music_enabled_ && music_.state != MusicState::PLAYING) {
|
||||||
#ifndef NO_AUDIO
|
|
||||||
JA_PlayMusic(Resource::get()->getMusic(name), loop);
|
JA_PlayMusic(Resource::get()->getMusic(name), loop);
|
||||||
#endif
|
|
||||||
music_.state = MusicState::PLAYING;
|
music_.state = MusicState::PLAYING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,9 +48,7 @@ void Audio::playMusic(const std::string &name, const int loop) {
|
|||||||
// Pausa la música
|
// Pausa la música
|
||||||
void Audio::pauseMusic() {
|
void Audio::pauseMusic() {
|
||||||
if (music_enabled_ && music_.state == MusicState::PLAYING) {
|
if (music_enabled_ && music_.state == MusicState::PLAYING) {
|
||||||
#ifndef NO_AUDIO
|
|
||||||
JA_PauseMusic();
|
JA_PauseMusic();
|
||||||
#endif
|
|
||||||
music_.state = MusicState::PAUSED;
|
music_.state = MusicState::PAUSED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,9 +56,7 @@ void Audio::pauseMusic() {
|
|||||||
// Continua la música pausada
|
// Continua la música pausada
|
||||||
void Audio::resumeMusic() {
|
void Audio::resumeMusic() {
|
||||||
if (music_enabled_ && music_.state == MusicState::PAUSED) {
|
if (music_enabled_ && music_.state == MusicState::PAUSED) {
|
||||||
#ifndef NO_AUDIO
|
|
||||||
JA_ResumeMusic();
|
JA_ResumeMusic();
|
||||||
#endif
|
|
||||||
music_.state = MusicState::PLAYING;
|
music_.state = MusicState::PLAYING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,37 +64,45 @@ void Audio::resumeMusic() {
|
|||||||
// Detiene la música
|
// Detiene la música
|
||||||
void Audio::stopMusic() {
|
void Audio::stopMusic() {
|
||||||
if (music_enabled_) {
|
if (music_enabled_) {
|
||||||
#ifndef NO_AUDIO
|
|
||||||
JA_StopMusic();
|
JA_StopMusic();
|
||||||
#endif
|
|
||||||
music_.state = MusicState::STOPPED;
|
music_.state = MusicState::STOPPED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reproduce un sonido
|
// Reproduce un sonido
|
||||||
void Audio::playSound(const std::string &name, Group group) const {
|
void Audio::playSound(const std::string& name, Group group) const {
|
||||||
if (sound_enabled_) {
|
if (sound_enabled_) {
|
||||||
#ifndef NO_AUDIO
|
|
||||||
JA_PlaySound(Resource::get()->getSound(name), 0, static_cast<int>(group));
|
JA_PlaySound(Resource::get()->getSound(name), 0, static_cast<int>(group));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detiene todos los sonidos
|
// Detiene todos los sonidos
|
||||||
void Audio::stopAllSounds() const {
|
void Audio::stopAllSounds() const {
|
||||||
if (sound_enabled_) {
|
if (sound_enabled_) {
|
||||||
#ifndef NO_AUDIO
|
|
||||||
JA_StopChannel(-1);
|
JA_StopChannel(-1);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Realiza un fundido de salida de la música
|
// Realiza un fundido de salida de la música
|
||||||
void Audio::fadeOutMusic(int milliseconds) const {
|
void Audio::fadeOutMusic(int milliseconds) const {
|
||||||
if (music_enabled_) {
|
if (music_enabled_ && getRealMusicState() == MusicState::PLAYING) {
|
||||||
#ifndef NO_AUDIO
|
|
||||||
JA_FadeOutMusic(milliseconds);
|
JA_FadeOutMusic(milliseconds);
|
||||||
#endif
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Consulta directamente el estado real de la música en jailaudio
|
||||||
|
auto Audio::getRealMusicState() -> MusicState {
|
||||||
|
JA_Music_state ja_state = JA_GetMusicState();
|
||||||
|
switch (ja_state) {
|
||||||
|
case JA_MUSIC_PLAYING:
|
||||||
|
return MusicState::PLAYING;
|
||||||
|
case JA_MUSIC_PAUSED:
|
||||||
|
return MusicState::PAUSED;
|
||||||
|
case JA_MUSIC_STOPPED:
|
||||||
|
case JA_MUSIC_INVALID:
|
||||||
|
case JA_MUSIC_DISABLED:
|
||||||
|
default:
|
||||||
|
return MusicState::STOPPED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,10 +110,8 @@ void Audio::fadeOutMusic(int milliseconds) const {
|
|||||||
void Audio::setSoundVolume(int sound_volume, Group group) const {
|
void Audio::setSoundVolume(int sound_volume, Group group) const {
|
||||||
if (sound_enabled_) {
|
if (sound_enabled_) {
|
||||||
sound_volume = std::clamp(sound_volume, MIN_VOLUME, MAX_VOLUME);
|
sound_volume = std::clamp(sound_volume, MIN_VOLUME, MAX_VOLUME);
|
||||||
#ifndef NO_AUDIO
|
|
||||||
const float CONVERTED_VOLUME = (sound_volume / 100.0F) * (Options::audio.volume / 100.0F);
|
const float CONVERTED_VOLUME = (sound_volume / 100.0F) * (Options::audio.volume / 100.0F);
|
||||||
JA_SetSoundVolume(CONVERTED_VOLUME, static_cast<int>(group));
|
JA_SetSoundVolume(CONVERTED_VOLUME, static_cast<int>(group));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,10 +119,8 @@ void Audio::setSoundVolume(int sound_volume, Group group) const {
|
|||||||
void Audio::setMusicVolume(int music_volume) const {
|
void Audio::setMusicVolume(int music_volume) const {
|
||||||
if (music_enabled_) {
|
if (music_enabled_) {
|
||||||
music_volume = std::clamp(music_volume, MIN_VOLUME, MAX_VOLUME);
|
music_volume = std::clamp(music_volume, MIN_VOLUME, MAX_VOLUME);
|
||||||
#ifndef NO_AUDIO
|
|
||||||
const float CONVERTED_VOLUME = (music_volume / 100.0F) * (Options::audio.volume / 100.0F);
|
const float CONVERTED_VOLUME = (music_volume / 100.0F) * (Options::audio.volume / 100.0F);
|
||||||
JA_SetMusicVolume(CONVERTED_VOLUME);
|
JA_SetMusicVolume(CONVERTED_VOLUME);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,16 +139,12 @@ void Audio::enable(bool value) {
|
|||||||
|
|
||||||
// Inicializa SDL Audio
|
// Inicializa SDL Audio
|
||||||
void Audio::initSDLAudio() {
|
void Audio::initSDLAudio() {
|
||||||
#ifndef NO_AUDIO
|
|
||||||
if (!SDL_Init(SDL_INIT_AUDIO)) {
|
if (!SDL_Init(SDL_INIT_AUDIO)) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_AUDIO could not initialize! SDL Error: %s", SDL_GetError());
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_AUDIO could not initialize! SDL Error: %s", SDL_GetError());
|
||||||
} else {
|
} else {
|
||||||
JA_Init(FREQUENCY, SDL_AUDIO_S16LE, 2);
|
JA_Init(FREQUENCY, SDL_AUDIO_S16LE, 2);
|
||||||
enable(Options::audio.enabled);
|
enable(Options::audio.enabled);
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "** Audio system initialized successfully");
|
Logger::info("Audio system initialized successfully");
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "** Audio system disabled");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
@@ -13,30 +13,36 @@ class Audio {
|
|||||||
INTERFACE = 1 // Sonidos de la interfaz
|
INTERFACE = 1 // Sonidos de la interfaz
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class MusicState {
|
||||||
|
PLAYING, // Reproduciendo música
|
||||||
|
PAUSED, // Música pausada
|
||||||
|
STOPPED, // Música detenida
|
||||||
|
};
|
||||||
|
|
||||||
// --- Constantes ---
|
// --- Constantes ---
|
||||||
static constexpr int MAX_VOLUME = 100; // Volumen máximo
|
static constexpr int MAX_VOLUME = 100; // Volumen máximo
|
||||||
static constexpr int MIN_VOLUME = 0; // Volumen mínimo
|
static constexpr int MIN_VOLUME = 0; // Volumen mínimo
|
||||||
static constexpr int FREQUENCY = 48000; // Frecuencia de audio
|
static constexpr int FREQUENCY = 48000; // Frecuencia de audio
|
||||||
|
|
||||||
// --- Métodos de singleton ---
|
// --- Métodos de singleton ---
|
||||||
static void init(); // Inicializa el objeto Audio
|
static void init(); // Inicializa el objeto Audio
|
||||||
static void destroy(); // Libera el objeto Audio
|
static void destroy(); // Libera el objeto Audio
|
||||||
static auto get() -> Audio *; // Obtiene el puntero al objeto Audio
|
static auto get() -> Audio*; // Obtiene el puntero al objeto Audio
|
||||||
Audio(const Audio &) = delete; // Evitar copia
|
Audio(const Audio&) = delete; // Evitar copia
|
||||||
auto operator=(const Audio &) -> Audio & = delete; // Evitar asignación
|
auto operator=(const Audio&) -> Audio& = delete; // Evitar asignación
|
||||||
|
|
||||||
// --- Método principal ---
|
// --- Método principal ---
|
||||||
static void update();
|
static void update();
|
||||||
|
|
||||||
// --- Control de Música ---
|
// --- Control de Música ---
|
||||||
void playMusic(const std::string &name, int loop = -1); // Reproducir música en bucle
|
void playMusic(const std::string& name, int loop = -1); // Reproducir música en bucle
|
||||||
void pauseMusic(); // Pausar reproducción de música
|
void pauseMusic(); // Pausar reproducción de música
|
||||||
void resumeMusic(); // Continua la música pausada
|
void resumeMusic(); // Continua la música pausada
|
||||||
void stopMusic(); // Detener completamente la música
|
void stopMusic(); // Detener completamente la música
|
||||||
void fadeOutMusic(int milliseconds) const; // Fundido de salida de la música
|
void fadeOutMusic(int milliseconds) const; // Fundido de salida de la música
|
||||||
|
|
||||||
// --- Control de Sonidos ---
|
// --- Control de Sonidos ---
|
||||||
void playSound(const std::string &name, Group group = Group::GAME) const; // Reproducir sonido puntual
|
void playSound(const std::string& name, Group group = Group::GAME) const; // Reproducir sonido puntual
|
||||||
void stopAllSounds() const; // Detener todos los sonidos
|
void stopAllSounds() const; // Detener todos los sonidos
|
||||||
|
|
||||||
// --- Configuración General ---
|
// --- Configuración General ---
|
||||||
@@ -60,14 +66,15 @@ class Audio {
|
|||||||
void setSoundVolume(int volume, Group group = Group::ALL) const; // Ajustar volumen de efectos
|
void setSoundVolume(int volume, Group group = Group::ALL) const; // Ajustar volumen de efectos
|
||||||
void setMusicVolume(int volume) const; // Ajustar volumen de música
|
void setMusicVolume(int volume) const; // Ajustar volumen de música
|
||||||
|
|
||||||
private:
|
// --- Getters para debug ---
|
||||||
// --- Enums privados ---
|
[[nodiscard]] auto isEnabled() const -> bool { return enabled_; }
|
||||||
enum class MusicState {
|
[[nodiscard]] auto isSoundEnabled() const -> bool { return sound_enabled_; }
|
||||||
PLAYING, // Reproduciendo música
|
[[nodiscard]] auto isMusicEnabled() const -> bool { return music_enabled_; }
|
||||||
PAUSED, // Música pausada
|
[[nodiscard]] auto getMusicState() const -> MusicState { return music_.state; }
|
||||||
STOPPED, // Música detenida
|
[[nodiscard]] static auto getRealMusicState() -> MusicState; // Consulta directamente a jailaudio
|
||||||
};
|
[[nodiscard]] auto getCurrentMusicName() const -> const std::string& { return music_.name; }
|
||||||
|
|
||||||
|
private:
|
||||||
// --- Estructuras privadas ---
|
// --- Estructuras privadas ---
|
||||||
struct Music {
|
struct Music {
|
||||||
MusicState state; // Estado actual de la música (reproduciendo, detenido, en pausa)
|
MusicState state; // Estado actual de la música (reproduciendo, detenido, en pausa)
|
||||||
@@ -75,11 +82,15 @@ class Audio {
|
|||||||
bool loop; // Indica si la última pista de música se debe reproducir en bucle
|
bool loop; // Indica si la última pista de música se debe reproducir en bucle
|
||||||
|
|
||||||
// Constructor para inicializar la música con valores predeterminados
|
// Constructor para inicializar la música con valores predeterminados
|
||||||
Music() : state(MusicState::STOPPED), loop(false) {}
|
Music()
|
||||||
|
: state(MusicState::STOPPED),
|
||||||
|
loop(false) {}
|
||||||
|
|
||||||
// Constructor para inicializar con valores específicos
|
// Constructor para inicializar con valores específicos
|
||||||
Music(MusicState init_state, std::string init_name, bool init_loop)
|
Music(MusicState init_state, std::string init_name, bool init_loop)
|
||||||
: state(init_state), name(std::move(init_name)), loop(init_loop) {}
|
: state(init_state),
|
||||||
|
name(std::move(init_name)),
|
||||||
|
loop(init_loop) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- Variables de estado ---
|
// --- Variables de estado ---
|
||||||
@@ -96,5 +107,5 @@ class Audio {
|
|||||||
~Audio(); // Destructor privado
|
~Audio(); // Destructor privado
|
||||||
|
|
||||||
// --- Instancia singleton ---
|
// --- Instancia singleton ---
|
||||||
static Audio *instance; // Instancia única de Audio
|
static Audio* instance; // Instancia única de Audio
|
||||||
};
|
};
|
||||||
@@ -1,18 +1,21 @@
|
|||||||
#define _USE_MATH_DEFINES
|
#define _USE_MATH_DEFINES
|
||||||
#include "background.h"
|
#include "background.hpp"
|
||||||
|
|
||||||
#include <SDL3/SDL.h> // Para SDL_FRect, SDL_SetRenderTarget, SDL_CreateTexture, SDL_DestroyTexture, SDL_GetRenderTarget, SDL_RenderTexture, SDL_SetTextureAlphaMod, SDL_SetTextureBlendMode, SDL_BLENDMODE_BLEND, SDL_PixelFormat, SDL_RenderClear, SDL_SetRenderDrawColor, SDL_TextureAccess, SDL_FPoint
|
#include <SDL3/SDL.h> // Para SDL_FRect, SDL_SetRenderTarget, SDL_CreateTexture, SDL_DestroyTexture, SDL_GetRenderTarget, SDL_RenderTexture, SDL_SetTextureAlphaMod, SDL_SetTextureBlendMode, SDL_BLENDMODE_BLEND, SDL_PixelFormat, SDL_RenderClear, SDL_SetRenderDrawColor, SDL_TextureAccess, SDL_FPoint
|
||||||
|
|
||||||
#include <algorithm> // Para clamp, max
|
#include <algorithm> // Para clamp, min, max
|
||||||
#include <cmath> // Para M_PI, cos, sin
|
#include <cmath> // Para M_PI, cos, sin
|
||||||
#include <utility>
|
#include <string> // Para basic_string
|
||||||
|
#include <utility> // Para move
|
||||||
|
|
||||||
#include "moving_sprite.h" // Para MovingSprite
|
#include "animated_sprite.hpp" // Para AnimatedSprite
|
||||||
#include "param.h" // Para Param, ParamBackground, param
|
#include "moving_sprite.hpp" // Para MovingSprite
|
||||||
#include "resource.h" // Para Resource
|
#include "param.hpp" // Para Param, ParamBackground, param
|
||||||
#include "screen.h" // Para Screen
|
#include "resource.hpp" // Para Resource
|
||||||
#include "sprite.h" // Para Sprite
|
#include "screen.hpp" // Para Screen
|
||||||
#include "texture.h" // Para Texture
|
#include "sprite.hpp" // Para Sprite
|
||||||
|
#include "texture.hpp" // Para Texture
|
||||||
|
#include "utils.hpp" // Para easeOutCubic
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Background::Background(float total_progress_to_complete)
|
Background::Background(float total_progress_to_complete)
|
||||||
@@ -21,14 +24,15 @@ Background::Background(float total_progress_to_complete)
|
|||||||
buildings_texture_(Resource::get()->getTexture("game_buildings.png")),
|
buildings_texture_(Resource::get()->getTexture("game_buildings.png")),
|
||||||
top_clouds_texture_(Resource::get()->getTexture("game_clouds1.png")),
|
top_clouds_texture_(Resource::get()->getTexture("game_clouds1.png")),
|
||||||
bottom_clouds_texture_(Resource::get()->getTexture("game_clouds2.png")),
|
bottom_clouds_texture_(Resource::get()->getTexture("game_clouds2.png")),
|
||||||
grass_texture_(Resource::get()->getTexture("game_grass.png")),
|
|
||||||
gradients_texture_(Resource::get()->getTexture("game_sky_colors.png")),
|
gradients_texture_(Resource::get()->getTexture("game_sky_colors.png")),
|
||||||
sun_texture_(Resource::get()->getTexture("game_sun.png")),
|
sun_texture_(Resource::get()->getTexture("game_sun.png")),
|
||||||
moon_texture_(Resource::get()->getTexture("game_moon.png")),
|
moon_texture_(Resource::get()->getTexture("game_moon.png")),
|
||||||
|
grass_sprite_(std::make_unique<AnimatedSprite>(Resource::get()->getTexture("game_grass.png"), Resource::get()->getAnimation("game_grass.ani"))),
|
||||||
|
|
||||||
total_progress_to_complete_(total_progress_to_complete),
|
total_progress_to_complete_(total_progress_to_complete),
|
||||||
progress_per_stage_(total_progress_to_complete_ / STAGES),
|
progress_per_stage_(total_progress_to_complete_ / STAGES),
|
||||||
sun_completion_progress_(total_progress_to_complete_ * SUN_COMPLETION_FACTOR),
|
sun_completion_progress_(total_progress_to_complete_ * SUN_COMPLETION_FACTOR),
|
||||||
|
minimum_completed_progress_(total_progress_to_complete_ * MINIMUM_COMPLETED_PROGRESS_PERCENTAGE),
|
||||||
|
|
||||||
rect_(SDL_FRect{0, 0, static_cast<float>(gradients_texture_->getWidth() / 2), static_cast<float>(gradients_texture_->getHeight() / 2)}),
|
rect_(SDL_FRect{0, 0, static_cast<float>(gradients_texture_->getWidth() / 2), static_cast<float>(gradients_texture_->getHeight() / 2)}),
|
||||||
src_rect_({.x = 0, .y = 0, .w = 320, .h = 240}),
|
src_rect_({.x = 0, .y = 0, .w = 320, .h = 240}),
|
||||||
@@ -86,30 +90,36 @@ void Background::initializeSprites() {
|
|||||||
|
|
||||||
buildings_sprite_ = std::make_unique<Sprite>(buildings_texture_);
|
buildings_sprite_ = std::make_unique<Sprite>(buildings_texture_);
|
||||||
gradient_sprite_ = std::make_unique<Sprite>(gradients_texture_, 0, 0, rect_.w, rect_.h);
|
gradient_sprite_ = std::make_unique<Sprite>(gradients_texture_, 0, 0, rect_.w, rect_.h);
|
||||||
grass_sprite_ = std::make_unique<Sprite>(grass_texture_, 0, 0, grass_texture_->getWidth(), grass_texture_->getHeight() / 2);
|
|
||||||
sun_sprite_ = std::make_unique<Sprite>(sun_texture_);
|
sun_sprite_ = std::make_unique<Sprite>(sun_texture_);
|
||||||
moon_sprite_ = std::make_unique<Sprite>(moon_texture_);
|
moon_sprite_ = std::make_unique<Sprite>(moon_texture_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configura las propiedades iniciales de los sprites
|
// Configura las propiedades iniciales de los sprites
|
||||||
void Background::initializeSpriteProperties() {
|
void Background::initializeSpriteProperties() {
|
||||||
constexpr float TOP_CLOUDS_SPEED = 0.1F;
|
// Velocidades iniciales que coinciden con updateCloudsSpeed() cuando progress=0
|
||||||
constexpr float BOTTOM_CLOUDS_SPEED = 0.05F;
|
constexpr float INITIAL_TOP_CLOUDS_SPEED_PX_PER_S = 0.05F * 60.0F; // 3.0 píxeles/segundo (coincide con CLOUDS_INITIAL_SPEED)
|
||||||
|
constexpr float INITIAL_BOTTOM_CLOUDS_SPEED_PX_PER_S = 0.05F * 60.0F / 2.0F; // 1.5 píxeles/segundo (mitad de velocidad)
|
||||||
|
|
||||||
top_clouds_sprite_a_->setSpriteClip(0, 0, top_clouds_texture_->getWidth(), top_clouds_texture_->getHeight());
|
top_clouds_sprite_a_->setSpriteClip(0, 0, top_clouds_texture_->getWidth(), top_clouds_texture_->getHeight());
|
||||||
top_clouds_sprite_a_->setVelX(-TOP_CLOUDS_SPEED);
|
top_clouds_sprite_a_->setVelX(-INITIAL_TOP_CLOUDS_SPEED_PX_PER_S);
|
||||||
|
|
||||||
top_clouds_sprite_b_->setSpriteClip(0, 0, top_clouds_texture_->getWidth(), top_clouds_texture_->getHeight());
|
top_clouds_sprite_b_->setSpriteClip(0, 0, top_clouds_texture_->getWidth(), top_clouds_texture_->getHeight());
|
||||||
top_clouds_sprite_b_->setVelX(-TOP_CLOUDS_SPEED);
|
top_clouds_sprite_b_->setVelX(-INITIAL_TOP_CLOUDS_SPEED_PX_PER_S);
|
||||||
|
|
||||||
bottom_clouds_sprite_a_->setSpriteClip(0, 0, bottom_clouds_texture_->getWidth(), bottom_clouds_texture_->getHeight());
|
bottom_clouds_sprite_a_->setSpriteClip(0, 0, bottom_clouds_texture_->getWidth(), bottom_clouds_texture_->getHeight());
|
||||||
bottom_clouds_sprite_a_->setVelX(-BOTTOM_CLOUDS_SPEED);
|
bottom_clouds_sprite_a_->setVelX(-INITIAL_BOTTOM_CLOUDS_SPEED_PX_PER_S);
|
||||||
|
|
||||||
bottom_clouds_sprite_b_->setSpriteClip(0, 0, bottom_clouds_texture_->getWidth(), bottom_clouds_texture_->getHeight());
|
bottom_clouds_sprite_b_->setSpriteClip(0, 0, bottom_clouds_texture_->getWidth(), bottom_clouds_texture_->getHeight());
|
||||||
bottom_clouds_sprite_b_->setVelX(-BOTTOM_CLOUDS_SPEED);
|
bottom_clouds_sprite_b_->setVelX(-INITIAL_BOTTOM_CLOUDS_SPEED_PX_PER_S);
|
||||||
|
|
||||||
|
// grass_sprite_->setY(base_ - grass_sprite_->getHeight());
|
||||||
|
// grass_sprite_->resetAnimation();
|
||||||
|
grass_sprite_->setPos(0.0F, base_ - 10.0F);
|
||||||
|
grass_sprite_->setWidth(320.0F);
|
||||||
|
grass_sprite_->setHeight(10.0F);
|
||||||
|
// grass_sprite_->setCurrentAnimation(0);
|
||||||
|
|
||||||
buildings_sprite_->setY(base_ - buildings_sprite_->getHeight());
|
buildings_sprite_->setY(base_ - buildings_sprite_->getHeight());
|
||||||
grass_sprite_->setY(base_ - grass_sprite_->getHeight());
|
|
||||||
sun_sprite_->setPosition(sun_path_.front());
|
sun_sprite_->setPosition(sun_path_.front());
|
||||||
moon_sprite_->setPosition(moon_path_.front());
|
moon_sprite_->setPosition(moon_path_.front());
|
||||||
}
|
}
|
||||||
@@ -126,20 +136,20 @@ void Background::initializeTextures() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza la lógica del objeto
|
// Actualiza la lógica del objeto
|
||||||
void Background::update() {
|
void Background::update(float delta_time) {
|
||||||
// Actualiza la progresión y calcula transiciones
|
// Actualiza la progresión y calcula transiciones
|
||||||
if (!manual_mode_) {
|
if (!manual_mode_) {
|
||||||
updateProgression();
|
updateProgression(delta_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el valor de alpha
|
// Actualiza el valor de alpha
|
||||||
updateAlphaColorTexture();
|
updateAlphaColorTexture(delta_time);
|
||||||
|
|
||||||
// Actualiza las nubes
|
// Actualiza las nubes
|
||||||
updateClouds();
|
updateClouds(delta_time);
|
||||||
|
|
||||||
// Calcula el frame de la hierba
|
// Actualiza el sprite con la hierba
|
||||||
grass_sprite_->setSpriteClip(0, (10 * (counter_ / 20 % 2)), 320, 10);
|
grass_sprite_->update(delta_time);
|
||||||
|
|
||||||
// Calcula el valor de alpha
|
// Calcula el valor de alpha
|
||||||
alpha_ = std::max((255 - (int)(255 * transition_)), 0);
|
alpha_ = std::max((255 - (int)(255 * transition_)), 0);
|
||||||
@@ -148,9 +158,6 @@ void Background::update() {
|
|||||||
sun_sprite_->setPosition(sun_path_.at(sun_index_));
|
sun_sprite_->setPosition(sun_path_.at(sun_index_));
|
||||||
moon_sprite_->setPosition(moon_path_.at(moon_index_));
|
moon_sprite_->setPosition(moon_path_.at(moon_index_));
|
||||||
|
|
||||||
// Incrementa el contador
|
|
||||||
++counter_;
|
|
||||||
|
|
||||||
// Compone todos los elementos del fondo en la textura
|
// Compone todos los elementos del fondo en la textura
|
||||||
fillCanvas();
|
fillCanvas();
|
||||||
}
|
}
|
||||||
@@ -182,6 +189,12 @@ void Background::setProgress(float absolute_progress) {
|
|||||||
|
|
||||||
// Cambia el estado del fondo
|
// Cambia el estado del fondo
|
||||||
void Background::setState(State new_state) {
|
void Background::setState(State new_state) {
|
||||||
|
// Si entra en estado completado, inicializar variables de transición
|
||||||
|
if (new_state == State::COMPLETED && state_ != State::COMPLETED) {
|
||||||
|
completion_initial_progress_ = progress_;
|
||||||
|
completion_transition_timer_ = 0.0F;
|
||||||
|
}
|
||||||
|
|
||||||
state_ = new_state;
|
state_ = new_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,6 +209,10 @@ void Background::reset() {
|
|||||||
sun_index_ = 0;
|
sun_index_ = 0;
|
||||||
moon_index_ = 0;
|
moon_index_ = 0;
|
||||||
|
|
||||||
|
// Resetear variables de transición de completado
|
||||||
|
completion_transition_timer_ = 0.0F;
|
||||||
|
completion_initial_progress_ = 0.0F;
|
||||||
|
|
||||||
// Notifica el cambio si hay callback
|
// Notifica el cambio si hay callback
|
||||||
if (progress_callback_ && progress_ != old_progress) {
|
if (progress_callback_ && progress_ != old_progress) {
|
||||||
progress_callback_(progress_);
|
progress_callback_(progress_);
|
||||||
@@ -252,13 +269,24 @@ void Background::setMoonProgression(float progress) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza la progresión y calcula las transiciones
|
// Actualiza la progresión y calcula las transiciones
|
||||||
void Background::updateProgression() {
|
void Background::updateProgression(float delta_time) {
|
||||||
// Si el juego está completado, reduce la progresión gradualmente
|
// Si el juego está completado, hacer transición suave con easing
|
||||||
if (state_ == State::COMPLETED) {
|
if (state_ == State::COMPLETED) {
|
||||||
if (progress_ > MINIMUM_COMPLETED_PROGRESS) {
|
completion_transition_timer_ += delta_time;
|
||||||
progress_ -= COMPLETED_REDUCTION_RATE;
|
|
||||||
|
// Calcular progreso normalizado de la transición (0.0 a 1.0)
|
||||||
|
float t = std::min(completion_transition_timer_ / COMPLETION_TRANSITION_DURATION_S, 1.0F);
|
||||||
|
|
||||||
|
if (t < 1.0F) {
|
||||||
|
// Usar easeOutCubic para transición suave (rápido al inicio, lento al final)
|
||||||
|
float eased_t = easeOutCubic(static_cast<double>(t));
|
||||||
|
|
||||||
|
// Interpolación desde progreso inicial hasta mínimo
|
||||||
|
float progress_range = completion_initial_progress_ - minimum_completed_progress_;
|
||||||
|
progress_ = completion_initial_progress_ - (progress_range * eased_t);
|
||||||
} else {
|
} else {
|
||||||
progress_ = MINIMUM_COMPLETED_PROGRESS;
|
// Transición completada, fijar al valor mínimo
|
||||||
|
progress_ = minimum_completed_progress_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,18 +311,19 @@ void Background::updateProgression() {
|
|||||||
|
|
||||||
// Actualiza la velocidad de las nubes según el estado y progresión
|
// Actualiza la velocidad de las nubes según el estado y progresión
|
||||||
void Background::updateCloudsSpeed() {
|
void Background::updateCloudsSpeed() {
|
||||||
// Cálculo de velocidad según progreso
|
// Cálculo de velocidad según progreso (convertido de frame-based a time-based)
|
||||||
constexpr float CLOUDS_INITIAL_SPEED = 0.05F;
|
constexpr float CLOUDS_INITIAL_SPEED_PX_PER_S = 0.05F * 60.0F; // 3.0 píxeles/segundo (era 0.05 px/frame @ 60fps)
|
||||||
constexpr float CLOUDS_FINAL_SPEED = 2.00F - CLOUDS_INITIAL_SPEED;
|
constexpr float CLOUDS_TOTAL_SPEED_PX_PER_S = 2.00F * 60.0F; // 120.0 píxeles/segundo (era 2.00 px/frame @ 60fps)
|
||||||
|
constexpr float CLOUDS_FINAL_SPEED_RANGE_PX_PER_S = CLOUDS_TOTAL_SPEED_PX_PER_S - CLOUDS_INITIAL_SPEED_PX_PER_S; // 117.0 píxeles/segundo
|
||||||
|
|
||||||
// Velocidad base según progreso (de -0.05 a -2.00)
|
// Velocidad base según progreso (de -3.0 a -120.0 píxeles/segundo, igual que la versión original)
|
||||||
float base_clouds_speed = (-CLOUDS_INITIAL_SPEED) +
|
float base_clouds_speed = (-CLOUDS_INITIAL_SPEED_PX_PER_S) +
|
||||||
(-CLOUDS_FINAL_SPEED * (progress_ / total_progress_to_complete_));
|
(-CLOUDS_FINAL_SPEED_RANGE_PX_PER_S * (progress_ / total_progress_to_complete_));
|
||||||
|
|
||||||
// En estado completado, las nubes se ralentizan gradualmente
|
// En estado completado, las nubes se ralentizan gradualmente
|
||||||
if (state_ == State::COMPLETED) {
|
if (state_ == State::COMPLETED) {
|
||||||
float completion_factor = (progress_ - MINIMUM_COMPLETED_PROGRESS) /
|
float completion_factor = (progress_ - minimum_completed_progress_) /
|
||||||
(total_progress_to_complete_ - MINIMUM_COMPLETED_PROGRESS);
|
(total_progress_to_complete_ - minimum_completed_progress_);
|
||||||
completion_factor = std::max(0.1F, completion_factor);
|
completion_factor = std::max(0.1F, completion_factor);
|
||||||
base_clouds_speed *= completion_factor;
|
base_clouds_speed *= completion_factor;
|
||||||
}
|
}
|
||||||
@@ -314,12 +343,12 @@ void Background::updateCloudsSpeed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las nubes
|
// Actualiza las nubes
|
||||||
void Background::updateClouds() {
|
void Background::updateClouds(float delta_time) {
|
||||||
// Mueve las nubes
|
// Mueve las nubes
|
||||||
top_clouds_sprite_a_->update();
|
top_clouds_sprite_a_->update(delta_time);
|
||||||
top_clouds_sprite_b_->update();
|
top_clouds_sprite_b_->update(delta_time);
|
||||||
bottom_clouds_sprite_a_->update();
|
bottom_clouds_sprite_a_->update(delta_time);
|
||||||
bottom_clouds_sprite_b_->update();
|
bottom_clouds_sprite_b_->update(delta_time);
|
||||||
|
|
||||||
// Calcula el offset de las nubes
|
// Calcula el offset de las nubes
|
||||||
if (top_clouds_sprite_a_->getPosX() < -top_clouds_sprite_a_->getWidth()) {
|
if (top_clouds_sprite_a_->getPosX() < -top_clouds_sprite_a_->getWidth()) {
|
||||||
@@ -389,7 +418,7 @@ void Background::renderBottomClouds() {
|
|||||||
// Compone todos los elementos del fondo en la textura
|
// Compone todos los elementos del fondo en la textura
|
||||||
void Background::fillCanvas() {
|
void Background::fillCanvas() {
|
||||||
// Cambia el destino del renderizador
|
// Cambia el destino del renderizador
|
||||||
auto *temp = SDL_GetRenderTarget(renderer_);
|
auto* temp = SDL_GetRenderTarget(renderer_);
|
||||||
SDL_SetRenderTarget(renderer_, canvas_);
|
SDL_SetRenderTarget(renderer_, canvas_);
|
||||||
|
|
||||||
// Dibuja el gradiente de fondo
|
// Dibuja el gradiente de fondo
|
||||||
@@ -440,7 +469,7 @@ void Background::setColor(Color color) {
|
|||||||
attenuate_color_ = color;
|
attenuate_color_ = color;
|
||||||
|
|
||||||
// Colorea la textura
|
// Colorea la textura
|
||||||
auto *temp = SDL_GetRenderTarget(renderer_);
|
auto* temp = SDL_GetRenderTarget(renderer_);
|
||||||
SDL_SetRenderTarget(renderer_, color_texture_);
|
SDL_SetRenderTarget(renderer_, color_texture_);
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(renderer_, attenuate_color_.r, attenuate_color_.g, attenuate_color_.b, 255);
|
SDL_SetRenderDrawColor(renderer_, attenuate_color_.r, attenuate_color_.g, attenuate_color_.b, 255);
|
||||||
@@ -459,13 +488,39 @@ void Background::setAlpha(int alpha) {
|
|||||||
alpha_color_texture_ = alpha;
|
alpha_color_texture_ = alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el valor de alpha
|
// Actualiza el valor de alpha (time-based)
|
||||||
void Background::updateAlphaColorTexture() {
|
void Background::updateAlphaColorTexture(float delta_time) {
|
||||||
|
// 1. Si ya hemos llegado al destino, no hacemos nada.
|
||||||
if (alpha_color_texture_ == previous_alpha_color_texture_) {
|
if (alpha_color_texture_ == previous_alpha_color_texture_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
alpha_color_texture_ > previous_alpha_color_texture_ ? ++previous_alpha_color_texture_ : --previous_alpha_color_texture_;
|
|
||||||
SDL_SetTextureAlphaMod(color_texture_, previous_alpha_color_texture_);
|
// 2. Define la velocidad del cambio (p. ej., 150 unidades de alfa por segundo).
|
||||||
|
// Puedes ajustar este valor para que la transición sea más rápida o lenta.
|
||||||
|
constexpr float ALPHA_TRANSITION_SPEED = 150.0F;
|
||||||
|
|
||||||
|
// 3. Determina la dirección del cambio (subir o bajar el alfa)
|
||||||
|
if (alpha_color_texture_ > previous_alpha_color_texture_) {
|
||||||
|
// Aumentar el alfa
|
||||||
|
current_alpha_float_ += ALPHA_TRANSITION_SPEED * delta_time;
|
||||||
|
// Nos aseguramos de no pasarnos del objetivo
|
||||||
|
current_alpha_float_ = std::min(current_alpha_float_, static_cast<float>(alpha_color_texture_));
|
||||||
|
} else {
|
||||||
|
// Disminuir el alfa
|
||||||
|
current_alpha_float_ -= ALPHA_TRANSITION_SPEED * delta_time;
|
||||||
|
// Nos aseguramos de no quedarnos cortos del objetivo
|
||||||
|
current_alpha_float_ = std::max(current_alpha_float_, static_cast<float>(alpha_color_texture_));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Actualiza el valor entero solo si ha cambiado lo suficiente
|
||||||
|
// Usamos std::round para un redondeo más natural.
|
||||||
|
const auto NEW_ALPHA = static_cast<size_t>(std::round(current_alpha_float_));
|
||||||
|
|
||||||
|
if (NEW_ALPHA != previous_alpha_color_texture_) {
|
||||||
|
previous_alpha_color_texture_ = NEW_ALPHA;
|
||||||
|
// SDL espera un Uint8 (0-255), así que hacemos un cast seguro.
|
||||||
|
SDL_SetTextureAlphaMod(color_texture_, static_cast<Uint8>(previous_alpha_color_texture_));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Precalcula el vector con el recorrido del sol
|
// Precalcula el vector con el recorrido del sol
|
||||||
|
|||||||
@@ -8,11 +8,12 @@
|
|||||||
#include <memory> // Para unique_ptr, shared_ptr
|
#include <memory> // Para unique_ptr, shared_ptr
|
||||||
#include <vector> // Para vector
|
#include <vector> // Para vector
|
||||||
|
|
||||||
#include "color.h" // Para Color
|
#include "color.hpp" // Para Color
|
||||||
|
|
||||||
class MovingSprite;
|
class MovingSprite;
|
||||||
class Sprite;
|
class Sprite;
|
||||||
class Texture;
|
class Texture;
|
||||||
|
class AnimatedSprite;
|
||||||
|
|
||||||
// --- Clase Background: gestiona el fondo de la sección jugable ---
|
// --- Clase Background: gestiona el fondo de la sección jugable ---
|
||||||
class Background {
|
class Background {
|
||||||
@@ -31,9 +32,9 @@ class Background {
|
|||||||
~Background(); // Destructor
|
~Background(); // Destructor
|
||||||
|
|
||||||
// --- Métodos principales ---
|
// --- Métodos principales ---
|
||||||
void update(); // Actualiza la lógica del objeto
|
void update(float delta_time); // Actualiza la lógica del objeto
|
||||||
void render(); // Dibuja el objeto
|
void render(); // Dibuja el objeto
|
||||||
void reset(); // Reinicia la progresión
|
void reset(); // Reinicia la progresión
|
||||||
|
|
||||||
// --- Configuración ---
|
// --- Configuración ---
|
||||||
void setPos(SDL_FRect pos); // Establece la posición del objeto
|
void setPos(SDL_FRect pos); // Establece la posición del objeto
|
||||||
@@ -60,19 +61,18 @@ class Background {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// --- Constantes ---
|
// --- Constantes ---
|
||||||
static constexpr size_t STAGES = 4; // Número de etapas
|
static constexpr size_t STAGES = 4; // Número de etapas
|
||||||
static constexpr float COMPLETED_REDUCTION_RATE = 25.0F; // Tasa de reducción completada
|
static constexpr float MINIMUM_COMPLETED_PROGRESS_PERCENTAGE = 0.05F; // Porcentaje mínimo completado (10%)
|
||||||
static constexpr float MINIMUM_COMPLETED_PROGRESS = 200.0F; // Progreso mínimo completado
|
static constexpr float SUN_COMPLETION_FACTOR = 0.5F; // Factor de completado del sol
|
||||||
static constexpr float SUN_COMPLETION_FACTOR = 0.5F; // Factor de completado del sol
|
static constexpr float COMPLETION_TRANSITION_DURATION_S = 3.0F; // Duración de la transición de completado en segundos
|
||||||
|
|
||||||
// --- Objetos y punteros ---
|
// --- Objetos y punteros ---
|
||||||
SDL_Renderer *renderer_; // Renderizador de la ventana
|
SDL_Renderer* renderer_; // Renderizador de la ventana
|
||||||
SDL_Texture *canvas_; // Textura para componer el fondo
|
SDL_Texture* canvas_; // Textura para componer el fondo
|
||||||
SDL_Texture *color_texture_; // Textura para atenuar el fondo
|
SDL_Texture* color_texture_; // Textura para atenuar el fondo
|
||||||
std::shared_ptr<Texture> buildings_texture_; // Textura de edificios
|
std::shared_ptr<Texture> buildings_texture_; // Textura de edificios
|
||||||
std::shared_ptr<Texture> top_clouds_texture_; // Textura de nubes superiores
|
std::shared_ptr<Texture> top_clouds_texture_; // Textura de nubes superiores
|
||||||
std::shared_ptr<Texture> bottom_clouds_texture_; // Textura de nubes inferiores
|
std::shared_ptr<Texture> bottom_clouds_texture_; // Textura de nubes inferiores
|
||||||
std::shared_ptr<Texture> grass_texture_; // Textura de hierba
|
|
||||||
std::shared_ptr<Texture> gradients_texture_; // Textura de gradientes
|
std::shared_ptr<Texture> gradients_texture_; // Textura de gradientes
|
||||||
std::shared_ptr<Texture> sun_texture_; // Textura del sol
|
std::shared_ptr<Texture> sun_texture_; // Textura del sol
|
||||||
std::shared_ptr<Texture> moon_texture_; // Textura de la luna
|
std::shared_ptr<Texture> moon_texture_; // Textura de la luna
|
||||||
@@ -82,14 +82,15 @@ class Background {
|
|||||||
std::unique_ptr<MovingSprite> bottom_clouds_sprite_b_; // Sprite de nubes inferiores B
|
std::unique_ptr<MovingSprite> bottom_clouds_sprite_b_; // Sprite de nubes inferiores B
|
||||||
std::unique_ptr<Sprite> buildings_sprite_; // Sprite de edificios
|
std::unique_ptr<Sprite> buildings_sprite_; // Sprite de edificios
|
||||||
std::unique_ptr<Sprite> gradient_sprite_; // Sprite de gradiente
|
std::unique_ptr<Sprite> gradient_sprite_; // Sprite de gradiente
|
||||||
std::unique_ptr<Sprite> grass_sprite_; // Sprite de hierba
|
|
||||||
std::unique_ptr<Sprite> sun_sprite_; // Sprite del sol
|
std::unique_ptr<Sprite> sun_sprite_; // Sprite del sol
|
||||||
std::unique_ptr<Sprite> moon_sprite_; // Sprite de la luna
|
std::unique_ptr<Sprite> moon_sprite_; // Sprite de la luna
|
||||||
|
std::unique_ptr<AnimatedSprite> grass_sprite_; // Sprite con la hierba
|
||||||
|
|
||||||
// --- Variables de configuración ---
|
// --- Variables de configuración ---
|
||||||
const float total_progress_to_complete_; // Progreso total para completar
|
const float total_progress_to_complete_; // Progreso total para completar
|
||||||
const float progress_per_stage_; // Progreso por etapa
|
const float progress_per_stage_; // Progreso por etapa
|
||||||
const float sun_completion_progress_; // Progreso de completado del sol
|
const float sun_completion_progress_; // Progreso de completado del sol
|
||||||
|
const float minimum_completed_progress_; // Progreso mínimo calculado dinámicamente
|
||||||
ProgressCallback progress_callback_; // Callback para notificar cambios de progreso
|
ProgressCallback progress_callback_; // Callback para notificar cambios de progreso
|
||||||
|
|
||||||
// --- Variables de estado ---
|
// --- Variables de estado ---
|
||||||
@@ -106,8 +107,8 @@ class Background {
|
|||||||
float progress_ = 0.0F; // Progresión interna
|
float progress_ = 0.0F; // Progresión interna
|
||||||
float clouds_speed_ = 0; // Velocidad de las nubes
|
float clouds_speed_ = 0; // Velocidad de las nubes
|
||||||
float transition_ = 0; // Porcentaje de transición
|
float transition_ = 0; // Porcentaje de transición
|
||||||
|
float current_alpha_float_ = 0.0F; // Acumulador para el valor alfa preciso
|
||||||
size_t gradient_number_ = 0; // Índice de fondo degradado
|
size_t gradient_number_ = 0; // Índice de fondo degradado
|
||||||
size_t counter_ = 0; // Contador interno
|
|
||||||
size_t alpha_color_texture_ = 0; // Transparencia de atenuación
|
size_t alpha_color_texture_ = 0; // Transparencia de atenuación
|
||||||
size_t previous_alpha_color_texture_ = 0; // Transparencia anterior
|
size_t previous_alpha_color_texture_ = 0; // Transparencia anterior
|
||||||
size_t sun_index_ = 0; // Índice del recorrido del sol
|
size_t sun_index_ = 0; // Índice del recorrido del sol
|
||||||
@@ -116,20 +117,24 @@ class Background {
|
|||||||
Uint8 alpha_ = 0; // Transparencia entre fases
|
Uint8 alpha_ = 0; // Transparencia entre fases
|
||||||
bool manual_mode_ = false; // Si está en modo manual
|
bool manual_mode_ = false; // Si está en modo manual
|
||||||
|
|
||||||
|
// --- Variables para transición suave de completado ---
|
||||||
|
float completion_transition_timer_ = 0.0F; // Timer para la transición de completado
|
||||||
|
float completion_initial_progress_ = 0.0F; // Progreso inicial al entrar en estado completado
|
||||||
|
|
||||||
// --- Métodos internos ---
|
// --- Métodos internos ---
|
||||||
void initializePaths(); // Inicializa las rutas del sol y la luna
|
void initializePaths(); // Inicializa las rutas del sol y la luna
|
||||||
void initializeRects(); // Inicializa los rectángulos de gradientes y nubes
|
void initializeRects(); // Inicializa los rectángulos de gradientes y nubes
|
||||||
void initializeSprites(); // Crea los sprites
|
void initializeSprites(); // Crea los sprites
|
||||||
void initializeSpriteProperties(); // Configura las propiedades iniciales de los sprites
|
void initializeSpriteProperties(); // Configura las propiedades iniciales de los sprites
|
||||||
void initializeTextures(); // Inicializa las texturas de renderizado
|
void initializeTextures(); // Inicializa las texturas de renderizado
|
||||||
void updateProgression(); // Actualiza la progresión y calcula transiciones
|
void updateProgression(float delta_time); // Actualiza la progresión y calcula transiciones
|
||||||
void updateCloudsSpeed(); // Actualiza la velocidad de las nubes según el estado
|
void updateCloudsSpeed(); // Actualiza la velocidad de las nubes según el estado
|
||||||
void renderGradient(); // Dibuja el gradiente de fondo
|
void renderGradient(); // Dibuja el gradiente de fondo
|
||||||
void renderTopClouds(); // Dibuja las nubes superiores
|
void renderTopClouds(); // Dibuja las nubes superiores
|
||||||
void renderBottomClouds(); // Dibuja las nubes inferiores
|
void renderBottomClouds(); // Dibuja las nubes inferiores
|
||||||
void fillCanvas(); // Compone todos los elementos en la textura
|
void fillCanvas(); // Compone todos los elementos en la textura
|
||||||
void updateAlphaColorTexture(); // Actualiza el alpha de la textura de atenuación
|
void updateAlphaColorTexture(float delta_time); // Actualiza el alpha de la textura de atenuación
|
||||||
void updateClouds(); // Actualiza el movimiento de las nubes
|
void updateClouds(float delta_time); // Actualiza el movimiento de las nubes (time-based)
|
||||||
void createSunPath(); // Precalcula el recorrido del sol
|
void createSunPath(); // Precalcula el recorrido del sol
|
||||||
void createMoonPath(); // Precalcula el recorrido de la luna
|
void createMoonPath(); // Precalcula el recorrido de la luna
|
||||||
};
|
};
|
||||||
@@ -1,34 +1,35 @@
|
|||||||
#include "balloon.h"
|
#include "balloon.hpp"
|
||||||
|
|
||||||
#include <algorithm> // Para clamp
|
#include <algorithm> // Para clamp
|
||||||
#include <array> // Para array
|
#include <array> // Para array
|
||||||
#include <cmath> // Para fabs
|
#include <cmath> // Para fabs
|
||||||
|
|
||||||
#include "animated_sprite.h" // Para AnimatedSprite
|
#include "animated_sprite.hpp" // Para AnimatedSprite
|
||||||
#include "audio.h" // Para Audio
|
#include "audio.hpp" // Para Audio
|
||||||
#include "param.h" // Para Param, ParamBalloon, param
|
#include "param.hpp" // Para Param, ParamBalloon, param
|
||||||
#include "sprite.h" // Para Sprite
|
#include "sprite.hpp" // Para Sprite
|
||||||
#include "texture.h" // Para Texture
|
#include "texture.hpp" // Para Texture
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Balloon::Balloon(float x, float y, Type type, Size size, float vel_x, float speed, Uint16 creation_timer, SDL_FRect play_area, const std::shared_ptr<Texture> &texture, const std::vector<std::string> &animation)
|
Balloon::Balloon(const Config& config)
|
||||||
: sprite_(std::make_unique<AnimatedSprite>(texture, animation)),
|
: sprite_(std::make_unique<AnimatedSprite>(config.texture, config.animation)),
|
||||||
x_(x),
|
x_(config.x),
|
||||||
y_(y),
|
y_(config.y),
|
||||||
vx_(vel_x),
|
vx_(config.vel_x),
|
||||||
being_created_(creation_timer > 0),
|
being_created_(config.creation_counter > 0),
|
||||||
invulnerable_(creation_timer > 0),
|
invulnerable_(config.creation_counter > 0),
|
||||||
stopped_(creation_timer > 0),
|
stopped_(config.creation_counter > 0),
|
||||||
creation_counter_(creation_timer),
|
creation_counter_(config.creation_counter),
|
||||||
creation_counter_ini_(creation_timer),
|
creation_counter_ini_(config.creation_counter),
|
||||||
type_(type),
|
type_(config.type),
|
||||||
size_(size),
|
size_(config.size),
|
||||||
speed_(speed),
|
game_tempo_(config.game_tempo),
|
||||||
play_area_(play_area) {
|
play_area_(config.play_area),
|
||||||
|
sound_(config.sound) {
|
||||||
switch (type_) {
|
switch (type_) {
|
||||||
case Type::BALLOON: {
|
case Type::BALLOON: {
|
||||||
vy_ = 0;
|
vy_ = 0;
|
||||||
max_vy_ = 3.0F;
|
max_vy_ = 3.0F * 60.0F; // Convert from frames to seconds (180 pixels/s)
|
||||||
|
|
||||||
const int INDEX = static_cast<int>(size_);
|
const int INDEX = static_cast<int>(size_);
|
||||||
gravity_ = param.balloon.settings.at(INDEX).grav;
|
gravity_ = param.balloon.settings.at(INDEX).grav;
|
||||||
@@ -37,9 +38,8 @@ Balloon::Balloon(float x, float y, Type type, Size size, float vel_x, float spee
|
|||||||
power_ = POWER.at(INDEX);
|
power_ = POWER.at(INDEX);
|
||||||
menace_ = MENACE.at(INDEX);
|
menace_ = MENACE.at(INDEX);
|
||||||
score_ = SCORE.at(INDEX);
|
score_ = SCORE.at(INDEX);
|
||||||
bouncing_sound_ = BOUNCING_SOUND.at(INDEX);
|
sound_.bouncing_file = BOUNCING_SOUND.at(INDEX);
|
||||||
popping_sound_ = POPPING_SOUND.at(INDEX);
|
sound_.popping_file = POPPING_SOUND.at(INDEX);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,27 +52,25 @@ Balloon::Balloon(float x, float y, Type type, Size size, float vel_x, float spee
|
|||||||
power_ = POWER.at(INDEX);
|
power_ = POWER.at(INDEX);
|
||||||
menace_ = MENACE.at(INDEX);
|
menace_ = MENACE.at(INDEX);
|
||||||
score_ = SCORE.at(INDEX);
|
score_ = SCORE.at(INDEX);
|
||||||
bouncing_sound_ = BOUNCING_SOUND.at(INDEX);
|
sound_.bouncing_file = BOUNCING_SOUND.at(INDEX);
|
||||||
popping_sound_ = POPPING_SOUND.at(INDEX);
|
sound_.popping_file = POPPING_SOUND.at(INDEX);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Type::POWERBALL: {
|
case Type::POWERBALL: {
|
||||||
constexpr int INDEX = 3;
|
constexpr int INDEX = 3;
|
||||||
h_ = w_ = WIDTH.at(4);
|
h_ = w_ = WIDTH.at(4);
|
||||||
bouncing_sound_ = BOUNCING_SOUND.at(3);
|
sound_.bouncing_file = BOUNCING_SOUND.at(3);
|
||||||
popping_sound_ = "power_ball_explosion.wav";
|
sound_.popping_file = "power_ball_explosion.wav";
|
||||||
power_ = score_ = menace_ = 0;
|
power_ = score_ = menace_ = 0;
|
||||||
|
|
||||||
vy_ = 0;
|
vy_ = 0;
|
||||||
max_vy_ = 3.0F;
|
max_vy_ = 3.0F * 60.0F; // Convert from frames to seconds (180 pixels/s)
|
||||||
gravity_ = param.balloon.settings.at(INDEX).grav;
|
gravity_ = param.balloon.settings.at(INDEX).grav;
|
||||||
default_vy_ = param.balloon.settings.at(INDEX).vel;
|
default_vy_ = param.balloon.settings.at(INDEX).vel;
|
||||||
|
|
||||||
sprite_->setRotate(creation_timer <= 0);
|
sprite_->setRotate(config.creation_counter <= 0);
|
||||||
sprite_->setRotateAmount(vx_ > 0.0F ? 2.0 : -2.0);
|
sprite_->setRotateAmount(vx_ > 0.0F ? 120.0 : -120.0); // Convert from 2 degrees/frame to 120 degrees/second
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,6 +89,12 @@ Balloon::Balloon(float x, float y, Type type, Size size, float vel_x, float spee
|
|||||||
|
|
||||||
// Establece la animación a usar
|
// Establece la animación a usar
|
||||||
setAnimation();
|
setAnimation();
|
||||||
|
|
||||||
|
// Si no se está creando (creation_counter = 0), asegurar estado activo
|
||||||
|
if (!being_created_) {
|
||||||
|
start();
|
||||||
|
setInvulnerable(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Centra el globo en la posición X
|
// Centra el globo en la posición X
|
||||||
@@ -127,7 +131,7 @@ void Balloon::render() {
|
|||||||
// Renderizado para el resto de globos
|
// Renderizado para el resto de globos
|
||||||
if (isBeingCreated()) {
|
if (isBeingCreated()) {
|
||||||
// Renderizado con transparencia
|
// Renderizado con transparencia
|
||||||
sprite_->getTexture()->setAlpha(255 - (int)((float)creation_counter_ * (255.0F / (float)creation_counter_ini_)));
|
sprite_->getTexture()->setAlpha(255 - (int)(creation_counter_ * (255.0F / creation_counter_ini_)));
|
||||||
sprite_->render();
|
sprite_->render();
|
||||||
sprite_->getTexture()->setAlpha(255);
|
sprite_->getTexture()->setAlpha(255);
|
||||||
} else {
|
} else {
|
||||||
@@ -137,19 +141,20 @@ void Balloon::render() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza la posición y estados del globo
|
// Actualiza la posición y estados del globo (time-based)
|
||||||
void Balloon::move() {
|
void Balloon::move(float delta_time) {
|
||||||
if (isStopped()) {
|
if (isStopped()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleHorizontalMovement();
|
handleHorizontalMovement(delta_time);
|
||||||
handleVerticalMovement();
|
handleVerticalMovement(delta_time);
|
||||||
applyGravity();
|
applyGravity(delta_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Balloon::handleHorizontalMovement() {
|
void Balloon::handleHorizontalMovement(float delta_time) {
|
||||||
x_ += vx_ * speed_;
|
// DeltaTime en segundos: velocidad (pixels/s) * tempo * tiempo (s)
|
||||||
|
x_ += vx_ * game_tempo_ * delta_time;
|
||||||
|
|
||||||
const int CLIP = 2;
|
const int CLIP = 2;
|
||||||
const float MIN_X = play_area_.x - CLIP;
|
const float MIN_X = play_area_.x - CLIP;
|
||||||
@@ -160,8 +165,9 @@ void Balloon::handleHorizontalMovement() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Balloon::handleVerticalMovement() {
|
void Balloon::handleVerticalMovement(float delta_time) {
|
||||||
y_ += vy_ * speed_;
|
// DeltaTime en segundos: velocidad (pixels/s) * tempo * tiempo (s)
|
||||||
|
y_ += vy_ * game_tempo_ * delta_time;
|
||||||
|
|
||||||
if (shouldCheckTopCollision()) {
|
if (shouldCheckTopCollision()) {
|
||||||
handleTopCollision();
|
handleTopCollision();
|
||||||
@@ -216,41 +222,37 @@ void Balloon::handleBottomCollision() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Balloon::applyGravity() {
|
void Balloon::applyGravity(float delta_time) {
|
||||||
/*
|
// DeltaTime en segundos: aceleración (pixels/s²) * tempo * tiempo (s)
|
||||||
Para aplicar la gravedad, el diseño original la aplicaba en cada iteración del bucle
|
vy_ += gravity_ * game_tempo_ * delta_time;
|
||||||
Al añadir el modificador de velocidad se reduce la distancia que recorre el objeto y por
|
}
|
||||||
tanto recibe mas gravedad. Para solucionarlo se va a aplicar la gravedad cuando se haya
|
|
||||||
recorrido una distancia igual a la velocidad en Y, que era el cálculo inicial
|
|
||||||
*/
|
|
||||||
|
|
||||||
travel_y_ += speed_;
|
void Balloon::playBouncingSound() const {
|
||||||
|
if (sound_.enabled && sound_.bouncing_enabled) {
|
||||||
if (travel_y_ >= 1.0F) {
|
Audio::get()->playSound(sound_.bouncing_file);
|
||||||
travel_y_ -= 1.0F;
|
|
||||||
vy_ += gravity_;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Balloon::playBouncingSound() {
|
void Balloon::playPoppingSound() const {
|
||||||
if (bouncing_sound_enabled_) {
|
if (sound_.enabled && sound_.poping_enabled) {
|
||||||
playSound(bouncing_sound_);
|
Audio::get()->playSound(sound_.popping_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza al globo a su posicion, animación y controla los contadores
|
// Actualiza al globo a su posicion, animación y controla los contadores (time-based)
|
||||||
void Balloon::update() {
|
void Balloon::update(float delta_time) {
|
||||||
move();
|
move(delta_time);
|
||||||
updateState();
|
updateState(delta_time);
|
||||||
updateBounceEffect();
|
updateBounceEffect();
|
||||||
shiftSprite();
|
shiftSprite();
|
||||||
shiftColliders();
|
shiftColliders();
|
||||||
sprite_->update();
|
sprite_->update(delta_time);
|
||||||
++counter_;
|
// Contador interno con deltaTime en segundos
|
||||||
|
counter_ += delta_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza los estados del globo
|
// Actualiza los estados del globo (time-based)
|
||||||
void Balloon::updateState() {
|
void Balloon::updateState(float delta_time) {
|
||||||
// Si se está creando
|
// Si se está creando
|
||||||
if (isBeingCreated()) {
|
if (isBeingCreated()) {
|
||||||
// Actualiza el valor de las variables
|
// Actualiza el valor de las variables
|
||||||
@@ -259,9 +261,14 @@ void Balloon::updateState() {
|
|||||||
|
|
||||||
if (creation_counter_ > 0) {
|
if (creation_counter_ > 0) {
|
||||||
// Desplaza lentamente el globo hacia abajo y hacia un lado
|
// Desplaza lentamente el globo hacia abajo y hacia un lado
|
||||||
if (creation_counter_ % 10 == 0) {
|
// Cada 10/60 segundos (equivalente a 10 frames a 60fps)
|
||||||
|
movement_accumulator_ += delta_time;
|
||||||
|
|
||||||
|
constexpr float MOVEMENT_INTERVAL_S = 10.0F / 60.0F; // 10 frames = ~0.167s
|
||||||
|
if (movement_accumulator_ >= MOVEMENT_INTERVAL_S) {
|
||||||
|
movement_accumulator_ -= MOVEMENT_INTERVAL_S;
|
||||||
y_++;
|
y_++;
|
||||||
x_ += vx_;
|
x_ += vx_ / 60.0F; // Convierte de pixels/segundo a pixels/frame para movimiento discreto
|
||||||
|
|
||||||
// Comprueba no se salga por los laterales
|
// Comprueba no se salga por los laterales
|
||||||
const int MIN_X = play_area_.x;
|
const int MIN_X = play_area_.x;
|
||||||
@@ -269,11 +276,12 @@ void Balloon::updateState() {
|
|||||||
|
|
||||||
if (x_ < MIN_X || x_ > MAX_X) {
|
if (x_ < MIN_X || x_ > MAX_X) {
|
||||||
// Corrige y cambia el sentido de la velocidad
|
// Corrige y cambia el sentido de la velocidad
|
||||||
x_ -= vx_;
|
x_ -= vx_ / 60.0F;
|
||||||
vx_ = -vx_;
|
vx_ = -vx_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--creation_counter_;
|
creation_counter_ -= delta_time;
|
||||||
|
creation_counter_ = std::max<float>(creation_counter_, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
@@ -307,11 +315,14 @@ void Balloon::setAnimation() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Establece el frame de animación
|
// Establece el frame de animación
|
||||||
|
std::string chosen_animation;
|
||||||
if (use_reversed_colors_) {
|
if (use_reversed_colors_) {
|
||||||
sprite_->setCurrentAnimation(creating_animation);
|
chosen_animation = creating_animation;
|
||||||
} else {
|
} else {
|
||||||
sprite_->setCurrentAnimation(isBeingCreated() ? creating_animation : normal_animation);
|
chosen_animation = isBeingCreated() ? creating_animation : normal_animation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sprite_->setCurrentAnimation(chosen_animation);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detiene el globo
|
// Detiene el globo
|
||||||
@@ -368,23 +379,8 @@ void Balloon::useNormalColor() {
|
|||||||
setAnimation();
|
setAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reproduce sonido
|
|
||||||
void Balloon::playSound(const std::string &name) const {
|
|
||||||
if (!sound_enabled_) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
static auto *audio_ = Audio::get();
|
|
||||||
audio_->playSound(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Explota el globo
|
// Explota el globo
|
||||||
void Balloon::pop(bool should_sound) {
|
void Balloon::pop(bool should_sound) {
|
||||||
if (should_sound) {
|
if (should_sound) { playPoppingSound(); }
|
||||||
if (poping_sound_enabled_) {
|
|
||||||
playSound(popping_sound_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enabled_ = false;
|
enabled_ = false;
|
||||||
}
|
}
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
#include <string_view> // Para string_view
|
#include <string_view> // Para string_view
|
||||||
#include <vector> // Para vector
|
#include <vector> // Para vector
|
||||||
|
|
||||||
#include "animated_sprite.h" // Para AnimatedSprite
|
#include "animated_sprite.hpp" // Para AnimatedSprite
|
||||||
#include "utils.h" // Para Circle
|
#include "utils.hpp" // Para Circle
|
||||||
|
|
||||||
class Texture;
|
class Texture;
|
||||||
|
|
||||||
@@ -25,15 +25,23 @@ class Balloon {
|
|||||||
static constexpr std::array<int, 5> WIDTH = {10, 16, 26, 48, 49};
|
static constexpr std::array<int, 5> WIDTH = {10, 16, 26, 48, 49};
|
||||||
|
|
||||||
static constexpr std::array<std::string_view, 4> BOUNCING_SOUND = {
|
static constexpr std::array<std::string_view, 4> BOUNCING_SOUND = {
|
||||||
"balloon_bounce0.wav", "balloon_bounce1.wav", "balloon_bounce2.wav", "balloon_bounce3.wav"};
|
"balloon_bounce0.wav",
|
||||||
|
"balloon_bounce1.wav",
|
||||||
|
"balloon_bounce2.wav",
|
||||||
|
"balloon_bounce3.wav"};
|
||||||
|
|
||||||
static constexpr std::array<std::string_view, 4> POPPING_SOUND = {
|
static constexpr std::array<std::string_view, 4> POPPING_SOUND = {
|
||||||
"balloon_pop0.wav", "balloon_pop1.wav", "balloon_pop2.wav", "balloon_pop3.wav"};
|
"balloon_pop0.wav",
|
||||||
|
"balloon_pop1.wav",
|
||||||
|
"balloon_pop2.wav",
|
||||||
|
"balloon_pop3.wav"};
|
||||||
|
|
||||||
static constexpr float VELX_POSITIVE = 0.7F;
|
// Velocidades horizontales en pixels/segundo (convertidas desde 0.7 pixels/frame a 60fps)
|
||||||
static constexpr float VELX_NEGATIVE = -0.7F;
|
static constexpr float VELX_POSITIVE = 0.7F * 60.0F; // 42 pixels/segundo
|
||||||
|
static constexpr float VELX_NEGATIVE = -0.7F * 60.0F; // -42 pixels/segundo
|
||||||
|
|
||||||
static constexpr std::array<float, 5> SPEED = {0.60F, 0.70F, 0.80F, 0.90F, 1.00F};
|
// Multiplicadores de tempo del juego (sin cambios, son puros multiplicadores)
|
||||||
|
static constexpr std::array<float, 5> GAME_TEMPO = {0.60F, 0.70F, 0.80F, 0.90F, 1.00F};
|
||||||
|
|
||||||
static constexpr int POWERBALL_SCREENPOWER_MINIMUM = 10;
|
static constexpr int POWERBALL_SCREENPOWER_MINIMUM = 10;
|
||||||
static constexpr int POWERBALL_COUNTER = 8;
|
static constexpr int POWERBALL_COUNTER = 8;
|
||||||
@@ -52,25 +60,39 @@ class Balloon {
|
|||||||
POWERBALL = 2, // Globo de poder
|
POWERBALL = 2, // Globo de poder
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// --- Estructura para manejo de sonido ---
|
||||||
|
struct Sound {
|
||||||
|
std::string bouncing_file; // Archivo de sonido al rebotar
|
||||||
|
std::string popping_file; // Archivo de sonido al explotar
|
||||||
|
bool bouncing_enabled = false; // Si debe sonar el globo al rebotar
|
||||||
|
bool poping_enabled = true; // Si debe sonar el globo al explotar
|
||||||
|
bool enabled = true; // Indica si los globos deben hacer algun sonido
|
||||||
|
};
|
||||||
|
|
||||||
|
// --- Estructura de configuración para inicialización ---
|
||||||
|
struct Config {
|
||||||
|
float x = 0.0F;
|
||||||
|
float y = 0.0F;
|
||||||
|
Type type = Type::BALLOON;
|
||||||
|
Size size = Size::EXTRALARGE;
|
||||||
|
float vel_x = VELX_POSITIVE;
|
||||||
|
float game_tempo = GAME_TEMPO.at(0);
|
||||||
|
float creation_counter = 0.0F;
|
||||||
|
SDL_FRect play_area = {.x = 0.0F, .y = 0.0F, .w = 0.0F, .h = 0.0F};
|
||||||
|
std::shared_ptr<Texture> texture = nullptr;
|
||||||
|
std::vector<std::string> animation;
|
||||||
|
Sound sound;
|
||||||
|
};
|
||||||
|
|
||||||
// --- Constructores y destructor ---
|
// --- Constructores y destructor ---
|
||||||
Balloon(
|
Balloon(const Config& config);
|
||||||
float x,
|
|
||||||
float y,
|
|
||||||
Type type,
|
|
||||||
Size size,
|
|
||||||
float vel_x,
|
|
||||||
float speed,
|
|
||||||
Uint16 creation_timer,
|
|
||||||
SDL_FRect play_area,
|
|
||||||
const std::shared_ptr<Texture>& texture,
|
|
||||||
const std::vector<std::string>& animation);
|
|
||||||
~Balloon() = default;
|
~Balloon() = default;
|
||||||
|
|
||||||
// --- Métodos principales ---
|
// --- Métodos principales ---
|
||||||
void alignTo(int x); // Centra el globo en la posición X
|
void alignTo(int x); // Centra el globo en la posición X
|
||||||
void render(); // Pinta el globo en la pantalla
|
void render(); // Pinta el globo en la pantalla
|
||||||
void move(); // Actualiza la posición y estados del globo
|
void move(float delta_time); // Actualiza la posición y estados del globo (time-based)
|
||||||
void update(); // Actualiza el globo (posición, animación, contadores)
|
void update(float delta_time); // Actualiza el globo (posición, animación, contadores) (time-based)
|
||||||
void stop(); // Detiene el globo
|
void stop(); // Detiene el globo
|
||||||
void start(); // Pone el globo en movimiento
|
void start(); // Pone el globo en movimiento
|
||||||
void pop(bool should_sound = false); // Explota el globo
|
void pop(bool should_sound = false); // Explota el globo
|
||||||
@@ -100,11 +122,13 @@ class Balloon {
|
|||||||
|
|
||||||
// --- Setters ---
|
// --- Setters ---
|
||||||
void setVelY(float vel_y) { vy_ = vel_y; }
|
void setVelY(float vel_y) { vy_ = vel_y; }
|
||||||
void setSpeed(float speed) { speed_ = speed; }
|
void setVelX(float vel_x) { vx_ = vel_x; }
|
||||||
|
void alterVelX(float percent) { vx_ *= percent; }
|
||||||
|
void setGameTempo(float tempo) { game_tempo_ = tempo; }
|
||||||
void setInvulnerable(bool value) { invulnerable_ = value; }
|
void setInvulnerable(bool value) { invulnerable_ = value; }
|
||||||
void setBouncingSound(bool value) { bouncing_sound_enabled_ = value; }
|
void setBouncingSound(bool value) { sound_.bouncing_enabled = value; }
|
||||||
void setPoppingSound(bool value) { poping_sound_enabled_ = value; }
|
void setPoppingSound(bool value) { sound_.poping_enabled = value; }
|
||||||
void setSound(bool value) { sound_enabled_ = value; }
|
void setSound(bool value) { sound_.enabled = value; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// --- Estructura para el efecto de rebote ---
|
// --- Estructura para el efecto de rebote ---
|
||||||
@@ -114,10 +138,28 @@ class Balloon {
|
|||||||
|
|
||||||
// Tablas de valores predefinidos para el efecto de rebote
|
// Tablas de valores predefinidos para el efecto de rebote
|
||||||
static constexpr std::array<float, BOUNCE_FRAMES> HORIZONTAL_ZOOM_VALUES = {
|
static constexpr std::array<float, BOUNCE_FRAMES> HORIZONTAL_ZOOM_VALUES = {
|
||||||
1.10F, 1.05F, 1.00F, 0.95F, 0.90F, 0.95F, 1.00F, 1.02F, 1.05F, 1.02F};
|
1.10F,
|
||||||
|
1.05F,
|
||||||
|
1.00F,
|
||||||
|
0.95F,
|
||||||
|
0.90F,
|
||||||
|
0.95F,
|
||||||
|
1.00F,
|
||||||
|
1.02F,
|
||||||
|
1.05F,
|
||||||
|
1.02F};
|
||||||
|
|
||||||
static constexpr std::array<float, BOUNCE_FRAMES> VERTICAL_ZOOM_VALUES = {
|
static constexpr std::array<float, BOUNCE_FRAMES> VERTICAL_ZOOM_VALUES = {
|
||||||
0.90F, 0.95F, 1.00F, 1.05F, 1.10F, 1.05F, 1.00F, 0.98F, 0.95F, 0.98F};
|
0.90F,
|
||||||
|
0.95F,
|
||||||
|
1.00F,
|
||||||
|
1.05F,
|
||||||
|
1.10F,
|
||||||
|
1.05F,
|
||||||
|
1.00F,
|
||||||
|
0.98F,
|
||||||
|
0.95F,
|
||||||
|
0.98F};
|
||||||
|
|
||||||
// Estado del efecto
|
// Estado del efecto
|
||||||
bool enabled_ = false; // Si el efecto está activo
|
bool enabled_ = false; // Si el efecto está activo
|
||||||
@@ -203,52 +245,48 @@ class Balloon {
|
|||||||
std::unique_ptr<AnimatedSprite> sprite_; // Sprite del objeto globo
|
std::unique_ptr<AnimatedSprite> sprite_; // Sprite del objeto globo
|
||||||
|
|
||||||
// --- Variables de estado y físicas ---
|
// --- Variables de estado y físicas ---
|
||||||
float x_; // Posición X
|
float x_; // Posición X
|
||||||
float y_; // Posición Y
|
float y_; // Posición Y
|
||||||
float w_; // Ancho
|
float w_; // Ancho
|
||||||
float h_; // Alto
|
float h_; // Alto
|
||||||
float vx_; // Velocidad X
|
float vx_; // Velocidad X
|
||||||
float vy_; // Velocidad Y
|
float vy_; // Velocidad Y
|
||||||
float gravity_; // Aceleración en Y
|
float gravity_; // Aceleración en Y
|
||||||
float default_vy_; // Velocidad inicial al rebotar
|
float default_vy_; // Velocidad inicial al rebotar
|
||||||
float max_vy_; // Máxima velocidad en Y
|
float max_vy_; // Máxima velocidad en Y
|
||||||
bool being_created_; // Si el globo se está creando
|
bool being_created_; // Si el globo se está creando
|
||||||
bool enabled_ = true; // Si el globo está activo
|
bool enabled_ = true; // Si el globo está activo
|
||||||
bool invulnerable_; // Si el globo es invulnerable
|
bool invulnerable_; // Si el globo es invulnerable
|
||||||
bool stopped_; // Si el globo está parado
|
bool stopped_; // Si el globo está parado
|
||||||
bool use_reversed_colors_ = false; // Si se usa el color alternativo
|
bool use_reversed_colors_ = false; // Si se usa el color alternativo
|
||||||
Circle collider_; // Círculo de colisión
|
Circle collider_; // Círculo de colisión
|
||||||
Uint16 creation_counter_; // Temporizador de creación
|
float creation_counter_; // Temporizador de creación
|
||||||
Uint16 creation_counter_ini_; // Valor inicial del temporizador de creación
|
float creation_counter_ini_; // Valor inicial del temporizador de creación
|
||||||
Uint16 score_; // Puntos al destruir el globo
|
Uint16 score_; // Puntos al destruir el globo
|
||||||
Type type_; // Tipo de globo
|
Type type_; // Tipo de globo
|
||||||
Size size_; // Tamaño de globo
|
Size size_; // Tamaño de globo
|
||||||
Uint8 menace_; // Amenaza que genera el globo
|
Uint8 menace_; // Amenaza que genera el globo
|
||||||
Uint32 counter_ = 0; // Contador interno
|
Uint32 counter_ = 0; // Contador interno
|
||||||
float travel_y_ = 1.0F; // Distancia a recorrer en Y antes de aplicar gravedad
|
float game_tempo_; // Multiplicador de tempo del juego
|
||||||
float speed_; // Velocidad del globo
|
float movement_accumulator_ = 0.0F; // Acumulador para movimiento durante creación (deltaTime)
|
||||||
Uint8 power_; // Poder que alberga el globo
|
Uint8 power_; // Poder que alberga el globo
|
||||||
SDL_FRect play_area_; // Zona de movimiento del globo
|
SDL_FRect play_area_; // Zona de movimiento del globo
|
||||||
std::string bouncing_sound_; // Archivo de sonido al rebotar
|
Sound sound_; // Configuración de sonido del globo
|
||||||
std::string popping_sound_; // Archivo de sonido al explotar
|
BounceEffect bounce_effect_; // Efecto de rebote
|
||||||
bool bouncing_sound_enabled_ = false; // Si debe sonar el globo al rebotar
|
|
||||||
bool poping_sound_enabled_ = true; // Si debe sonar el globo al explotar
|
|
||||||
bool sound_enabled_ = true; // Indica si los globos deben hacer algun sonido
|
|
||||||
BounceEffect bounce_effect_; // Efecto de rebote
|
|
||||||
|
|
||||||
// --- Posicionamiento y transformación ---
|
// --- Posicionamiento y transformación ---
|
||||||
void shiftColliders(); // Alinea el círculo de colisión con el sprite
|
void shiftColliders(); // Alinea el círculo de colisión con el sprite
|
||||||
void shiftSprite(); // Alinea el sprite en pantalla
|
void shiftSprite(); // Alinea el sprite en pantalla
|
||||||
|
|
||||||
// --- Animación y sonido ---
|
// --- Animación y sonido ---
|
||||||
void setAnimation(); // Establece la animación correspondiente
|
void setAnimation(); // Establece la animación correspondiente
|
||||||
void playSound(const std::string& name) const; // Reproduce un sonido por nombre
|
void playBouncingSound() const; // Reproduce el sonido de rebote
|
||||||
void playBouncingSound(); // Reproduce el sonido de rebote
|
void playPoppingSound() const; // Reproduce el sonido de reventar
|
||||||
|
|
||||||
// --- Movimiento y física ---
|
// --- Movimiento y física ---
|
||||||
void handleHorizontalMovement(); // Maneja el movimiento horizontal
|
void handleHorizontalMovement(float delta_time); // Maneja el movimiento horizontal (time-based)
|
||||||
void handleVerticalMovement(); // Maneja el movimiento vertical
|
void handleVerticalMovement(float delta_time); // Maneja el movimiento vertical (time-based)
|
||||||
void applyGravity(); // Aplica la gravedad al objeto
|
void applyGravity(float delta_time); // Aplica la gravedad al objeto (time-based)
|
||||||
|
|
||||||
// --- Rebote ---
|
// --- Rebote ---
|
||||||
void enableBounceEffect(); // Activa el efecto de rebote
|
void enableBounceEffect(); // Activa el efecto de rebote
|
||||||
@@ -263,5 +301,5 @@ class Balloon {
|
|||||||
void handleBottomCollision(); // Maneja la colisión inferior
|
void handleBottomCollision(); // Maneja la colisión inferior
|
||||||
|
|
||||||
// --- Lógica de estado ---
|
// --- Lógica de estado ---
|
||||||
void updateState(); // Actualiza los estados del globo
|
void updateState(float delta_time); // Actualiza los estados del globo (time-based)
|
||||||
};
|
};
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "balloon_formations.h"
|
#include "balloon_formations.hpp"
|
||||||
|
|
||||||
#include <algorithm> // Para max, min, copy
|
#include <algorithm> // Para max, min, copy
|
||||||
#include <array> // Para array
|
#include <array> // Para array
|
||||||
@@ -11,10 +11,10 @@
|
|||||||
#include <sstream> // Para basic_istringstream
|
#include <sstream> // Para basic_istringstream
|
||||||
#include <string> // Para string, char_traits, allocator, operator==, stoi, getline, operator<=>, basic_string
|
#include <string> // Para string, char_traits, allocator, operator==, stoi, getline, operator<=>, basic_string
|
||||||
|
|
||||||
#include "asset.h" // Para Asset
|
#include "asset.hpp" // Para Asset
|
||||||
#include "balloon.h" // Para Balloon
|
#include "balloon.hpp" // Para Balloon
|
||||||
#include "param.h" // Para Param, ParamGame, param
|
#include "param.hpp" // Para Param, ParamGame, param
|
||||||
#include "utils.h" // Para Zone, BLOCK
|
#include "utils.hpp" // Para Zone, BLOCK
|
||||||
|
|
||||||
void BalloonFormations::initFormations() {
|
void BalloonFormations::initFormations() {
|
||||||
// Calcular posiciones base
|
// Calcular posiciones base
|
||||||
@@ -155,7 +155,7 @@ auto BalloonFormations::parseBalloonLine(const std::string& line, const std::map
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
int creation_time = DEFAULT_CREATION_TIME + evaluateExpression(tokens.at(6), variables);
|
float creation_time = CREATION_TIME + evaluateExpression(tokens.at(6), variables); // Base time + offset from formations.txt
|
||||||
|
|
||||||
return SpawnParams(x + offset, y, vel_x, type, size, creation_time);
|
return SpawnParams(x + offset, y, vel_x, type, size, creation_time);
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
@@ -168,7 +168,7 @@ auto BalloonFormations::evaluateExpression(const std::string& expr, const std::m
|
|||||||
|
|
||||||
// Si es un número directo
|
// Si es un número directo
|
||||||
if ((std::isdigit(trimmed_expr.at(0)) != 0) || (trimmed_expr.at(0) == '-' && trimmed_expr.length() > 1)) {
|
if ((std::isdigit(trimmed_expr.at(0)) != 0) || (trimmed_expr.at(0) == '-' && trimmed_expr.length() > 1)) {
|
||||||
return std::stoi(trimmed_expr);
|
return std::stof(trimmed_expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si es una variable simple
|
// Si es una variable simple
|
||||||
@@ -205,7 +205,7 @@ auto BalloonFormations::evaluateSimpleExpression(const std::string& expr, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Si no se encuentra operador, intentar como variable o número
|
// Si no se encuentra operador, intentar como variable o número
|
||||||
return variables.find(expr) != variables.end() ? variables.at(expr) : std::stoi(expr);
|
return variables.find(expr) != variables.end() ? variables.at(expr) : std::stof(expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto BalloonFormations::trim(const std::string& str) -> std::string {
|
auto BalloonFormations::trim(const std::string& str) -> std::string {
|
||||||
@@ -235,10 +235,10 @@ void BalloonFormations::createFloaterVariants() {
|
|||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
void BalloonFormations::addTestFormation() {
|
void BalloonFormations::addTestFormation() {
|
||||||
std::vector<SpawnParams> test_params = {
|
std::vector<SpawnParams> test_params = {
|
||||||
{10, -BLOCK, 0, Balloon::Type::FLOATER, Balloon::Size::SMALL, 200},
|
{10, -BLOCK, 0, Balloon::Type::FLOATER, Balloon::Size::SMALL, 3.334F}, // 200 frames ÷ 60fps = 3.334s
|
||||||
{50, -BLOCK, 0, Balloon::Type::FLOATER, Balloon::Size::MEDIUM, 200},
|
{50, -BLOCK, 0, Balloon::Type::FLOATER, Balloon::Size::MEDIUM, 3.334F}, // 200 frames ÷ 60fps = 3.334s
|
||||||
{90, -BLOCK, 0, Balloon::Type::FLOATER, Balloon::Size::LARGE, 200},
|
{90, -BLOCK, 0, Balloon::Type::FLOATER, Balloon::Size::LARGE, 3.334F}, // 200 frames ÷ 60fps = 3.334s
|
||||||
{140, -BLOCK, 0, Balloon::Type::FLOATER, Balloon::Size::EXTRALARGE, 200}};
|
{140, -BLOCK, 0, Balloon::Type::FLOATER, Balloon::Size::EXTRALARGE, 3.334F}}; // 200 frames ÷ 60fps = 3.334s
|
||||||
|
|
||||||
formations_.at(99) = Formation(test_params);
|
formations_.at(99) = Formation(test_params);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +1,38 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <algorithm> // Para copy, max
|
#include <cstddef> // Para size_t
|
||||||
#include <cstddef> // Para size_t
|
#include <iterator> // Para pair
|
||||||
#include <map> // Para map
|
#include <map> // Para map
|
||||||
#include <optional> // Para optional
|
#include <optional> // Para optional
|
||||||
#include <string> // Para string
|
#include <string> // Para string
|
||||||
#include <utility> // Para pair
|
#include <utility> // Para pair
|
||||||
#include <vector> // Para vector
|
#include <vector> // Para vector
|
||||||
|
|
||||||
#include "balloon.h" // Para Balloon
|
#include "balloon.hpp" // for Balloon
|
||||||
|
|
||||||
// --- Clase BalloonFormations ---
|
// --- Clase BalloonFormations ---
|
||||||
class BalloonFormations {
|
class BalloonFormations {
|
||||||
public:
|
public:
|
||||||
// --- Estructuras ---
|
// --- Estructuras ---
|
||||||
struct SpawnParams {
|
struct SpawnParams {
|
||||||
int x = 0; // Posición en el eje X donde crear el globo
|
float x = 0; // Posición en el eje X donde crear el globo
|
||||||
int y = 0; // Posición en el eje Y donde crear el globo
|
float y = 0; // Posición en el eje Y donde crear el globo
|
||||||
float vel_x = 0.0F; // Velocidad inicial en el eje X
|
float vel_x = 0.0F; // Velocidad inicial en el eje X
|
||||||
Balloon::Type type = Balloon::Type::BALLOON; // Tipo de globo
|
Balloon::Type type = Balloon::Type::BALLOON; // Tipo de globo
|
||||||
Balloon::Size size = Balloon::Size::SMALL; // Tamaño de globo
|
Balloon::Size size = Balloon::Size::SMALL; // Tamaño de globo
|
||||||
int creation_counter = 0; // Temporizador para la creación del globo
|
float creation_counter = 0.0F; // Temporizador para la creación del globo
|
||||||
|
|
||||||
// Constructor por defecto
|
// Constructor por defecto
|
||||||
SpawnParams() = default;
|
SpawnParams() = default;
|
||||||
|
|
||||||
// Constructor con parámetros
|
// Constructor con parámetros
|
||||||
SpawnParams(int x, int y, float vel_x, Balloon::Type type, Balloon::Size size, int creation_counter)
|
SpawnParams(float x, float y, float vel_x, Balloon::Type type, Balloon::Size size, float creation_counter)
|
||||||
: x(x), y(y), vel_x(vel_x), type(type), size(size), creation_counter(creation_counter) {}
|
: x(x),
|
||||||
|
y(y),
|
||||||
|
vel_x(vel_x),
|
||||||
|
type(type),
|
||||||
|
size(size),
|
||||||
|
creation_counter(creation_counter) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Formation {
|
struct Formation {
|
||||||
@@ -76,8 +81,9 @@ class BalloonFormations {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// --- Constantes ---
|
// --- Constantes ---
|
||||||
static constexpr int BALLOON_SPAWN_HEIGHT = 208; // Altura desde el suelo en la que aparecen los globos
|
static constexpr int BALLOON_SPAWN_HEIGHT = 208; // Altura desde el suelo en la que aparecen los globos
|
||||||
static constexpr int DEFAULT_CREATION_TIME = 200; // Tiempo base de creación de los globos para las formaciones
|
static constexpr float CREATION_TIME = 5.0F; // Tiempo base de creación de los globos en segundos (300 frames ÷ 60fps = 5.0s)
|
||||||
|
static constexpr float DEFAULT_CREATION_TIME = 3.334F; // Tiempo base de creación de los globos en segundos (200 frames ÷ 60fps = 3.334s)
|
||||||
|
|
||||||
// --- Variables ---
|
// --- Variables ---
|
||||||
std::vector<Formation> formations_; // Vector con todas las formaciones disponibles
|
std::vector<Formation> formations_; // Vector con todas las formaciones disponibles
|
||||||
@@ -1,23 +1,25 @@
|
|||||||
#include "balloon_manager.h"
|
#include "balloon_manager.hpp"
|
||||||
|
|
||||||
#include <algorithm> // Para remove_if
|
#include <algorithm> // Para remove_if
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstdlib> // Para rand
|
#include <cstdlib> // Para rand
|
||||||
#include <numeric> // Para accumulate
|
#include <numeric> // Para accumulate
|
||||||
|
|
||||||
#include "balloon.h" // Para Balloon, Balloon::SCORE.at( )ALLOON_VELX...
|
#include "balloon.hpp" // Para Balloon, Balloon::SCORE.at( )ALLOON_VELX...
|
||||||
#include "balloon_formations.h" // Para BalloonFormationParams, BalloonForma...
|
#include "balloon_formations.hpp" // Para BalloonFormationParams, BalloonForma...
|
||||||
#include "color.h" // Para Zone, Color, flash_color
|
#include "color.hpp" // Para Zone, Color, flash_color
|
||||||
#include "explosions.h" // Para Explosions
|
#include "explosions.hpp" // Para Explosions
|
||||||
#include "param.h" // Para Param, ParamGame, param
|
#include "param.hpp" // Para Param, ParamGame, param
|
||||||
#include "resource.h" // Para Resource
|
#include "resource.hpp" // Para Resource
|
||||||
#include "screen.h" // Para Screen
|
#include "screen.hpp" // Para Screen
|
||||||
#include "stage_interface.h" // Para IStageInfo
|
#include "stage_interface.hpp" // Para IStageInfo
|
||||||
#include "utils.h"
|
#include "utils.hpp"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
BalloonManager::BalloonManager(IStageInfo *stage_info)
|
BalloonManager::BalloonManager(IStageInfo* stage_info)
|
||||||
: explosions_(std::make_unique<Explosions>()), balloon_formations_(std::make_unique<BalloonFormations>()), stage_info_(stage_info) { init(); }
|
: explosions_(std::make_unique<Explosions>()),
|
||||||
|
balloon_formations_(std::make_unique<BalloonFormations>()),
|
||||||
|
stage_info_(stage_info) { init(); }
|
||||||
|
|
||||||
// Inicializa
|
// Inicializa
|
||||||
void BalloonManager::init() {
|
void BalloonManager::init() {
|
||||||
@@ -60,18 +62,18 @@ void BalloonManager::init() {
|
|||||||
explosions_->addTexture(3, explosions_textures_.at(3), explosions_animations_.at(3));
|
explosions_->addTexture(3, explosions_textures_.at(3), explosions_animations_.at(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza
|
// Actualiza (time-based)
|
||||||
void BalloonManager::update() {
|
void BalloonManager::update(float delta_time) {
|
||||||
for (const auto &balloon : balloons_) {
|
for (const auto& balloon : balloons_) {
|
||||||
balloon->update();
|
balloon->update(delta_time);
|
||||||
}
|
}
|
||||||
updateBalloonDeployCounter();
|
updateBalloonDeployCounter(delta_time);
|
||||||
explosions_->update();
|
explosions_->update(delta_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renderiza los objetos
|
// Renderiza los objetos
|
||||||
void BalloonManager::render() {
|
void BalloonManager::render() {
|
||||||
for (auto &balloon : balloons_) {
|
for (auto& balloon : balloons_) {
|
||||||
balloon->render();
|
balloon->render();
|
||||||
}
|
}
|
||||||
explosions_->render();
|
explosions_->render();
|
||||||
@@ -79,12 +81,12 @@ void BalloonManager::render() {
|
|||||||
|
|
||||||
// Crea una formación de globos
|
// Crea una formación de globos
|
||||||
void BalloonManager::deployRandomFormation(int stage) {
|
void BalloonManager::deployRandomFormation(int stage) {
|
||||||
// Solo despliega una formación enemiga si ha pasado cierto tiempo desde la última
|
// Solo despliega una formación enemiga si el timer ha llegado a cero
|
||||||
if (balloon_deploy_counter_ == 0) {
|
if (balloon_deploy_counter_ <= 0.0F) {
|
||||||
// En este punto se decide entre crear una powerball o una formación enemiga
|
// En este punto se decide entre crear una powerball o una formación enemiga
|
||||||
if ((rand() % 100 < 15) && (canPowerBallBeCreated())) {
|
if ((rand() % 100 < 15) && (canPowerBallBeCreated())) {
|
||||||
createPowerBall(); // Crea una powerball
|
createPowerBall(); // Crea una powerball
|
||||||
balloon_deploy_counter_ = 10; // Da un poco de margen para que se creen mas globos
|
balloon_deploy_counter_ = POWERBALL_DEPLOY_DELAY; // Resetea con pequeño retraso
|
||||||
} else {
|
} else {
|
||||||
// Decrementa el contador de despliegues de globos necesarios para la siguiente PowerBall
|
// Decrementa el contador de despliegues de globos necesarios para la siguiente PowerBall
|
||||||
if (power_ball_counter_ > 0) {
|
if (power_ball_counter_ > 0) {
|
||||||
@@ -105,11 +107,19 @@ void BalloonManager::deployRandomFormation(int stage) {
|
|||||||
// Crea los globos de la formación
|
// Crea los globos de la formación
|
||||||
const auto BALLOONS = balloon_formations_->getFormationFromPool(stage, formation_id).balloons;
|
const auto BALLOONS = balloon_formations_->getFormationFromPool(stage, formation_id).balloons;
|
||||||
for (auto balloon : BALLOONS) {
|
for (auto balloon : BALLOONS) {
|
||||||
createBalloon(balloon.x, balloon.y, balloon.type, balloon.size, balloon.vel_x, balloon_speed_, (creation_time_enabled_) ? balloon.creation_counter : 0);
|
Balloon::Config config = {
|
||||||
|
.x = balloon.x,
|
||||||
|
.y = balloon.y,
|
||||||
|
.type = balloon.type,
|
||||||
|
.size = balloon.size,
|
||||||
|
.vel_x = balloon.vel_x,
|
||||||
|
.game_tempo = balloon_speed_,
|
||||||
|
.creation_counter = creation_time_enabled_ ? balloon.creation_counter : 0.0F};
|
||||||
|
createBalloon(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reinicia el contador para el próximo despliegue
|
// Reinicia el timer para el próximo despliegue
|
||||||
balloon_deploy_counter_ = DEFAULT_BALLOON_DEPLOY_COUNTER;
|
balloon_deploy_counter_ = DEFAULT_BALLOON_DEPLOY_DELAY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,29 +128,45 @@ void BalloonManager::deployRandomFormation(int stage) {
|
|||||||
void BalloonManager::deployFormation(int formation_id) {
|
void BalloonManager::deployFormation(int formation_id) {
|
||||||
const auto BALLOONS = balloon_formations_->getFormation(formation_id).balloons;
|
const auto BALLOONS = balloon_formations_->getFormation(formation_id).balloons;
|
||||||
for (auto balloon : BALLOONS) {
|
for (auto balloon : BALLOONS) {
|
||||||
createBalloon(balloon.x, balloon.y, balloon.type, balloon.size, balloon.vel_x, balloon_speed_, balloon.creation_counter);
|
Balloon::Config config = {
|
||||||
|
.x = balloon.x,
|
||||||
|
.y = balloon.y,
|
||||||
|
.type = balloon.type,
|
||||||
|
.size = balloon.size,
|
||||||
|
.vel_x = balloon.vel_x,
|
||||||
|
.game_tempo = balloon_speed_,
|
||||||
|
.creation_counter = balloon.creation_counter};
|
||||||
|
createBalloon(config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crea una formación de globos específica a una altura determinada
|
// Crea una formación de globos específica a una altura determinada
|
||||||
void BalloonManager::deployFormation(int formation_id, int y) {
|
void BalloonManager::deployFormation(int formation_id, float y) {
|
||||||
const auto BALLOONS = balloon_formations_->getFormation(formation_id).balloons;
|
const auto BALLOONS = balloon_formations_->getFormation(formation_id).balloons;
|
||||||
for (auto balloon : BALLOONS) {
|
for (auto balloon : BALLOONS) {
|
||||||
createBalloon(balloon.x, y, balloon.type, balloon.size, balloon.vel_x, balloon_speed_, balloon.creation_counter);
|
Balloon::Config config = {
|
||||||
|
.x = balloon.x,
|
||||||
|
.y = y,
|
||||||
|
.type = balloon.type,
|
||||||
|
.size = balloon.size,
|
||||||
|
.vel_x = balloon.vel_x,
|
||||||
|
.game_tempo = balloon_speed_,
|
||||||
|
.creation_counter = balloon.creation_counter};
|
||||||
|
createBalloon(config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vacia del vector de globos los globos que ya no sirven
|
// Vacia del vector de globos los globos que ya no sirven
|
||||||
void BalloonManager::freeBalloons() {
|
void BalloonManager::freeBalloons() {
|
||||||
auto result = std::ranges::remove_if(balloons_, [](const auto &balloon) { return !balloon->isEnabled(); });
|
std::erase_if(balloons_, [](const auto& balloon) {
|
||||||
balloons_.erase(result.begin(), balloons_.end());
|
return !balloon->isEnabled();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza la variable enemyDeployCounter
|
// Actualiza el timer de despliegue de globos (time-based)
|
||||||
void BalloonManager::updateBalloonDeployCounter() {
|
void BalloonManager::updateBalloonDeployCounter(float delta_time) {
|
||||||
if (balloon_deploy_counter_ > 0) {
|
// DeltaTime en segundos - timer decrementa hasta llegar a cero
|
||||||
--balloon_deploy_counter_;
|
balloon_deploy_counter_ -= delta_time;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indica si se puede crear una powerball
|
// Indica si se puede crear una powerball
|
||||||
@@ -148,17 +174,20 @@ auto BalloonManager::canPowerBallBeCreated() -> bool { return (!power_ball_enabl
|
|||||||
|
|
||||||
// Calcula el poder actual de los globos en pantalla
|
// Calcula el poder actual de los globos en pantalla
|
||||||
auto BalloonManager::calculateScreenPower() -> int {
|
auto BalloonManager::calculateScreenPower() -> int {
|
||||||
return std::accumulate(balloons_.begin(), balloons_.end(), 0, [](int sum, const auto &balloon) { return sum + (balloon->isEnabled() ? balloon->getPower() : 0); });
|
return std::accumulate(balloons_.begin(), balloons_.end(), 0, [](int sum, const auto& balloon) { return sum + (balloon->isEnabled() ? balloon->getPower() : 0); });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crea un globo nuevo en el vector de globos
|
// Crea un globo nuevo en el vector de globos
|
||||||
auto BalloonManager::createBalloon(float x, int y, Balloon::Type type, Balloon::Size size, float velx, float speed, int creation_timer) -> std::shared_ptr<Balloon> {
|
auto BalloonManager::createBalloon(Balloon::Config config) -> std::shared_ptr<Balloon> {
|
||||||
if (can_deploy_balloons_) {
|
if (can_deploy_balloons_) {
|
||||||
const int INDEX = static_cast<int>(size);
|
const int INDEX = static_cast<int>(config.size);
|
||||||
balloons_.emplace_back(std::make_shared<Balloon>(x, y, type, size, velx, speed, creation_timer, play_area_, balloon_textures_.at(INDEX), balloon_animations_.at(INDEX)));
|
config.play_area = play_area_;
|
||||||
balloons_.back()->setSound(sound_enabled_);
|
config.texture = balloon_textures_.at(INDEX);
|
||||||
balloons_.back()->setBouncingSound(bouncing_sound_enabled_);
|
config.animation = balloon_animations_.at(INDEX);
|
||||||
balloons_.back()->setPoppingSound(poping_sound_enabled_);
|
config.sound.enabled = sound_enabled_;
|
||||||
|
config.sound.bouncing_enabled = bouncing_sound_enabled_;
|
||||||
|
config.sound.poping_enabled = poping_sound_enabled_;
|
||||||
|
balloons_.emplace_back(std::make_shared<Balloon>(config));
|
||||||
return balloons_.back();
|
return balloons_.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,29 +195,50 @@ auto BalloonManager::createBalloon(float x, int y, Balloon::Type type, Balloon::
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Crea un globo a partir de otro globo
|
// Crea un globo a partir de otro globo
|
||||||
void BalloonManager::createChildBalloon(const std::shared_ptr<Balloon> &balloon, const std::string &direction) {
|
void BalloonManager::createChildBalloon(const std::shared_ptr<Balloon>& parent_balloon, const std::string& direction) {
|
||||||
if (can_deploy_balloons_) {
|
if (can_deploy_balloons_) {
|
||||||
// Calcula parametros
|
// Calcula parametros
|
||||||
const float VX = direction == "LEFT" ? Balloon::VELX_NEGATIVE : Balloon::VELX_POSITIVE;
|
const int PARENT_HEIGHT = parent_balloon->getHeight();
|
||||||
const auto SIZE = static_cast<Balloon::Size>(static_cast<int>(balloon->getSize()) - 1);
|
const int CHILD_HEIGHT = Balloon::WIDTH.at(static_cast<size_t>(parent_balloon->getSize()) - 1);
|
||||||
const int PARENT_HEIGHT = balloon->getHeight();
|
|
||||||
const int CHILD_HEIGHT = Balloon::WIDTH.at(static_cast<int>(balloon->getSize()) - 1);
|
|
||||||
const int CHILD_WIDTH = CHILD_HEIGHT;
|
const int CHILD_WIDTH = CHILD_HEIGHT;
|
||||||
const float Y = balloon->getPosY() + ((PARENT_HEIGHT - CHILD_HEIGHT) / 2);
|
|
||||||
float x = direction == "LEFT" ? balloon->getPosX() + (balloon->getWidth() / 3) : balloon->getPosX() + (2 * (balloon->getWidth() / 3));
|
const float X = direction == "LEFT" ? parent_balloon->getPosX() + (parent_balloon->getWidth() / 3) : parent_balloon->getPosX() + (2 * (parent_balloon->getWidth() / 3));
|
||||||
const float MIN_X = play_area_.x;
|
const float MIN_X = play_area_.x;
|
||||||
const float MAX_X = play_area_.w - CHILD_WIDTH;
|
const float MAX_X = play_area_.w - CHILD_WIDTH;
|
||||||
x = std::clamp(x - (CHILD_WIDTH / 2), MIN_X, MAX_X);
|
|
||||||
|
|
||||||
// Crea el globo
|
Balloon::Config config = {
|
||||||
auto b = createBalloon(x, Y, balloon->getType(), SIZE, VX, balloon_speed_, 0);
|
.x = std::clamp(X - (CHILD_WIDTH / 2), MIN_X, MAX_X),
|
||||||
|
.y = parent_balloon->getPosY() + ((PARENT_HEIGHT - CHILD_HEIGHT) / 2),
|
||||||
|
.type = parent_balloon->getType(),
|
||||||
|
.size = static_cast<Balloon::Size>(static_cast<int>(parent_balloon->getSize()) - 1),
|
||||||
|
.vel_x = direction == "LEFT" ? Balloon::VELX_NEGATIVE : Balloon::VELX_POSITIVE,
|
||||||
|
.game_tempo = balloon_speed_,
|
||||||
|
.creation_counter = 0};
|
||||||
|
|
||||||
// Establece parametros
|
// Crea el globo hijo
|
||||||
b->setVelY(b->getType() == Balloon::Type::BALLOON ? -2.50F : Balloon::VELX_NEGATIVE * 2.0F);
|
auto child_balloon = createBalloon(config);
|
||||||
|
|
||||||
// Herencia de estados
|
// Configura el globo hijo
|
||||||
if (balloon->isStopped()) { b->stop(); }
|
if (child_balloon != nullptr) {
|
||||||
if (balloon->isUsingReversedColor()) { b->useReverseColor(); }
|
// Establece parametros
|
||||||
|
constexpr float VEL_Y_BALLOON_PER_S = -150.0F;
|
||||||
|
switch (child_balloon->getType()) {
|
||||||
|
case Balloon::Type::BALLOON: {
|
||||||
|
child_balloon->setVelY(VEL_Y_BALLOON_PER_S);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Balloon::Type::FLOATER: {
|
||||||
|
child_balloon->setVelY(Balloon::VELX_NEGATIVE * 2.0F);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Herencia de estados
|
||||||
|
if (parent_balloon->isStopped()) { child_balloon->stop(); }
|
||||||
|
if (parent_balloon->isUsingReversedColor()) { child_balloon->useReverseColor(); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,18 +246,32 @@ void BalloonManager::createChildBalloon(const std::shared_ptr<Balloon> &balloon,
|
|||||||
void BalloonManager::createPowerBall() {
|
void BalloonManager::createPowerBall() {
|
||||||
if (can_deploy_balloons_) {
|
if (can_deploy_balloons_) {
|
||||||
constexpr int VALUES = 6;
|
constexpr int VALUES = 6;
|
||||||
constexpr float POS_Y = -Balloon::WIDTH.at(4);
|
const int LUCK = rand() % VALUES;
|
||||||
constexpr int CREATION_TIME = 0;
|
|
||||||
|
|
||||||
const float LEFT = param.game.play_area.rect.x;
|
const float LEFT = param.game.play_area.rect.x;
|
||||||
const float CENTER = param.game.play_area.center_x - (Balloon::WIDTH.at(4) / 2);
|
const float CENTER = param.game.play_area.center_x - (Balloon::WIDTH.at(4) / 2);
|
||||||
const float RIGHT = param.game.play_area.rect.w - Balloon::WIDTH.at(4);
|
const float RIGHT = param.game.play_area.rect.w - Balloon::WIDTH.at(4);
|
||||||
|
|
||||||
const int LUCK = rand() % VALUES;
|
|
||||||
const std::array<float, VALUES> POS_X = {LEFT, LEFT, CENTER, CENTER, RIGHT, RIGHT};
|
const std::array<float, VALUES> POS_X = {LEFT, LEFT, CENTER, CENTER, RIGHT, RIGHT};
|
||||||
const std::array<float, VALUES> VEL_X = {Balloon::VELX_POSITIVE, Balloon::VELX_POSITIVE, Balloon::VELX_POSITIVE, Balloon::VELX_NEGATIVE, Balloon::VELX_NEGATIVE, Balloon::VELX_NEGATIVE};
|
const std::array<float, VALUES> VEL_X = {Balloon::VELX_POSITIVE, Balloon::VELX_POSITIVE, Balloon::VELX_POSITIVE, Balloon::VELX_NEGATIVE, Balloon::VELX_NEGATIVE, Balloon::VELX_NEGATIVE};
|
||||||
|
|
||||||
balloons_.emplace_back(std::make_unique<Balloon>(POS_X[LUCK], POS_Y, Balloon::Type::POWERBALL, Balloon::Size::EXTRALARGE, VEL_X[LUCK], balloon_speed_, CREATION_TIME, play_area_, balloon_textures_[4], balloon_animations_[4]));
|
Balloon::Config config = {
|
||||||
|
.x = POS_X.at(LUCK),
|
||||||
|
.y = -Balloon::WIDTH.at(4),
|
||||||
|
.type = Balloon::Type::POWERBALL,
|
||||||
|
.size = Balloon::Size::EXTRALARGE,
|
||||||
|
.vel_x = VEL_X.at(LUCK),
|
||||||
|
.game_tempo = balloon_speed_,
|
||||||
|
.creation_counter = 0,
|
||||||
|
.play_area = play_area_,
|
||||||
|
.texture = balloon_textures_.at(4),
|
||||||
|
.animation = balloon_animations_.at(4),
|
||||||
|
.sound = {
|
||||||
|
.bouncing_enabled = bouncing_sound_enabled_,
|
||||||
|
.poping_enabled = poping_sound_enabled_,
|
||||||
|
.enabled = sound_enabled_}};
|
||||||
|
|
||||||
|
balloons_.emplace_back(std::make_unique<Balloon>(config));
|
||||||
balloons_.back()->setInvulnerable(true);
|
balloons_.back()->setInvulnerable(true);
|
||||||
|
|
||||||
power_ball_enabled_ = true;
|
power_ball_enabled_ = true;
|
||||||
@@ -218,13 +282,13 @@ void BalloonManager::createPowerBall() {
|
|||||||
// Establece la velocidad de los globos
|
// Establece la velocidad de los globos
|
||||||
void BalloonManager::setBalloonSpeed(float speed) {
|
void BalloonManager::setBalloonSpeed(float speed) {
|
||||||
balloon_speed_ = speed;
|
balloon_speed_ = speed;
|
||||||
for (auto &balloon : balloons_) {
|
for (auto& balloon : balloons_) {
|
||||||
balloon->setSpeed(speed);
|
balloon->setGameTempo(speed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Explosiona un globo. Lo destruye y crea otros dos si es el caso
|
// Explosiona un globo. Lo destruye y crea otros dos si es el caso
|
||||||
auto BalloonManager::popBalloon(const std::shared_ptr<Balloon> &balloon) -> int {
|
auto BalloonManager::popBalloon(const std::shared_ptr<Balloon>& balloon) -> int {
|
||||||
stage_info_->addPower(1);
|
stage_info_->addPower(1);
|
||||||
int score = 0;
|
int score = 0;
|
||||||
|
|
||||||
@@ -232,7 +296,7 @@ auto BalloonManager::popBalloon(const std::shared_ptr<Balloon> &balloon) -> int
|
|||||||
balloon->pop(true);
|
balloon->pop(true);
|
||||||
score = destroyAllBalloons();
|
score = destroyAllBalloons();
|
||||||
power_ball_enabled_ = false;
|
power_ball_enabled_ = false;
|
||||||
balloon_deploy_counter_ = 20;
|
balloon_deploy_counter_ = BALLOON_POP_DELAY; // Resetea con retraso
|
||||||
} else {
|
} else {
|
||||||
score = balloon->getScore();
|
score = balloon->getScore();
|
||||||
if (balloon->getSize() != Balloon::Size::SMALL) {
|
if (balloon->getSize() != Balloon::Size::SMALL) {
|
||||||
@@ -249,7 +313,7 @@ auto BalloonManager::popBalloon(const std::shared_ptr<Balloon> &balloon) -> int
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Explosiona un globo. Lo destruye = no crea otros globos
|
// Explosiona un globo. Lo destruye = no crea otros globos
|
||||||
auto BalloonManager::destroyBalloon(std::shared_ptr<Balloon> &balloon) -> int {
|
auto BalloonManager::destroyBalloon(std::shared_ptr<Balloon>& balloon) -> int {
|
||||||
int score = 0;
|
int score = 0;
|
||||||
|
|
||||||
// Calcula la puntuación y el poder que generaria el globo en caso de romperlo a él y a sus hijos
|
// Calcula la puntuación y el poder que generaria el globo en caso de romperlo a él y a sus hijos
|
||||||
@@ -284,12 +348,12 @@ auto BalloonManager::destroyBalloon(std::shared_ptr<Balloon> &balloon) -> int {
|
|||||||
// Destruye todos los globos
|
// Destruye todos los globos
|
||||||
auto BalloonManager::destroyAllBalloons() -> int {
|
auto BalloonManager::destroyAllBalloons() -> int {
|
||||||
int score = 0;
|
int score = 0;
|
||||||
for (auto &balloon : balloons_) {
|
for (auto& balloon : balloons_) {
|
||||||
score += destroyBalloon(balloon);
|
score += destroyBalloon(balloon);
|
||||||
}
|
}
|
||||||
|
|
||||||
balloon_deploy_counter_ = 300;
|
balloon_deploy_counter_ = DEFAULT_BALLOON_DEPLOY_DELAY;
|
||||||
Screen::get()->flash(Colors::FLASH, 3);
|
Screen::get()->flash(Colors::FLASH, 0.05F);
|
||||||
Screen::get()->shake();
|
Screen::get()->shake();
|
||||||
|
|
||||||
return score;
|
return score;
|
||||||
@@ -297,14 +361,16 @@ auto BalloonManager::destroyAllBalloons() -> int {
|
|||||||
|
|
||||||
// Detiene todos los globos
|
// Detiene todos los globos
|
||||||
void BalloonManager::stopAllBalloons() {
|
void BalloonManager::stopAllBalloons() {
|
||||||
for (auto &balloon : balloons_) {
|
for (auto& balloon : balloons_) {
|
||||||
balloon->stop();
|
if (!balloon->isBeingCreated()) {
|
||||||
|
balloon->stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pone en marcha todos los globos
|
// Pone en marcha todos los globos
|
||||||
void BalloonManager::startAllBalloons() {
|
void BalloonManager::startAllBalloons() {
|
||||||
for (auto &balloon : balloons_) {
|
for (auto& balloon : balloons_) {
|
||||||
if (!balloon->isBeingCreated()) {
|
if (!balloon->isBeingCreated()) {
|
||||||
balloon->start();
|
balloon->start();
|
||||||
}
|
}
|
||||||
@@ -313,7 +379,7 @@ void BalloonManager::startAllBalloons() {
|
|||||||
|
|
||||||
// Cambia el color de todos los globos
|
// Cambia el color de todos los globos
|
||||||
void BalloonManager::reverseColorsToAllBalloons() {
|
void BalloonManager::reverseColorsToAllBalloons() {
|
||||||
for (auto &balloon : balloons_) {
|
for (auto& balloon : balloons_) {
|
||||||
if (balloon->isStopped()) {
|
if (balloon->isStopped()) {
|
||||||
balloon->useReverseColor();
|
balloon->useReverseColor();
|
||||||
}
|
}
|
||||||
@@ -322,7 +388,7 @@ void BalloonManager::reverseColorsToAllBalloons() {
|
|||||||
|
|
||||||
// Cambia el color de todos los globos
|
// Cambia el color de todos los globos
|
||||||
void BalloonManager::normalColorsToAllBalloons() {
|
void BalloonManager::normalColorsToAllBalloons() {
|
||||||
for (auto &balloon : balloons_) {
|
for (auto& balloon : balloons_) {
|
||||||
balloon->useNormalColor();
|
balloon->useNormalColor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -332,28 +398,15 @@ void BalloonManager::createTwoBigBalloons() {
|
|||||||
deployFormation(1);
|
deployFormation(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crea una disposición de globos aleatoria
|
|
||||||
void BalloonManager::createRandomBalloons() {
|
|
||||||
const int NUM_BALLOONS = 2 + (rand() % 4);
|
|
||||||
for (int i = 0; i < NUM_BALLOONS; ++i) {
|
|
||||||
const float X = param.game.game_area.rect.x + (rand() % static_cast<int>(param.game.game_area.rect.w)) - Balloon::WIDTH.at(3);
|
|
||||||
const int Y = param.game.game_area.rect.y + (rand() % 50);
|
|
||||||
const auto SIZE = static_cast<Balloon::Size>(rand() % 4);
|
|
||||||
const float VEL_X = (rand() % 2 == 0) ? Balloon::VELX_POSITIVE : Balloon::VELX_NEGATIVE;
|
|
||||||
const int CREATION_COUNTER = 0;
|
|
||||||
createBalloon(X, Y, Balloon::Type::BALLOON, SIZE, VEL_X, balloon_speed_, CREATION_COUNTER);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtiene el nivel de ameza actual generado por los globos
|
// Obtiene el nivel de ameza actual generado por los globos
|
||||||
auto BalloonManager::getMenace() -> int {
|
auto BalloonManager::getMenace() -> int {
|
||||||
return std::accumulate(balloons_.begin(), balloons_.end(), 0, [](int sum, const auto &balloon) { return sum + (balloon->isEnabled() ? balloon->getMenace() : 0); });
|
return std::accumulate(balloons_.begin(), balloons_.end(), 0, [](int sum, const auto& balloon) { return sum + (balloon->isEnabled() ? balloon->getMenace() : 0); });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el sonido de los globos
|
// Establece el sonido de los globos
|
||||||
void BalloonManager::setSounds(bool value) {
|
void BalloonManager::setSounds(bool value) {
|
||||||
sound_enabled_ = value;
|
sound_enabled_ = value;
|
||||||
for (auto &balloon : balloons_) {
|
for (auto& balloon : balloons_) {
|
||||||
balloon->setSound(value);
|
balloon->setSound(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -361,14 +414,14 @@ void BalloonManager::setSounds(bool value) {
|
|||||||
// Activa o desactiva los sonidos de rebote los globos
|
// Activa o desactiva los sonidos de rebote los globos
|
||||||
void BalloonManager::setBouncingSounds(bool value) {
|
void BalloonManager::setBouncingSounds(bool value) {
|
||||||
bouncing_sound_enabled_ = value;
|
bouncing_sound_enabled_ = value;
|
||||||
for (auto &balloon : balloons_) {
|
for (auto& balloon : balloons_) {
|
||||||
balloon->setBouncingSound(value);
|
balloon->setBouncingSound(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Activa o desactiva los sonidos de los globos al explotar
|
// Activa o desactiva los sonidos de los globos al explotar
|
||||||
void BalloonManager::setPoppingSounds(bool value) {
|
void BalloonManager::setPoppingSounds(bool value) {
|
||||||
poping_sound_enabled_ = value;
|
poping_sound_enabled_ = value;
|
||||||
for (auto &balloon : balloons_) {
|
for (auto& balloon : balloons_) {
|
||||||
balloon->setPoppingSound(value);
|
balloon->setPoppingSound(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,61 +2,60 @@
|
|||||||
|
|
||||||
#include <SDL3/SDL.h> // Para SDL_FRect
|
#include <SDL3/SDL.h> // Para SDL_FRect
|
||||||
|
|
||||||
#include <algorithm> // Para max
|
#include <array> // Para array
|
||||||
#include <array> // Para array
|
#include <list> // Para list
|
||||||
#include <memory> // Para shared_ptr, unique_ptr
|
#include <memory> // Para shared_ptr, unique_ptr
|
||||||
#include <string> // Para string
|
#include <string> // Para basic_string, string
|
||||||
#include <vector> // Para vector
|
#include <vector> // Para vector
|
||||||
|
|
||||||
#include "balloon.h" // Para BALLOON_SPEED, Balloon, Balloon::Size (ptr only), Balloon::Type (ptr only)
|
#include "balloon.hpp" // for Balloon
|
||||||
#include "balloon_formations.h" // Para BalloonFormations
|
#include "balloon_formations.hpp" // for BalloonFormations
|
||||||
#include "explosions.h" // Para Explosions
|
#include "explosions.hpp" // for Explosions
|
||||||
#include "param.h" // Para Param, ParamGame, param
|
#include "param.hpp" // for Param, ParamGame, param
|
||||||
#include "stage_interface.h" // Para IStageInfo
|
#include "utils.hpp" // for Zone
|
||||||
#include "utils.h" // Para Zone
|
|
||||||
|
|
||||||
|
class IStageInfo;
|
||||||
class Texture;
|
class Texture;
|
||||||
|
|
||||||
// --- Types ---
|
// --- Types ---
|
||||||
using Balloons = std::vector<std::shared_ptr<Balloon>>;
|
using Balloons = std::list<std::shared_ptr<Balloon>>;
|
||||||
|
|
||||||
// --- Clase BalloonManager: gestiona todos los globos del juego ---
|
// --- Clase BalloonManager: gestiona todos los globos del juego ---
|
||||||
class BalloonManager {
|
class BalloonManager {
|
||||||
public:
|
public:
|
||||||
// --- Constructor y destructor ---
|
// --- Constructor y destructor ---
|
||||||
BalloonManager(IStageInfo *stage_info);
|
BalloonManager(IStageInfo* stage_info);
|
||||||
~BalloonManager() = default;
|
~BalloonManager() = default;
|
||||||
|
|
||||||
// --- Métodos principales ---
|
// --- Métodos principales ---
|
||||||
void update(); // Actualiza el estado de los globos
|
void update(float delta_time); // Actualiza el estado de los globos (time-based)
|
||||||
void render(); // Renderiza los globos en pantalla
|
void render(); // Renderiza los globos en pantalla
|
||||||
|
|
||||||
// --- Gestión de globos ---
|
// --- Gestión de globos ---
|
||||||
void freeBalloons(); // Libera globos que ya no sirven
|
void freeBalloons(); // Libera globos que ya no sirven
|
||||||
|
|
||||||
// --- Creación de formaciones enemigas ---
|
// --- Creación de formaciones enemigas ---
|
||||||
void deployRandomFormation(int stage); // Crea una formación de globos aleatoria
|
void deployRandomFormation(int stage); // Crea una formación de globos aleatoria
|
||||||
void deployFormation(int formation_id); // Crea una formación específica
|
void deployFormation(int formation_id); // Crea una formación específica
|
||||||
void deployFormation(int formation_id, int y); // Crea una formación específica con coordenadas
|
void deployFormation(int formation_id, float y); // Crea una formación específica con coordenadas
|
||||||
|
|
||||||
// --- Creación de globos ---
|
// --- Creación de globos ---
|
||||||
auto createBalloon(float x, int y, Balloon::Type type, Balloon::Size size, float velx, float speed, int creation_timer) -> std::shared_ptr<Balloon>; // Crea un nuevo globo
|
auto createBalloon(Balloon::Config config) -> std::shared_ptr<Balloon>; // Crea un nuevo globo
|
||||||
void createChildBalloon(const std::shared_ptr<Balloon> &balloon, const std::string &direction); // Crea un globo a partir de otro
|
void createChildBalloon(const std::shared_ptr<Balloon>& balloon, const std::string& direction); // Crea un globo a partir de otro
|
||||||
void createPowerBall(); // Crea una PowerBall
|
void createPowerBall(); // Crea una PowerBall
|
||||||
void createTwoBigBalloons(); // Crea dos globos grandes
|
void createTwoBigBalloons(); // Crea dos globos grandes
|
||||||
void createRandomBalloons(); // Crea una disposición aleatoria de globos
|
|
||||||
|
|
||||||
// --- Control de velocidad y despliegue ---
|
// --- Control de velocidad y despliegue ---
|
||||||
void setBalloonSpeed(float speed); // Ajusta la velocidad de los globos
|
void setBalloonSpeed(float speed); // Ajusta la velocidad de los globos
|
||||||
void setDefaultBalloonSpeed(float speed) { default_balloon_speed_ = speed; }; // Establece la velocidad base
|
void setDefaultBalloonSpeed(float speed) { default_balloon_speed_ = speed; }; // Establece la velocidad base
|
||||||
void resetBalloonSpeed() { setBalloonSpeed(default_balloon_speed_); }; // Restablece la velocidad de los globos
|
void resetBalloonSpeed() { setBalloonSpeed(default_balloon_speed_); }; // Restablece la velocidad de los globos
|
||||||
void updateBalloonDeployCounter(); // Actualiza el contador de despliegue
|
void updateBalloonDeployCounter(float delta_time); // Actualiza el contador de despliegue (time-based)
|
||||||
auto canPowerBallBeCreated() -> bool; // Indica si se puede crear una PowerBall
|
auto canPowerBallBeCreated() -> bool; // Indica si se puede crear una PowerBall
|
||||||
auto calculateScreenPower() -> int; // Calcula el poder de los globos en pantalla
|
auto calculateScreenPower() -> int; // Calcula el poder de los globos en pantalla
|
||||||
|
|
||||||
// --- Manipulación de globos existentes ---
|
// --- Manipulación de globos existentes ---
|
||||||
auto popBalloon(const std::shared_ptr<Balloon> &balloon) -> int; // Explosiona un globo, creando otros si aplica
|
auto popBalloon(const std::shared_ptr<Balloon>& balloon) -> int; // Explosiona un globo, creando otros si aplica
|
||||||
auto destroyBalloon(std::shared_ptr<Balloon> &balloon) -> int; // Explosiona un globo sin crear otros
|
auto destroyBalloon(std::shared_ptr<Balloon>& balloon) -> int; // Explosiona un globo sin crear otros
|
||||||
auto destroyAllBalloons() -> int; // Destruye todos los globos
|
auto destroyAllBalloons() -> int; // Destruye todos los globos
|
||||||
void stopAllBalloons(); // Detiene el movimiento de los globos
|
void stopAllBalloons(); // Detiene el movimiento de los globos
|
||||||
void startAllBalloons(); // Reactiva el movimiento de los globos
|
void startAllBalloons(); // Reactiva el movimiento de los globos
|
||||||
@@ -78,12 +77,14 @@ class BalloonManager {
|
|||||||
// --- Getters ---
|
// --- Getters ---
|
||||||
auto getMenace() -> int; // Obtiene el nivel de amenaza generado por los globos
|
auto getMenace() -> int; // Obtiene el nivel de amenaza generado por los globos
|
||||||
[[nodiscard]] auto getBalloonSpeed() const -> float { return balloon_speed_; }
|
[[nodiscard]] auto getBalloonSpeed() const -> float { return balloon_speed_; }
|
||||||
auto getBalloons() -> Balloons & { return balloons_; }
|
auto getBalloons() -> Balloons& { return balloons_; }
|
||||||
[[nodiscard]] auto getNumBalloons() const -> int { return balloons_.size(); }
|
[[nodiscard]] auto getNumBalloons() const -> int { return balloons_.size(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// --- Constantes ---
|
// --- Constantes ---
|
||||||
static const int DEFAULT_BALLOON_DEPLOY_COUNTER = 300;
|
static constexpr float DEFAULT_BALLOON_DEPLOY_DELAY = 5.0F; // 300 frames = 5 segundos
|
||||||
|
static constexpr float POWERBALL_DEPLOY_DELAY = 0.167F; // 10 frames = 0.167 segundos
|
||||||
|
static constexpr float BALLOON_POP_DELAY = 0.333F; // 20 frames = 0.333 segundos
|
||||||
|
|
||||||
// --- Objetos y punteros ---
|
// --- Objetos y punteros ---
|
||||||
Balloons balloons_; // Vector con los globos activos
|
Balloons balloons_; // Vector con los globos activos
|
||||||
@@ -93,13 +94,13 @@ class BalloonManager {
|
|||||||
std::vector<std::shared_ptr<Texture>> explosions_textures_; // Texturas de explosiones
|
std::vector<std::shared_ptr<Texture>> explosions_textures_; // Texturas de explosiones
|
||||||
std::vector<std::vector<std::string>> balloon_animations_; // Animaciones de los globos
|
std::vector<std::vector<std::string>> balloon_animations_; // Animaciones de los globos
|
||||||
std::vector<std::vector<std::string>> explosions_animations_; // Animaciones de las explosiones
|
std::vector<std::vector<std::string>> explosions_animations_; // Animaciones de las explosiones
|
||||||
IStageInfo *stage_info_; // Informacion de la pantalla actual
|
IStageInfo* stage_info_; // Informacion de la pantalla actual
|
||||||
|
|
||||||
// --- Variables de estado ---
|
// --- Variables de estado ---
|
||||||
SDL_FRect play_area_ = param.game.play_area.rect;
|
SDL_FRect play_area_ = param.game.play_area.rect;
|
||||||
float balloon_speed_ = Balloon::SPEED.at(0);
|
float balloon_speed_ = Balloon::GAME_TEMPO.at(0);
|
||||||
float default_balloon_speed_ = Balloon::SPEED.at(0);
|
float default_balloon_speed_ = Balloon::GAME_TEMPO.at(0);
|
||||||
int balloon_deploy_counter_ = 0;
|
float balloon_deploy_counter_ = 0;
|
||||||
int power_ball_counter_ = 0;
|
int power_ball_counter_ = 0;
|
||||||
int last_balloon_deploy_ = 0;
|
int last_balloon_deploy_ = 0;
|
||||||
bool power_ball_enabled_ = false;
|
bool power_ball_enabled_ = false;
|
||||||
@@ -1,49 +1,66 @@
|
|||||||
#include "bullet.h"
|
#include "bullet.hpp"
|
||||||
|
|
||||||
#include <memory> // Para allocator, unique_ptr, make_unique
|
#include <memory> // Para unique_ptr, make_unique
|
||||||
#include <string> // Para char_traits, basic_string, operator+, string
|
#include <string> // Para basic_string, string
|
||||||
|
|
||||||
#include "param.h" // Para Param, ParamGame, param
|
#include "param.hpp" // Para Param, ParamGame, param
|
||||||
#include "resource.h" // Para Resource
|
#include "resource.hpp" // Para Resource
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Bullet::Bullet(float x, float y, BulletType bullet_type, bool powered, Player::Id owner)
|
Bullet::Bullet(float x, float y, Type type, Color color, int owner)
|
||||||
: sprite_(std::make_unique<AnimatedSprite>(Resource::get()->getTexture("bullet.png"), Resource::get()->getAnimation("bullet.ani"))),
|
: sprite_(std::make_unique<AnimatedSprite>(Resource::get()->getTexture("bullet.png"), Resource::get()->getAnimation("bullet.ani"))),
|
||||||
bullet_type_(bullet_type),
|
type_(type),
|
||||||
owner_(owner),
|
owner_(owner),
|
||||||
pos_x_(x),
|
pos_x_(x),
|
||||||
pos_y_(y) {
|
pos_y_(y) {
|
||||||
vel_x_ = calculateVelocity(bullet_type_);
|
vel_x_ = calculateVelocity(type_);
|
||||||
sprite_->setCurrentAnimation(buildAnimationString(bullet_type_, powered));
|
sprite_->setCurrentAnimation(buildAnimationString(type_, color));
|
||||||
|
|
||||||
collider_.r = WIDTH / 2;
|
collider_.r = WIDTH / 2;
|
||||||
shiftColliders();
|
shiftColliders();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calcula la velocidad horizontal de la bala basada en su tipo
|
// Calcula la velocidad horizontal de la bala basada en su tipo
|
||||||
auto Bullet::calculateVelocity(BulletType bullet_type) -> float {
|
auto Bullet::calculateVelocity(Type type) -> float {
|
||||||
switch (bullet_type) {
|
switch (type) {
|
||||||
case BulletType::LEFT:
|
case Type::LEFT:
|
||||||
return VEL_X_LEFT;
|
return VEL_X_LEFT;
|
||||||
case BulletType::RIGHT:
|
case Type::RIGHT:
|
||||||
return VEL_X_RIGHT;
|
return VEL_X_RIGHT;
|
||||||
default:
|
default:
|
||||||
return VEL_X_CENTER;
|
return VEL_X_CENTER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construye el string de animación basado en el tipo de bala y si está potenciada
|
// Construye el string de animación basado en el tipo de bala y color específico
|
||||||
auto Bullet::buildAnimationString(BulletType bullet_type, bool powered) -> std::string {
|
auto Bullet::buildAnimationString(Type type, Color color) -> std::string {
|
||||||
std::string animation_string = powered ? "powered_" : "normal_";
|
std::string animation_string;
|
||||||
|
|
||||||
switch (bullet_type) {
|
// Mapear color a string específico
|
||||||
case BulletType::UP:
|
switch (color) {
|
||||||
|
case Color::YELLOW:
|
||||||
|
animation_string = "yellow_";
|
||||||
|
break;
|
||||||
|
case Color::GREEN:
|
||||||
|
animation_string = "green_";
|
||||||
|
break;
|
||||||
|
case Color::RED:
|
||||||
|
animation_string = "red_";
|
||||||
|
break;
|
||||||
|
case Color::PURPLE:
|
||||||
|
animation_string = "purple_";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Añadir dirección
|
||||||
|
switch (type) {
|
||||||
|
case Type::UP:
|
||||||
animation_string += "up";
|
animation_string += "up";
|
||||||
break;
|
break;
|
||||||
case BulletType::LEFT:
|
case Type::LEFT:
|
||||||
animation_string += "left";
|
animation_string += "left";
|
||||||
break;
|
break;
|
||||||
case BulletType::RIGHT:
|
case Type::RIGHT:
|
||||||
animation_string += "right";
|
animation_string += "right";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -53,48 +70,48 @@ auto Bullet::buildAnimationString(BulletType bullet_type, bool powered) -> std::
|
|||||||
return animation_string;
|
return animation_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implementación de render (llama al render del sprite_)
|
// Implementación de render
|
||||||
void Bullet::render() {
|
void Bullet::render() {
|
||||||
if (bullet_type_ != BulletType::NONE) {
|
if (type_ != Type::NONE) {
|
||||||
sprite_->render();
|
sprite_->render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el estado del objeto
|
// Actualiza el estado del objeto
|
||||||
auto Bullet::update() -> BulletMoveStatus {
|
auto Bullet::update(float delta_time) -> MoveStatus {
|
||||||
sprite_->update();
|
sprite_->update(delta_time);
|
||||||
return move();
|
return move(delta_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implementación del movimiento usando BulletMoveStatus
|
// Implementación del movimiento usando MoveStatus
|
||||||
auto Bullet::move() -> BulletMoveStatus {
|
auto Bullet::move(float delta_time) -> MoveStatus {
|
||||||
pos_x_ += vel_x_;
|
pos_x_ += vel_x_ * delta_time;
|
||||||
if (pos_x_ < param.game.play_area.rect.x - WIDTH || pos_x_ > param.game.play_area.rect.w) {
|
if (pos_x_ < param.game.play_area.rect.x - WIDTH || pos_x_ > param.game.play_area.rect.w) {
|
||||||
disable();
|
disable();
|
||||||
return BulletMoveStatus::OUT;
|
return MoveStatus::OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos_y_ += VEL_Y;
|
pos_y_ += VEL_Y * delta_time;
|
||||||
if (pos_y_ < param.game.play_area.rect.y - HEIGHT) {
|
if (pos_y_ < param.game.play_area.rect.y - HEIGHT) {
|
||||||
disable();
|
disable();
|
||||||
return BulletMoveStatus::OUT;
|
return MoveStatus::OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
shiftSprite();
|
shiftSprite();
|
||||||
shiftColliders();
|
shiftColliders();
|
||||||
|
|
||||||
return BulletMoveStatus::OK;
|
return MoveStatus::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Bullet::isEnabled() const -> bool {
|
auto Bullet::isEnabled() const -> bool {
|
||||||
return bullet_type_ != BulletType::NONE;
|
return type_ != Type::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bullet::disable() {
|
void Bullet::disable() {
|
||||||
bullet_type_ = BulletType::NONE;
|
type_ = Type::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Bullet::getOwner() const -> Player::Id {
|
auto Bullet::getOwner() const -> int {
|
||||||
return owner_;
|
return owner_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <SDL3/SDL.h> // Para Uint8
|
|
||||||
|
|
||||||
#include <memory> // Para unique_ptr
|
|
||||||
#include <string> // Para string
|
|
||||||
|
|
||||||
#include "animated_sprite.h" // Para AnimatedSprite
|
|
||||||
#include "player.h" // Para Player
|
|
||||||
#include "utils.h" // Para Circle
|
|
||||||
|
|
||||||
// --- Enums ---
|
|
||||||
enum class BulletType : Uint8 {
|
|
||||||
UP, // Bala hacia arriba
|
|
||||||
LEFT, // Bala hacia la izquierda
|
|
||||||
RIGHT, // Bala hacia la derecha
|
|
||||||
NONE // Sin bala
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class BulletMoveStatus : Uint8 {
|
|
||||||
OK = 0, // Movimiento normal
|
|
||||||
OUT = 1 // Fuera de los límites
|
|
||||||
};
|
|
||||||
|
|
||||||
// --- Clase Bullet: representa una bala del jugador ---
|
|
||||||
class Bullet {
|
|
||||||
public:
|
|
||||||
// --- Constantes ---
|
|
||||||
static constexpr float WIDTH = 12.0F; // Anchura de la bala
|
|
||||||
static constexpr float HEIGHT = 12.0F; // Altura de la bala
|
|
||||||
|
|
||||||
// --- Constructor y destructor ---
|
|
||||||
Bullet(float x, float y, BulletType bullet_type, bool powered, Player::Id owner); // Constructor principal
|
|
||||||
~Bullet() = default; // Destructor
|
|
||||||
|
|
||||||
// --- Métodos principales ---
|
|
||||||
void render(); // Dibuja la bala en pantalla
|
|
||||||
auto update() -> BulletMoveStatus; // Actualiza el estado del objeto
|
|
||||||
void disable(); // Desactiva la bala
|
|
||||||
|
|
||||||
// --- Getters ---
|
|
||||||
[[nodiscard]] auto isEnabled() const -> bool; // Comprueba si está activa
|
|
||||||
[[nodiscard]] auto getOwner() const -> Player::Id; // Devuelve el identificador del dueño
|
|
||||||
auto getCollider() -> Circle &; // Devuelve el círculo de colisión
|
|
||||||
|
|
||||||
private:
|
|
||||||
// --- Constantes ---
|
|
||||||
static constexpr float VEL_Y = -3.0F; // Velocidad vertical
|
|
||||||
static constexpr float VEL_X_LEFT = -2.0F; // Velocidad izquierda
|
|
||||||
static constexpr float VEL_X_RIGHT = 2.0F; // Velocidad derecha
|
|
||||||
static constexpr float VEL_X_CENTER = 0.0F; // Velocidad central
|
|
||||||
|
|
||||||
// --- Objetos y punteros ---
|
|
||||||
std::unique_ptr<AnimatedSprite> sprite_; // Sprite con los gráficos
|
|
||||||
|
|
||||||
// --- Variables de estado ---
|
|
||||||
Circle collider_; // Círculo de colisión
|
|
||||||
BulletType bullet_type_; // Tipo de bala
|
|
||||||
Player::Id owner_; // Identificador del dueño
|
|
||||||
float pos_x_; // Posición en el eje X
|
|
||||||
float pos_y_; // Posición en el eje Y
|
|
||||||
float vel_x_; // Velocidad en el eje X
|
|
||||||
|
|
||||||
// --- Métodos internos ---
|
|
||||||
void shiftColliders(); // Ajusta el círculo de colisión
|
|
||||||
void shiftSprite(); // Ajusta el sprite
|
|
||||||
auto move() -> BulletMoveStatus; // Mueve la bala y devuelve su estado
|
|
||||||
static auto calculateVelocity(BulletType bullet_type) -> float; // Calcula la velocidad horizontal de la bala
|
|
||||||
static auto buildAnimationString(BulletType bullet_type, bool powered) -> std::string; // Construye el string de animación
|
|
||||||
};
|
|
||||||
76
source/bullet.hpp
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <SDL3/SDL.h> // Para Uint8
|
||||||
|
|
||||||
|
#include <memory> // Para unique_ptr
|
||||||
|
#include <string> // Para string
|
||||||
|
|
||||||
|
#include "animated_sprite.hpp" // Para AnimatedSprite
|
||||||
|
#include "utils.hpp" // Para Circle
|
||||||
|
|
||||||
|
// --- Clase Bullet: representa una bala del jugador ---
|
||||||
|
class Bullet {
|
||||||
|
public:
|
||||||
|
// --- Constantes ---
|
||||||
|
static constexpr float WIDTH = 12.0F; // Anchura de la bala
|
||||||
|
static constexpr float HEIGHT = 12.0F; // Altura de la bala
|
||||||
|
|
||||||
|
// --- Enums ---
|
||||||
|
enum class Type : Uint8 {
|
||||||
|
UP, // Bala hacia arriba
|
||||||
|
LEFT, // Bala hacia la izquierda
|
||||||
|
RIGHT, // Bala hacia la derecha
|
||||||
|
NONE // Sin bala
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class MoveStatus : Uint8 {
|
||||||
|
OK = 0, // Movimiento normal
|
||||||
|
OUT = 1 // Fuera de los límites
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class Color : Uint8 {
|
||||||
|
YELLOW,
|
||||||
|
GREEN,
|
||||||
|
RED,
|
||||||
|
PURPLE
|
||||||
|
};
|
||||||
|
|
||||||
|
// --- Constructor y destructor ---
|
||||||
|
Bullet(float x, float y, Type type, Color color, int owner); // Constructor principal
|
||||||
|
~Bullet() = default; // Destructor
|
||||||
|
|
||||||
|
// --- Métodos principales ---
|
||||||
|
void render(); // Dibuja la bala en pantalla
|
||||||
|
auto update(float delta_time) -> MoveStatus; // Actualiza el estado del objeto (time-based)
|
||||||
|
void disable(); // Desactiva la bala
|
||||||
|
|
||||||
|
// --- Getters ---
|
||||||
|
[[nodiscard]] auto isEnabled() const -> bool; // Comprueba si está activa
|
||||||
|
[[nodiscard]] auto getOwner() const -> int; // Devuelve el identificador del dueño
|
||||||
|
auto getCollider() -> Circle&; // Devuelve el círculo de colisión
|
||||||
|
|
||||||
|
private:
|
||||||
|
// --- Constantes ---
|
||||||
|
static constexpr float VEL_Y = -180.0F; // Velocidad vertical (pixels/segundo) - era -0.18F pixels/ms
|
||||||
|
static constexpr float VEL_X_LEFT = -120.0F; // Velocidad izquierda (pixels/segundo) - era -0.12F pixels/ms
|
||||||
|
static constexpr float VEL_X_RIGHT = 120.0F; // Velocidad derecha (pixels/segundo) - era 0.12F pixels/ms
|
||||||
|
static constexpr float VEL_X_CENTER = 0.0F; // Velocidad central
|
||||||
|
|
||||||
|
// --- Objetos y punteros ---
|
||||||
|
std::unique_ptr<AnimatedSprite> sprite_; // Sprite con los gráficos
|
||||||
|
|
||||||
|
// --- Variables de estado ---
|
||||||
|
Circle collider_; // Círculo de colisión
|
||||||
|
Type type_; // Tipo de bala
|
||||||
|
int owner_; // Identificador del jugador
|
||||||
|
float pos_x_; // Posición en el eje X
|
||||||
|
float pos_y_; // Posición en el eje Y
|
||||||
|
float vel_x_; // Velocidad en el eje X
|
||||||
|
|
||||||
|
// --- Métodos internos ---
|
||||||
|
void shiftColliders(); // Ajusta el círculo de colisión
|
||||||
|
void shiftSprite(); // Ajusta el sprite
|
||||||
|
auto move(float delta_time) -> MoveStatus; // Mueve la bala y devuelve su estado (time-based)
|
||||||
|
static auto calculateVelocity(Type type) -> float; // Calcula la velocidad horizontal de la bala
|
||||||
|
static auto buildAnimationString(Type type, Color color) -> std::string; // Construye el string de animación
|
||||||
|
};
|
||||||
104
source/bullet_manager.cpp
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
#include "bullet_manager.hpp"
|
||||||
|
|
||||||
|
#include <algorithm> // Para remove_if
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include "bullet.hpp" // Para Bullet
|
||||||
|
#include "param.hpp" // Para Param, ParamGame, param
|
||||||
|
#include "utils.hpp" // Para Circle, Zone
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
BulletManager::BulletManager()
|
||||||
|
: play_area_(param.game.play_area.rect) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualiza el estado de todas las balas
|
||||||
|
void BulletManager::update(float delta_time) {
|
||||||
|
for (auto& bullet : bullets_) {
|
||||||
|
if (bullet->isEnabled()) {
|
||||||
|
processBulletUpdate(bullet, delta_time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Renderiza todas las balas activas
|
||||||
|
void BulletManager::render() {
|
||||||
|
for (auto& bullet : bullets_) {
|
||||||
|
if (bullet->isEnabled()) {
|
||||||
|
bullet->render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crea una nueva bala
|
||||||
|
void BulletManager::createBullet(int x, int y, Bullet::Type type, Bullet::Color color, int owner) {
|
||||||
|
bullets_.emplace_back(std::make_shared<Bullet>(x, y, type, color, owner));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Libera balas que ya no están habilitadas
|
||||||
|
void BulletManager::freeBullets() {
|
||||||
|
std::erase_if(bullets_, [](const std::shared_ptr<Bullet>& bullet) {
|
||||||
|
return !bullet->isEnabled();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Elimina todas las balas
|
||||||
|
void BulletManager::clearAllBullets() {
|
||||||
|
bullets_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verifica colisiones de todas las balas
|
||||||
|
void BulletManager::checkCollisions() {
|
||||||
|
for (auto& bullet : bullets_) {
|
||||||
|
if (!bullet->isEnabled()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verifica colisión con Tabe
|
||||||
|
if (tabe_collision_callback_ && tabe_collision_callback_(bullet)) {
|
||||||
|
break; // Sale del bucle si hubo colisión
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verifica colisión con globos
|
||||||
|
if (balloon_collision_callback_ && balloon_collision_callback_(bullet)) {
|
||||||
|
break; // Sale del bucle si hubo colisión
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Establece el callback para colisión con Tabe
|
||||||
|
void BulletManager::setTabeCollisionCallback(CollisionCallback callback) {
|
||||||
|
tabe_collision_callback_ = std::move(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Establece el callback para colisión con globos
|
||||||
|
void BulletManager::setBalloonCollisionCallback(CollisionCallback callback) {
|
||||||
|
balloon_collision_callback_ = std::move(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Establece el callback para balas fuera de límites
|
||||||
|
void BulletManager::setOutOfBoundsCallback(OutOfBoundsCallback callback) {
|
||||||
|
out_of_bounds_callback_ = std::move(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Métodos privados ---
|
||||||
|
|
||||||
|
// Procesa la actualización individual de una bala
|
||||||
|
void BulletManager::processBulletUpdate(const std::shared_ptr<Bullet>& bullet, float delta_time) {
|
||||||
|
auto status = bullet->update(delta_time);
|
||||||
|
|
||||||
|
// Si la bala salió de los límites, llama al callback
|
||||||
|
if (status == Bullet::MoveStatus::OUT && out_of_bounds_callback_) {
|
||||||
|
out_of_bounds_callback_(bullet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verifica si la bala está fuera de los límites del área de juego
|
||||||
|
auto BulletManager::isBulletOutOfBounds(const std::shared_ptr<Bullet>& bullet) const -> bool {
|
||||||
|
auto collider = bullet->getCollider();
|
||||||
|
|
||||||
|
return (collider.x < play_area_.x ||
|
||||||
|
collider.x > play_area_.x + play_area_.w ||
|
||||||
|
collider.y < play_area_.y ||
|
||||||
|
collider.y > play_area_.y + play_area_.h);
|
||||||
|
}
|
||||||
76
source/bullet_manager.hpp
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <SDL3/SDL.h> // Para SDL_FRect
|
||||||
|
|
||||||
|
#include <functional> // Para function
|
||||||
|
#include <list> // Para list
|
||||||
|
#include <memory> // Para shared_ptr
|
||||||
|
#include <vector> // Para vector
|
||||||
|
|
||||||
|
#include "bullet.hpp" // for Bullet
|
||||||
|
|
||||||
|
// --- Types ---
|
||||||
|
using Bullets = std::list<std::shared_ptr<Bullet>>;
|
||||||
|
|
||||||
|
// --- Clase BulletManager: gestiona todas las balas del juego ---
|
||||||
|
//
|
||||||
|
// Esta clase se encarga de la gestión completa de las balas del juego,
|
||||||
|
// incluyendo su creación, actualización, renderizado y colisiones.
|
||||||
|
//
|
||||||
|
// Funcionalidades principales:
|
||||||
|
// • Gestión del ciclo de vida: creación, actualización y destrucción de balas
|
||||||
|
// • Renderizado: dibuja todas las balas activas en pantalla
|
||||||
|
// • Detección de colisiones: mediante sistema de callbacks
|
||||||
|
// • Limpieza automática: elimina balas deshabilitadas del contenedor
|
||||||
|
// • Configuración flexible: permite ajustar parámetros de las balas
|
||||||
|
//
|
||||||
|
// La clase utiliza un sistema de callbacks para manejar las colisiones,
|
||||||
|
// permitiendo que la lógica específica del juego permanezca en Game.
|
||||||
|
class BulletManager {
|
||||||
|
public:
|
||||||
|
// --- Types para callbacks ---
|
||||||
|
using CollisionCallback = std::function<bool(const std::shared_ptr<Bullet>&)>;
|
||||||
|
using OutOfBoundsCallback = std::function<void(const std::shared_ptr<Bullet>&)>;
|
||||||
|
|
||||||
|
// --- Constructor y destructor ---
|
||||||
|
BulletManager();
|
||||||
|
~BulletManager() = default;
|
||||||
|
|
||||||
|
// --- Métodos principales ---
|
||||||
|
void update(float delta_time); // Actualiza el estado de las balas (time-based)
|
||||||
|
void render(); // Renderiza las balas en pantalla
|
||||||
|
|
||||||
|
// --- Gestión de balas ---
|
||||||
|
void createBullet(int x, int y, Bullet::Type type, Bullet::Color color, int owner); // Crea una nueva bala
|
||||||
|
void freeBullets(); // Libera balas que ya no sirven
|
||||||
|
void clearAllBullets(); // Elimina todas las balas
|
||||||
|
|
||||||
|
// --- Detección de colisiones ---
|
||||||
|
void checkCollisions(); // Verifica colisiones de todas las balas
|
||||||
|
void setTabeCollisionCallback(CollisionCallback callback); // Establece callback para colisión con Tabe
|
||||||
|
void setBalloonCollisionCallback(CollisionCallback callback); // Establece callback para colisión con globos
|
||||||
|
void setOutOfBoundsCallback(OutOfBoundsCallback callback); // Establece callback para balas fuera de límites
|
||||||
|
|
||||||
|
// --- Configuración ---
|
||||||
|
void setPlayArea(SDL_FRect play_area) { play_area_ = play_area; }; // Define el área de juego
|
||||||
|
|
||||||
|
// --- Getters ---
|
||||||
|
auto getBullets() -> Bullets& { return bullets_; } // Obtiene referencia al vector de balas
|
||||||
|
[[nodiscard]] auto getNumBullets() const -> int { return bullets_.size(); } // Obtiene el número de balas activas
|
||||||
|
|
||||||
|
private:
|
||||||
|
// --- Objetos y punteros ---
|
||||||
|
Bullets bullets_; // Vector con las balas activas
|
||||||
|
|
||||||
|
// --- Variables de configuración ---
|
||||||
|
SDL_FRect play_area_; // Área de juego para límites
|
||||||
|
|
||||||
|
// --- Callbacks para colisiones ---
|
||||||
|
CollisionCallback tabe_collision_callback_; // Callback para colisión con Tabe
|
||||||
|
CollisionCallback balloon_collision_callback_; // Callback para colisión con globos
|
||||||
|
OutOfBoundsCallback out_of_bounds_callback_; // Callback para balas fuera de límites
|
||||||
|
|
||||||
|
// --- Métodos internos ---
|
||||||
|
void processBulletUpdate(const std::shared_ptr<Bullet>& bullet, float delta_time); // Procesa actualización individual
|
||||||
|
[[nodiscard]] auto isBulletOutOfBounds(const std::shared_ptr<Bullet>& bullet) const -> bool; // Verifica si la bala está fuera de límites
|
||||||
|
};
|
||||||
118
source/color.cpp
@@ -1,5 +1,5 @@
|
|||||||
#define _USE_MATH_DEFINES
|
#define _USE_MATH_DEFINES
|
||||||
#include "color.h"
|
#include "color.hpp"
|
||||||
|
|
||||||
#include <cctype> // Para isxdigit
|
#include <cctype> // Para isxdigit
|
||||||
#include <cmath> // Para sinf, fmaxf, fminf, M_PI, fmodf, roundf, fmod
|
#include <cmath> // Para sinf, fmaxf, fminf, M_PI, fmodf, roundf, fmod
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <string> // Para basic_string, stoi, string
|
#include <string> // Para basic_string, stoi, string
|
||||||
|
|
||||||
// Método estático para crear Color desde string hexadecimal
|
// Método estático para crear Color desde string hexadecimal
|
||||||
auto Color::fromHex(const std::string &hex_str) -> Color {
|
auto Color::fromHex(const std::string& hex_str) -> Color {
|
||||||
std::string hex = hex_str;
|
std::string hex = hex_str;
|
||||||
|
|
||||||
// Quitar '#' si existe
|
// Quitar '#' si existe
|
||||||
@@ -43,7 +43,7 @@ auto Color::fromHex(const std::string &hex_str) -> Color {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Implementaciones de métodos estáticos de Color
|
// Implementaciones de métodos estáticos de Color
|
||||||
constexpr auto Color::rgbToHsv(Color color) -> HSV {
|
constexpr auto Color::RGB_TO_HSV(Color color) -> HSV {
|
||||||
float r = color.r / 255.0F;
|
float r = color.r / 255.0F;
|
||||||
float g = color.g / 255.0F;
|
float g = color.g / 255.0F;
|
||||||
float b = color.b / 255.0F;
|
float b = color.b / 255.0F;
|
||||||
@@ -73,7 +73,7 @@ constexpr auto Color::rgbToHsv(Color color) -> HSV {
|
|||||||
return {.h = h, .s = s, .v = v};
|
return {.h = h, .s = s, .v = v};
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto Color::hsvToRgb(HSV hsv) -> Color {
|
constexpr auto Color::HSV_TO_RGB(HSV hsv) -> Color {
|
||||||
float c = hsv.v * hsv.s;
|
float c = hsv.v * hsv.s;
|
||||||
float x = c * (1 - std::abs(std::fmod(hsv.h / 60.0F, 2) - 1));
|
float x = c * (1 - std::abs(std::fmod(hsv.h / 60.0F, 2) - 1));
|
||||||
float m = hsv.v - c;
|
float m = hsv.v - c;
|
||||||
@@ -116,71 +116,71 @@ constexpr auto Color::hsvToRgb(HSV hsv) -> Color {
|
|||||||
|
|
||||||
// Implementaciones del namespace Colors
|
// Implementaciones del namespace Colors
|
||||||
namespace Colors {
|
namespace Colors {
|
||||||
// Obtiene un color del vector de colores imitando al Coche Fantástico
|
// Obtiene un color del vector de colores imitando al Coche Fantástico
|
||||||
auto getColorLikeKnightRider(const std::vector<Color> &colors, int counter) -> Color {
|
auto getColorLikeKnightRider(const std::vector<Color>& colors, int counter) -> Color {
|
||||||
int cycle_length = (colors.size() * 2) - 2;
|
int cycle_length = (colors.size() * 2) - 2;
|
||||||
size_t n = counter % cycle_length;
|
size_t n = counter % cycle_length;
|
||||||
|
|
||||||
size_t index;
|
size_t index;
|
||||||
if (n < colors.size()) {
|
if (n < colors.size()) {
|
||||||
index = n; // Avanza: 0,1,2,3
|
index = n; // Avanza: 0,1,2,3
|
||||||
} else {
|
} else {
|
||||||
index = 2 * (colors.size() - 1) - n; // Retrocede: 2,1
|
index = 2 * (colors.size() - 1) - n; // Retrocede: 2,1
|
||||||
}
|
|
||||||
|
|
||||||
return colors[index];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto generateMirroredCycle(Color base, ColorCycleStyle style) -> Cycle {
|
return colors[index];
|
||||||
Cycle result{};
|
}
|
||||||
HSV base_hsv = Color::rgbToHsv(base);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < CYCLE_SIZE; ++i) {
|
auto generateMirroredCycle(Color base, ColorCycleStyle style) -> Cycle {
|
||||||
float t = static_cast<float>(i) / (CYCLE_SIZE - 1); // 0 → 1
|
Cycle result{};
|
||||||
float hue_shift = 0.0F;
|
HSV base_hsv = Color::RGB_TO_HSV(base);
|
||||||
float sat_shift = 0.0F;
|
|
||||||
float val_shift = 0.0F;
|
|
||||||
|
|
||||||
switch (style) {
|
for (size_t i = 0; i < CYCLE_SIZE; ++i) {
|
||||||
case ColorCycleStyle::SUBTLE_PULSE:
|
float t = static_cast<float>(i) / (CYCLE_SIZE - 1); // 0 → 1
|
||||||
// Solo brillo suave
|
float hue_shift = 0.0F;
|
||||||
val_shift = 0.07F * sinf(t * M_PI);
|
float sat_shift = 0.0F;
|
||||||
break;
|
float val_shift = 0.0F;
|
||||||
|
|
||||||
case ColorCycleStyle::HUE_WAVE:
|
switch (style) {
|
||||||
// Oscilación leve de tono
|
case ColorCycleStyle::SUBTLE_PULSE:
|
||||||
hue_shift = 15.0F * (t - 0.5F) * 2.0F;
|
// Solo brillo suave
|
||||||
val_shift = 0.05F * sinf(t * M_PI);
|
val_shift = 0.07F * sinf(t * M_PI);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ColorCycleStyle::VIBRANT:
|
case ColorCycleStyle::HUE_WAVE:
|
||||||
// Cambios fuertes en tono y brillo
|
// Oscilación leve de tono
|
||||||
hue_shift = 35.0F * sinf(t * M_PI);
|
hue_shift = 15.0F * (t - 0.5F) * 2.0F;
|
||||||
val_shift = 0.2F * sinf(t * M_PI);
|
val_shift = 0.05F * sinf(t * M_PI);
|
||||||
sat_shift = -0.2F * sinf(t * M_PI);
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case ColorCycleStyle::DARKEN_GLOW:
|
case ColorCycleStyle::VIBRANT:
|
||||||
// Se oscurece al centro
|
// Cambios fuertes en tono y brillo
|
||||||
val_shift = -0.15F * sinf(t * M_PI);
|
hue_shift = 35.0F * sinf(t * M_PI);
|
||||||
break;
|
val_shift = 0.2F * sinf(t * M_PI);
|
||||||
|
sat_shift = -0.2F * sinf(t * M_PI);
|
||||||
|
break;
|
||||||
|
|
||||||
case ColorCycleStyle::LIGHT_FLASH:
|
case ColorCycleStyle::DARKEN_GLOW:
|
||||||
// Se ilumina al centro
|
// Se oscurece al centro
|
||||||
val_shift = 0.25F * sinf(t * M_PI);
|
val_shift = -0.15F * sinf(t * M_PI);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
HSV adjusted = {
|
case ColorCycleStyle::LIGHT_FLASH:
|
||||||
.h = fmodf(base_hsv.h + hue_shift + 360.0F, 360.0F),
|
// Se ilumina al centro
|
||||||
.s = fminf(1.0F, fmaxf(0.0F, base_hsv.s + sat_shift)),
|
val_shift = 0.25F * sinf(t * M_PI);
|
||||||
.v = fminf(1.0F, fmaxf(0.0F, base_hsv.v + val_shift))};
|
break;
|
||||||
|
|
||||||
Color c = Color::hsvToRgb(adjusted);
|
|
||||||
result[i] = c;
|
|
||||||
result[(2 * CYCLE_SIZE) - 1 - i] = c; // espejo
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
HSV adjusted = {
|
||||||
|
.h = fmodf(base_hsv.h + hue_shift + 360.0F, 360.0F),
|
||||||
|
.s = fminf(1.0F, fmaxf(0.0F, base_hsv.s + sat_shift)),
|
||||||
|
.v = fminf(1.0F, fmaxf(0.0F, base_hsv.v + val_shift))};
|
||||||
|
|
||||||
|
Color c = Color::HSV_TO_RGB(adjusted);
|
||||||
|
result[i] = c;
|
||||||
|
result[(2 * CYCLE_SIZE) - 1 - i] = c; // espejo
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
} // namespace Colors
|
||||||
@@ -36,10 +36,17 @@ struct Color {
|
|||||||
|
|
||||||
Uint8 r, g, b, a;
|
Uint8 r, g, b, a;
|
||||||
|
|
||||||
constexpr Color() : r(MIN_COLOR_VALUE), g(MIN_COLOR_VALUE), b(MIN_COLOR_VALUE), a(DEFAULT_ALPHA) {}
|
constexpr Color()
|
||||||
|
: r(MIN_COLOR_VALUE),
|
||||||
|
g(MIN_COLOR_VALUE),
|
||||||
|
b(MIN_COLOR_VALUE),
|
||||||
|
a(DEFAULT_ALPHA) {}
|
||||||
|
|
||||||
explicit constexpr Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha = DEFAULT_ALPHA)
|
explicit constexpr Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha = DEFAULT_ALPHA)
|
||||||
: r(red), g(green), b(blue), a(alpha) {}
|
: r(red),
|
||||||
|
g(green),
|
||||||
|
b(blue),
|
||||||
|
a(alpha) {}
|
||||||
|
|
||||||
[[nodiscard]] constexpr auto INVERSE() const -> Color {
|
[[nodiscard]] constexpr auto INVERSE() const -> Color {
|
||||||
return Color(MAX_COLOR_VALUE - r, MAX_COLOR_VALUE - g, MAX_COLOR_VALUE - b, a);
|
return Color(MAX_COLOR_VALUE - r, MAX_COLOR_VALUE - g, MAX_COLOR_VALUE - b, a);
|
||||||
@@ -62,17 +69,17 @@ struct Color {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Método estático para crear Color desde string hexadecimal
|
// Método estático para crear Color desde string hexadecimal
|
||||||
static auto fromHex(const std::string &hex_str) -> Color;
|
static auto fromHex(const std::string& hex_str) -> Color;
|
||||||
|
|
||||||
// Conversiones de formato de color
|
// Conversiones de formato de color
|
||||||
[[nodiscard]] constexpr static auto rgbToHsv(Color color) -> HSV;
|
[[nodiscard]] constexpr static auto RGB_TO_HSV(Color color) -> HSV;
|
||||||
[[nodiscard]] constexpr static auto hsvToRgb(HSV hsv) -> Color;
|
[[nodiscard]] constexpr static auto HSV_TO_RGB(HSV hsv) -> Color;
|
||||||
|
|
||||||
[[nodiscard]] constexpr auto IS_EQUAL_TO(const Color &other) const -> bool {
|
[[nodiscard]] constexpr auto IS_EQUAL_TO(const Color& other) const -> bool {
|
||||||
return r == other.r && g == other.g && b == other.b && a == other.a;
|
return r == other.r && g == other.g && b == other.b && a == other.a;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] constexpr auto APPROACH_TO(const Color &target, int step = DEFAULT_APPROACH_STEP) const -> Color {
|
[[nodiscard]] constexpr auto APPROACH_TO(const Color& target, int step = DEFAULT_APPROACH_STEP) const -> Color {
|
||||||
auto approach_component = [step](Uint8 current, Uint8 target_val) -> Uint8 {
|
auto approach_component = [step](Uint8 current, Uint8 target_val) -> Uint8 {
|
||||||
if (std::abs(current - target_val) <= step) {
|
if (std::abs(current - target_val) <= step) {
|
||||||
return target_val;
|
return target_val;
|
||||||
@@ -88,6 +95,28 @@ struct Color {
|
|||||||
return Color(new_r, new_g, new_b, new_a);
|
return Color(new_r, new_g, new_b, new_a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Interpolación lineal hacia otro color (t=0.0: this, t=1.0: target)
|
||||||
|
[[nodiscard]] constexpr auto LERP(const Color& target, float t) const -> Color {
|
||||||
|
// Asegurar que t esté en el rango [0.0, 1.0]
|
||||||
|
t = std::clamp(t, 0.0F, 1.0F);
|
||||||
|
|
||||||
|
// Interpolación lineal para cada componente
|
||||||
|
auto lerp_component = [t](Uint8 start, Uint8 end) -> Uint8 {
|
||||||
|
return static_cast<Uint8>(start + ((end - start) * t));
|
||||||
|
};
|
||||||
|
|
||||||
|
return Color(
|
||||||
|
lerp_component(r, target.r),
|
||||||
|
lerp_component(g, target.g),
|
||||||
|
lerp_component(b, target.b),
|
||||||
|
lerp_component(a, target.a));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sobrecarga para aceptar componentes RGBA directamente
|
||||||
|
[[nodiscard]] constexpr auto LERP(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha, float t) const -> Color {
|
||||||
|
return LERP(Color(red, green, blue, alpha), t);
|
||||||
|
}
|
||||||
|
|
||||||
// Convierte el color a un entero de 32 bits en formato RGBA
|
// Convierte el color a un entero de 32 bits en formato RGBA
|
||||||
[[nodiscard]] constexpr auto TO_UINT32() const -> Uint32 {
|
[[nodiscard]] constexpr auto TO_UINT32() const -> Uint32 {
|
||||||
return (static_cast<Uint32>(r) << 24) |
|
return (static_cast<Uint32>(r) << 24) |
|
||||||
@@ -108,25 +137,25 @@ enum class ColorCycleStyle {
|
|||||||
|
|
||||||
// --- Namespace Colors: constantes y utilidades de color ---
|
// --- Namespace Colors: constantes y utilidades de color ---
|
||||||
namespace Colors {
|
namespace Colors {
|
||||||
// --- Constantes ---
|
// --- Constantes ---
|
||||||
constexpr size_t CYCLE_SIZE = 6; // Mitad del ciclo espejado
|
constexpr size_t CYCLE_SIZE = 6; // Mitad del ciclo espejado
|
||||||
|
|
||||||
// --- Alias ---
|
// --- Alias ---
|
||||||
using Cycle = std::array<Color, 2 * CYCLE_SIZE>;
|
using Cycle = std::array<Color, 2 * CYCLE_SIZE>;
|
||||||
|
|
||||||
// --- Colores predefinidos ---
|
// --- Colores predefinidos ---
|
||||||
constexpr Color NO_COLOR_MOD = Color(0XFF, 0XFF, 0XFF);
|
constexpr Color NO_COLOR_MOD = Color(0XFF, 0XFF, 0XFF);
|
||||||
constexpr Color SHADOW_TEXT = Color(0X43, 0X43, 0X4F);
|
constexpr Color SHADOW_TEXT = Color(0X43, 0X43, 0X4F);
|
||||||
constexpr Color TITLE_SHADOW_TEXT = Color(0x14, 0x87, 0xc4);
|
constexpr Color TITLE_SHADOW_TEXT = Color(0x14, 0x87, 0xc4);
|
||||||
constexpr Color ORANGE_TEXT = Color(0XFF, 0X7A, 0X00);
|
constexpr Color ORANGE_TEXT = Color(0XFF, 0X7A, 0X00);
|
||||||
|
|
||||||
constexpr Color FLASH = Color(0XFF, 0XFF, 0XFF);
|
constexpr Color FLASH = Color(0XFF, 0XFF, 0XFF);
|
||||||
|
|
||||||
constexpr Color BLUE_SKY = Color(0X02, 0X88, 0XD1);
|
constexpr Color BLUE_SKY = Color(0X02, 0X88, 0XD1);
|
||||||
constexpr Color PINK_SKY = Color(0XFF, 0X6B, 0X97);
|
constexpr Color PINK_SKY = Color(0XFF, 0X6B, 0X97);
|
||||||
constexpr Color GREEN_SKY = Color(0X00, 0X79, 0X6B);
|
constexpr Color GREEN_SKY = Color(0X00, 0X79, 0X6B);
|
||||||
|
|
||||||
// --- Funciones ---
|
// --- Funciones ---
|
||||||
auto getColorLikeKnightRider(const std::vector<Color> &colors, int counter) -> Color;
|
auto getColorLikeKnightRider(const std::vector<Color>& colors, int counter) -> Color;
|
||||||
auto generateMirroredCycle(Color base, ColorCycleStyle style = ColorCycleStyle::SUBTLE_PULSE) -> Cycle;
|
auto generateMirroredCycle(Color base, ColorCycleStyle style = ColorCycleStyle::SUBTLE_PULSE) -> Cycle;
|
||||||
}
|
} // namespace Colors
|
||||||
48
source/cooldown.hpp
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <algorithm> // Para std::max
|
||||||
|
|
||||||
|
class Cooldown {
|
||||||
|
public:
|
||||||
|
Cooldown(float first_delay_s = 0.0F, float repeat_delay_s = 0.0F)
|
||||||
|
: first_delay_s_(first_delay_s), repeat_delay_s_(repeat_delay_s) {}
|
||||||
|
|
||||||
|
// Llamar cada frame con delta en segundos (float)
|
||||||
|
void update(float delta_s) {
|
||||||
|
if (remaining_s_ <= 0.0F) {
|
||||||
|
remaining_s_ = 0.0F;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
remaining_s_ -= delta_s;
|
||||||
|
remaining_s_ = std::max(remaining_s_, 0.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Llamar cuando el input está activo. Devuelve true si debe ejecutarse la acción ahora.
|
||||||
|
auto tryConsumeOnHeld() -> bool {
|
||||||
|
if (remaining_s_ > 0.0F) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
float delay = held_before_ ? repeat_delay_s_ : first_delay_s_;
|
||||||
|
remaining_s_ = delay;
|
||||||
|
held_before_ = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Llamar cuando el input se suelta
|
||||||
|
void onReleased() {
|
||||||
|
held_before_ = false;
|
||||||
|
remaining_s_ = 0.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto empty() const -> bool { return remaining_s_ == 0.0F; }
|
||||||
|
|
||||||
|
// Fuerza un valor en segundos (útil para tests o resets)
|
||||||
|
void forceSet(float seconds) { remaining_s_ = seconds > 0.0F ? seconds : 0.0F; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
float first_delay_s_;
|
||||||
|
float repeat_delay_s_;
|
||||||
|
float remaining_s_{0.0F};
|
||||||
|
bool held_before_{false};
|
||||||
|
};
|
||||||
@@ -4,8 +4,9 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
#include "color.h"
|
#include "color.hpp"
|
||||||
#include "ui/notifier.h" // Para Notifier::Position
|
#include "ui/notifier.hpp" // Para Notifier::Position
|
||||||
|
#include "version.h" // Para Version::APP_NAME
|
||||||
|
|
||||||
// --- Namespace GameDefaults: configuración centralizada con valores por defecto del juego ---
|
// --- Namespace GameDefaults: configuración centralizada con valores por defecto del juego ---
|
||||||
namespace GameDefaults {
|
namespace GameDefaults {
|
||||||
@@ -14,7 +15,6 @@ namespace GameDefaults {
|
|||||||
namespace Game {
|
namespace Game {
|
||||||
constexpr float WIDTH = 320.0F;
|
constexpr float WIDTH = 320.0F;
|
||||||
constexpr float HEIGHT = 256.0F;
|
constexpr float HEIGHT = 256.0F;
|
||||||
constexpr float ITEM_SIZE = 20.0F;
|
|
||||||
constexpr int NAME_ENTRY_IDLE_TIME = 10;
|
constexpr int NAME_ENTRY_IDLE_TIME = 10;
|
||||||
constexpr int NAME_ENTRY_TOTAL_TIME = 60;
|
constexpr int NAME_ENTRY_TOTAL_TIME = 60;
|
||||||
constexpr bool HIT_STOP = false;
|
constexpr bool HIT_STOP = false;
|
||||||
@@ -58,7 +58,7 @@ constexpr int SKIP_COUNTDOWN_VALUE = 8;
|
|||||||
// --- TITLE ---
|
// --- TITLE ---
|
||||||
namespace Title {
|
namespace Title {
|
||||||
constexpr int PRESS_START_POSITION = 180;
|
constexpr int PRESS_START_POSITION = 180;
|
||||||
constexpr int DURATION = 800;
|
constexpr float DURATION_S = 14.0F;
|
||||||
constexpr int ARCADE_EDITION_POSITION = 123;
|
constexpr int ARCADE_EDITION_POSITION = 123;
|
||||||
constexpr int TITLE_C_C_POSITION = 80;
|
constexpr int TITLE_C_C_POSITION = 80;
|
||||||
constexpr const char* BG_COLOR = "41526F";
|
constexpr const char* BG_COLOR = "41526F";
|
||||||
@@ -76,14 +76,16 @@ struct BalloonSettings {
|
|||||||
float vel;
|
float vel;
|
||||||
float grav;
|
float grav;
|
||||||
constexpr BalloonSettings(float v, float g)
|
constexpr BalloonSettings(float v, float g)
|
||||||
: vel(v), grav(g) {}
|
: vel(v),
|
||||||
|
grav(g) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Valores para deltaTime en segundos: vel en pixels/s, grav en pixels/s² (aceleración)
|
||||||
constexpr std::array<BalloonSettings, 4> SETTINGS = {{
|
constexpr std::array<BalloonSettings, 4> SETTINGS = {{
|
||||||
BalloonSettings(2.75F, 0.09F), // Globo 0
|
BalloonSettings(165.0F, 320.0F), // Globo 0: vel=165 pixels/s, grav=320 pixels/s²
|
||||||
BalloonSettings(3.70F, 0.10F), // Globo 1
|
BalloonSettings(222.0F, 360.0F), // Globo 1: vel=222 pixels/s, grav=360 pixels/s²
|
||||||
BalloonSettings(4.70F, 0.10F), // Globo 2
|
BalloonSettings(282.0F, 360.0F), // Globo 2: vel=282 pixels/s, grav=360 pixels/s²
|
||||||
BalloonSettings(5.45F, 0.10F) // Globo 3
|
BalloonSettings(327.0F, 360.0F) // Globo 3: vel=327 pixels/s, grav=360 pixels/s²
|
||||||
}};
|
}};
|
||||||
|
|
||||||
constexpr std::array<const char*, 4> COLORS = {
|
constexpr std::array<const char*, 4> COLORS = {
|
||||||
@@ -209,7 +211,7 @@ constexpr const char* PLAYER1 = "422028FF";
|
|||||||
// --- OPTIONS ---
|
// --- OPTIONS ---
|
||||||
namespace Options {
|
namespace Options {
|
||||||
// Window
|
// Window
|
||||||
constexpr const char* WINDOW_CAPTION = "Coffee Crisis Arcade Edition";
|
constexpr const char* WINDOW_CAPTION = Version::APP_NAME;
|
||||||
constexpr int WINDOW_ZOOM = 2;
|
constexpr int WINDOW_ZOOM = 2;
|
||||||
constexpr int WINDOW_MAX_ZOOM = 2;
|
constexpr int WINDOW_MAX_ZOOM = 2;
|
||||||
|
|
||||||
@@ -1,25 +1,23 @@
|
|||||||
#include "define_buttons.h"
|
#include "define_buttons.hpp"
|
||||||
|
|
||||||
#include <algorithm> // Para __all_of_fn, all_of
|
#include <algorithm> // Para __all_of_fn, all_of
|
||||||
#include <functional> // Para identity
|
#include <memory> // Para unique_ptr, allocator, shared_ptr, operator==, make_unique
|
||||||
#include <memory> // Para allocator, unique_ptr, shared_ptr, make_unique, operator==
|
|
||||||
|
|
||||||
#include "color.h" // Para Color
|
#include "input.hpp" // Para Input
|
||||||
#include "input.h" // Para Input
|
#include "input_types.hpp" // Para InputAction
|
||||||
#include "input_types.h" // Para InputAction
|
#include "lang.hpp" // Para getText
|
||||||
#include "lang.h" // Para getText
|
#include "options.hpp" // Para Gamepad
|
||||||
#include "options.h" // Para Gamepad
|
#include "param.hpp" // Para Param, param, ParamGame, ParamServiceMenu
|
||||||
#include "param.h" // Para Param, ParamGame, param
|
#include "resource.hpp" // Para Resource
|
||||||
#include "resource.h" // Para Resource
|
#include "ui/window_message.hpp" // Para WindowMessage
|
||||||
#include "ui/window_message.h" // Para WindowMessage
|
#include "utils.hpp" // Para Zone
|
||||||
#include "utils.h" // Para Zone
|
|
||||||
|
|
||||||
DefineButtons::DefineButtons()
|
DefineButtons::DefineButtons()
|
||||||
: input_(Input::get()) {
|
: input_(Input::get()) {
|
||||||
clearButtons();
|
clearButtons();
|
||||||
|
|
||||||
auto gamepads = input_->getGamepads();
|
auto gamepads = input_->getGamepads();
|
||||||
for (const auto &gamepad : gamepads) {
|
for (const auto& gamepad : gamepads) {
|
||||||
controller_names_.emplace_back(Input::getControllerName(gamepad));
|
controller_names_.emplace_back(Input::getControllerName(gamepad));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,22 +37,22 @@ void DefineButtons::render() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefineButtons::update() {
|
void DefineButtons::update(float delta_time) {
|
||||||
if (!enabled_) {
|
if (!enabled_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualizar la ventana siempre
|
// Actualizar la ventana siempre
|
||||||
if (window_message_) {
|
if (window_message_) {
|
||||||
window_message_->update();
|
window_message_->update(delta_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manejar la secuencia de cierre si ya terminamos
|
// Manejar la secuencia de cierre si ya terminamos
|
||||||
if (finished_ && message_shown_) {
|
if (finished_ && message_shown_) {
|
||||||
message_timer_++;
|
message_timer_ += delta_time;
|
||||||
|
|
||||||
// Después del delay, iniciar animación de cierre (solo una vez)
|
// Después del delay, iniciar animación de cierre (solo una vez)
|
||||||
if (message_timer_ > MESSAGE_DISPLAY_FRAMES && !closing_) {
|
if (message_timer_ >= MESSAGE_DISPLAY_DURATION_S && !closing_) {
|
||||||
if (window_message_) {
|
if (window_message_) {
|
||||||
window_message_->hide(); // Iniciar animación de cierre
|
window_message_->hide(); // Iniciar animación de cierre
|
||||||
}
|
}
|
||||||
@@ -63,7 +61,7 @@ void DefineButtons::update() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefineButtons::handleEvents(const SDL_Event &event) {
|
void DefineButtons::handleEvents(const SDL_Event& event) {
|
||||||
if (enabled_) {
|
if (enabled_) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
||||||
@@ -81,7 +79,7 @@ void DefineButtons::handleEvents(const SDL_Event &event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto DefineButtons::enable(Options::Gamepad *options_gamepad) -> bool {
|
auto DefineButtons::enable(Options::Gamepad* options_gamepad) -> bool {
|
||||||
if (options_gamepad != nullptr) {
|
if (options_gamepad != nullptr) {
|
||||||
options_gamepad_ = options_gamepad;
|
options_gamepad_ = options_gamepad;
|
||||||
enabled_ = true;
|
enabled_ = true;
|
||||||
@@ -117,7 +115,7 @@ void DefineButtons::disable() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefineButtons::doControllerButtonDown(const SDL_GamepadButtonEvent &event) {
|
void DefineButtons::doControllerButtonDown(const SDL_GamepadButtonEvent& event) {
|
||||||
auto gamepad = input_->getGamepad(event.which);
|
auto gamepad = input_->getGamepad(event.which);
|
||||||
|
|
||||||
if (!gamepad || gamepad != options_gamepad_->instance) {
|
if (!gamepad || gamepad != options_gamepad_->instance) {
|
||||||
@@ -132,7 +130,7 @@ void DefineButtons::doControllerButtonDown(const SDL_GamepadButtonEvent &event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefineButtons::doControllerAxisMotion(const SDL_GamepadAxisEvent &event) {
|
void DefineButtons::doControllerAxisMotion(const SDL_GamepadAxisEvent& event) {
|
||||||
auto gamepad = input_->getGamepad(event.which);
|
auto gamepad = input_->getGamepad(event.which);
|
||||||
|
|
||||||
if (!gamepad || gamepad != options_gamepad_->instance) {
|
if (!gamepad || gamepad != options_gamepad_->instance) {
|
||||||
@@ -182,8 +180,8 @@ void DefineButtons::doControllerAxisMotion(const SDL_GamepadAxisEvent &event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefineButtons::bindButtons(Options::Gamepad *options_gamepad) {
|
void DefineButtons::bindButtons(Options::Gamepad* options_gamepad) {
|
||||||
for (const auto &button : buttons_) {
|
for (const auto& button : buttons_) {
|
||||||
Input::bindGameControllerButton(options_gamepad->instance, button.action, static_cast<SDL_GamepadButton>(button.button));
|
Input::bindGameControllerButton(options_gamepad->instance, button.action, static_cast<SDL_GamepadButton>(button.button));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,13 +198,13 @@ void DefineButtons::incIndexButton() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto DefineButtons::checkButtonNotInUse(SDL_GamepadButton button) -> bool {
|
auto DefineButtons::checkButtonNotInUse(SDL_GamepadButton button) -> bool {
|
||||||
return std::ranges::all_of(buttons_, [button](const auto &b) {
|
return std::ranges::all_of(buttons_, [button](const auto& b) {
|
||||||
return b.button != button;
|
return b.button != button;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto DefineButtons::checkTriggerNotInUse(int trigger_button) -> bool {
|
auto DefineButtons::checkTriggerNotInUse(int trigger_button) -> bool {
|
||||||
return std::ranges::all_of(buttons_, [trigger_button](const auto &b) {
|
return std::ranges::all_of(buttons_, [trigger_button](const auto& b) {
|
||||||
return b.button != trigger_button;
|
return b.button != trigger_button;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -234,7 +232,7 @@ void DefineButtons::checkEnd() {
|
|||||||
|
|
||||||
// Solo marcar que ya mostramos el mensaje
|
// Solo marcar que ya mostramos el mensaje
|
||||||
message_shown_ = true;
|
message_shown_ = true;
|
||||||
message_timer_ = 0;
|
message_timer_ = 0.0F;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||