Compare commits
17 Commits
b9e26aa755
...
merdes-nov
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e083a8cdb | |||
| cbe4315701 | |||
| 49d561b583 | |||
| 6e56a6fd79 | |||
| 267d9647e0 | |||
| 13b3702d00 | |||
| 4500845dcd | |||
| a4abc02f88 | |||
| a0fb6934b0 | |||
| 19645445b2 | |||
| efe8628a3c | |||
| c98cb0d29f | |||
| c16fc1bae5 | |||
| fa0af1179a | |||
| d1e4a5eb07 | |||
| e18d1b186a | |||
| d056a5e336 |
@@ -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
|
||||||
@@ -79,6 +95,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,17 +109,12 @@ set(APP_SOURCES
|
|||||||
|
|
||||||
# Fuentes de librerías de terceros
|
# Fuentes de librerías de terceros
|
||||||
set(EXTERNAL_SOURCES
|
set(EXTERNAL_SOURCES
|
||||||
|
source/external/jail_audio.cpp
|
||||||
source/external/jail_shader.cpp
|
source/external/jail_shader.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
|
|
||||||
if(NOT DISABLE_AUDIO)
|
|
||||||
list(APPEND EXTERNAL_SOURCES source/external/jail_audio.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}")
|
||||||
@@ -114,6 +126,7 @@ add_executable(${PROJECT_NAME} ${APP_SOURCES} ${EXTERNAL_SOURCES})
|
|||||||
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_BINARY_DIR}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Enlazar la librería SDL3
|
# Enlazar la librería SDL3
|
||||||
@@ -128,16 +141,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)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ 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|${PREFIX}/data/demo/demo1.bin
|
||||||
DEMODATA|${PREFIX}/data/demo/demo2.bin
|
DEMODATA|${PREFIX}/data/demo/demo2.bin
|
||||||
|
DEMODATA|${PREFIX}/data/demo/demo3.bin
|
||||||
|
|
||||||
# Música
|
# Música
|
||||||
MUSIC|${PREFIX}/data/music/congratulations.ogg
|
MUSIC|${PREFIX}/data/music/congratulations.ogg
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
BIN
data/demo/demo3.bin
Normal file
BIN
data/demo/demo3.bin
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <SDL3/SDL.h> // Para SDL_LogCategory, SDL_LogInfo, SDL_LogError, SDL_LogWarn
|
#include <SDL3/SDL.h> // Para SDL_LogCategory, SDL_LogInfo, SDL_LogError, SDL_LogWarn
|
||||||
|
|
||||||
|
#include <algorithm> // Para std::sort
|
||||||
#include <cstddef> // Para size_t
|
#include <cstddef> // Para size_t
|
||||||
#include <exception> // Para exception
|
#include <exception> // Para exception
|
||||||
#include <filesystem> // Para std::filesystem
|
#include <filesystem> // Para std::filesystem
|
||||||
@@ -299,6 +300,9 @@ auto Asset::getListByType(Type type) const -> std::vector<std::string> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ordenar alfabéticamente para garantizar orden consistente
|
||||||
|
std::sort(list.begin(), list.end());
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,7 @@
|
|||||||
|
|
||||||
#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.h" // Para AudioOptions, audio, MusicOptions
|
#include "options.h" // Para AudioOptions, audio, MusicOptions
|
||||||
#include "resource.h" // Para Resource
|
#include "resource.h" // Para Resource
|
||||||
|
|
||||||
@@ -27,9 +25,7 @@ Audio::Audio() { initSDLAudio(); }
|
|||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
Audio::~Audio() {
|
Audio::~Audio() {
|
||||||
#ifndef NO_AUDIO
|
|
||||||
JA_Quit();
|
JA_Quit();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Método principal
|
// Método principal
|
||||||
@@ -43,9 +39,7 @@ void Audio::playMusic(const std::string &name, const int loop) {
|
|||||||
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 +47,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 +55,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,9 +63,7 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,33 +71,26 @@ void Audio::stopMusic() {
|
|||||||
// 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_ && getRealMusicState() == MusicState::PLAYING) {
|
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
|
// Consulta directamente el estado real de la música en jailaudio
|
||||||
auto Audio::getRealMusicState() const -> MusicState {
|
auto Audio::getRealMusicState() const -> MusicState {
|
||||||
#ifndef NO_AUDIO
|
|
||||||
JA_Music_state ja_state = JA_GetMusicState();
|
JA_Music_state ja_state = JA_GetMusicState();
|
||||||
switch (ja_state) {
|
switch (ja_state) {
|
||||||
case JA_MUSIC_PLAYING:
|
case JA_MUSIC_PLAYING:
|
||||||
@@ -122,19 +103,14 @@ auto Audio::getRealMusicState() const -> MusicState {
|
|||||||
default:
|
default:
|
||||||
return MusicState::STOPPED;
|
return MusicState::STOPPED;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
return MusicState::STOPPED;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el volumen de los sonidos
|
// Establece el volumen de los sonidos
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,10 +118,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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +138,6 @@ 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 {
|
||||||
@@ -173,7 +146,4 @@ void Audio::initSDLAudio() {
|
|||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "** Audio system initialized successfully");
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "** Audio system initialized successfully");
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "** Audio system disabled");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
@@ -122,6 +122,8 @@ class Balloon {
|
|||||||
|
|
||||||
// --- Setters ---
|
// --- Setters ---
|
||||||
void setVelY(float vel_y) { vy_ = vel_y; }
|
void setVelY(float vel_y) { vy_ = vel_y; }
|
||||||
|
void setVelX(float vel_x) { vx_ = vel_x; }
|
||||||
|
void alterVelX(float percent) {vx_ *= percent; }
|
||||||
void setGameTempo(float tempo) { game_tempo_ = tempo; }
|
void setGameTempo(float tempo) { game_tempo_ = tempo; }
|
||||||
void setInvulnerable(bool value) { invulnerable_ = value; }
|
void setInvulnerable(bool value) { invulnerable_ = value; }
|
||||||
void setBouncingSound(bool value) { sound_.bouncing_enabled = value; }
|
void setBouncingSound(bool value) { sound_.bouncing_enabled = value; }
|
||||||
|
|||||||
@@ -208,6 +208,7 @@ void BalloonManager::createChildBalloon(const std::shared_ptr<Balloon> &balloon,
|
|||||||
Balloon::Config config = {
|
Balloon::Config config = {
|
||||||
.x = std::clamp(X - (CHILD_WIDTH / 2), MIN_X, MAX_X),
|
.x = std::clamp(X - (CHILD_WIDTH / 2), MIN_X, MAX_X),
|
||||||
.y = balloon->getPosY() + ((PARENT_HEIGHT - CHILD_HEIGHT) / 2),
|
.y = balloon->getPosY() + ((PARENT_HEIGHT - CHILD_HEIGHT) / 2),
|
||||||
|
.type = balloon->getType(),
|
||||||
.size = static_cast<Balloon::Size>(static_cast<int>(balloon->getSize()) - 1),
|
.size = static_cast<Balloon::Size>(static_cast<int>(balloon->getSize()) - 1),
|
||||||
.vel_x = direction == "LEFT" ? Balloon::VELX_NEGATIVE : Balloon::VELX_POSITIVE,
|
.vel_x = direction == "LEFT" ? Balloon::VELX_NEGATIVE : Balloon::VELX_POSITIVE,
|
||||||
.game_tempo = balloon_speed_,
|
.game_tempo = balloon_speed_,
|
||||||
@@ -216,9 +217,22 @@ void BalloonManager::createChildBalloon(const std::shared_ptr<Balloon> &balloon,
|
|||||||
// Crea el globo
|
// Crea el globo
|
||||||
auto b = createBalloon(config);
|
auto b = createBalloon(config);
|
||||||
|
|
||||||
// Establece parametros (deltaTime en segundos - velocidades en pixels/segundo)
|
// Establece parametros
|
||||||
constexpr float VEL_Y_BALLOON_PER_S = -150.0F; // -2.50 pixels/frame convertido a pixels/segundo (-2.50 * 60 = -150)
|
constexpr float VEL_Y_BALLOON_PER_S = -150.0F;
|
||||||
b->setVelY(b->getType() == Balloon::Type::BALLOON ? VEL_Y_BALLOON_PER_S : Balloon::VELX_NEGATIVE * 2.0F);
|
switch (b->getType()) {
|
||||||
|
case Balloon::Type::BALLOON: {
|
||||||
|
b->setVelY(VEL_Y_BALLOON_PER_S);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Balloon::Type::FLOATER: {
|
||||||
|
const float MODIFIER = (rand() % 2 == 0) ? 1.0F : 1.0F;
|
||||||
|
b->setVelY(Balloon::VELX_NEGATIVE * 2.0F * MODIFIER);
|
||||||
|
(rand() % 2 == 0) ? b->alterVelX(1.0F) : b->alterVelX(1.0F);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Herencia de estados
|
// Herencia de estados
|
||||||
if (balloon->isStopped()) { b->stop(); }
|
if (balloon->isStopped()) { b->stop(); }
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "ui/notifier.h" // Para Notifier::Position
|
#include "ui/notifier.h" // 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;
|
||||||
@@ -211,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;
|
||||||
|
|
||||||
|
|||||||
70
source/demo.cpp
Normal file
70
source/demo.cpp
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#include "demo.h"
|
||||||
|
|
||||||
|
#include <SDL3/SDL.h> // Para SDL_IOStream, SDL_IOFromConstMem, SDL_IOFromFile, SDL_ReadIO, SDL_WriteIO, SDL_CloseIO
|
||||||
|
#include <stdexcept> // Para runtime_error
|
||||||
|
|
||||||
|
#include "resource_helper.h" // Para ResourceHelper
|
||||||
|
#include "utils.h" // Para printWithDots, getFileName
|
||||||
|
|
||||||
|
// Carga el fichero de datos para la demo
|
||||||
|
auto loadDemoDataFromFile(const std::string &file_path) -> DemoData {
|
||||||
|
DemoData dd;
|
||||||
|
|
||||||
|
SDL_IOStream *file = nullptr;
|
||||||
|
|
||||||
|
// Intentar cargar desde ResourceHelper primero
|
||||||
|
auto resource_data = ResourceHelper::loadFile(file_path);
|
||||||
|
if (!resource_data.empty()) {
|
||||||
|
file = SDL_IOFromConstMem(resource_data.data(), resource_data.size());
|
||||||
|
} else {
|
||||||
|
// Fallback a filesystem directo
|
||||||
|
file = SDL_IOFromFile(file_path.c_str(), "r+b");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file == nullptr) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error: Fichero no encontrado %s", file_path.c_str());
|
||||||
|
throw std::runtime_error("Fichero no encontrado: " + file_path);
|
||||||
|
}
|
||||||
|
printWithDots("DemoData : ", getFileName(file_path), "[ LOADED ]");
|
||||||
|
|
||||||
|
// Lee todos los datos del fichero y los deja en el destino
|
||||||
|
for (int i = 0; i < TOTAL_DEMO_DATA; ++i) {
|
||||||
|
DemoKeys dk = DemoKeys();
|
||||||
|
SDL_ReadIO(file, &dk, sizeof(DemoKeys));
|
||||||
|
dd.push_back(dk);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cierra el fichero
|
||||||
|
SDL_CloseIO(file);
|
||||||
|
|
||||||
|
return dd;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef RECORDING
|
||||||
|
// Guarda el fichero de datos para la demo
|
||||||
|
bool saveDemoFile(const std::string &file_path, const DemoData &dd) {
|
||||||
|
auto success = true;
|
||||||
|
auto file = SDL_IOFromFile(file_path.c_str(), "w+b");
|
||||||
|
|
||||||
|
if (file) {
|
||||||
|
// Guarda los datos
|
||||||
|
for (const auto &data : dd) {
|
||||||
|
if (SDL_WriteIO(file, &data, sizeof(DemoKeys)) != sizeof(DemoKeys)) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error al escribir el fichero %s", getFileName(file_path).c_str());
|
||||||
|
success = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (success) {
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Writing file %s", getFileName(file_path).c_str());
|
||||||
|
}
|
||||||
|
// Cierra el fichero
|
||||||
|
SDL_CloseIO(file);
|
||||||
|
} else {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error: Unable to save %s file! %s", getFileName(file_path).c_str(), SDL_GetError());
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
#endif // RECORDING
|
||||||
54
source/demo.h
Normal file
54
source/demo.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <SDL3/SDL.h> // Para Uint8
|
||||||
|
#include <string> // Para string
|
||||||
|
#include <vector> // Para vector
|
||||||
|
|
||||||
|
// --- Constantes ---
|
||||||
|
constexpr int TOTAL_DEMO_DATA = 2000;
|
||||||
|
|
||||||
|
// --- Estructuras ---
|
||||||
|
struct DemoKeys {
|
||||||
|
Uint8 left;
|
||||||
|
Uint8 right;
|
||||||
|
Uint8 no_input;
|
||||||
|
Uint8 fire;
|
||||||
|
Uint8 fire_left;
|
||||||
|
Uint8 fire_right;
|
||||||
|
|
||||||
|
explicit DemoKeys(Uint8 l = 0, Uint8 r = 0, Uint8 ni = 0, Uint8 f = 0, Uint8 fl = 0, Uint8 fr = 0)
|
||||||
|
: left(l),
|
||||||
|
right(r),
|
||||||
|
no_input(ni),
|
||||||
|
fire(f),
|
||||||
|
fire_left(fl),
|
||||||
|
fire_right(fr) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
// --- Tipos ---
|
||||||
|
using DemoData = std::vector<DemoKeys>;
|
||||||
|
|
||||||
|
struct Demo {
|
||||||
|
bool enabled = false; // Indica si está activo el modo demo
|
||||||
|
bool recording = false; // Indica si está activado el modo para grabar la demo
|
||||||
|
float elapsed_s = 0.0F; // Segundos transcurridos de demo
|
||||||
|
int index = 0; // Contador para el modo demo
|
||||||
|
DemoKeys keys; // Variable con las pulsaciones de teclas del modo demo
|
||||||
|
std::vector<DemoData> data; // Vector con diferentes sets de datos con los movimientos para la demo
|
||||||
|
|
||||||
|
Demo() = default;
|
||||||
|
|
||||||
|
Demo(bool e, bool r, int c, const DemoKeys& k, const std::vector<DemoData>& d)
|
||||||
|
: enabled(e),
|
||||||
|
recording(r),
|
||||||
|
index(c),
|
||||||
|
keys(k),
|
||||||
|
data(d) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
// --- Funciones ---
|
||||||
|
auto loadDemoDataFromFile(const std::string& file_path) -> DemoData;
|
||||||
|
|
||||||
|
#ifdef RECORDING
|
||||||
|
bool saveDemoFile(const std::string& file_path, const DemoData& dd);
|
||||||
|
#endif
|
||||||
@@ -42,7 +42,7 @@ Director::Director(int argc, std::span<char *> argv) {
|
|||||||
Section::name = Section::Name::GAME;
|
Section::name = Section::Name::GAME;
|
||||||
Section::options = Section::Options::GAME_PLAY_1P;
|
Section::options = Section::Options::GAME_PLAY_1P;
|
||||||
#elif _DEBUG
|
#elif _DEBUG
|
||||||
Section::name = Section::Name::GAME;
|
Section::name = Section::Name::TITLE;
|
||||||
Section::options = Section::Options::GAME_PLAY_1P;
|
Section::options = Section::Options::GAME_PLAY_1P;
|
||||||
#else // NORMAL GAME
|
#else // NORMAL GAME
|
||||||
Section::name = Section::Name::LOGO;
|
Section::name = Section::Name::LOGO;
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ Item::Item(ItemType type, float x, float y, SDL_FRect &play_area, const std::sha
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
width_ = param.game.item_size;
|
|
||||||
height_ = param.game.item_size;
|
|
||||||
pos_x_ = x;
|
pos_x_ = x;
|
||||||
pos_y_ = y;
|
pos_y_ = y;
|
||||||
// 6 velocidades: 3 negativas (-1.0, -0.66, -0.33) y 3 positivas (0.33, 0.66, 1.0)
|
// 6 velocidades: 3 negativas (-1.0, -0.66, -0.33) y 3 positivas (0.33, 0.66, 1.0)
|
||||||
@@ -35,13 +33,17 @@ Item::Item(ItemType type, float x, float y, SDL_FRect &play_area, const std::sha
|
|||||||
if (direction < 3) {
|
if (direction < 3) {
|
||||||
// Velocidades negativas: -1.0, -0.66, -0.33
|
// Velocidades negativas: -1.0, -0.66, -0.33
|
||||||
vel_x_ = -ITEM_VEL_X_BASE + (direction * ITEM_VEL_X_STEP);
|
vel_x_ = -ITEM_VEL_X_BASE + (direction * ITEM_VEL_X_STEP);
|
||||||
|
rotate_speed_ = -720.0F;
|
||||||
} else {
|
} else {
|
||||||
// Velocidades positivas: 0.33, 0.66, 1.0
|
// Velocidades positivas: 0.33, 0.66, 1.0
|
||||||
vel_x_ = ITEM_VEL_X_STEP + ((direction - 3) * ITEM_VEL_X_STEP);
|
vel_x_ = ITEM_VEL_X_STEP + ((direction - 3) * ITEM_VEL_X_STEP);
|
||||||
|
rotate_speed_ = 720.0F;
|
||||||
}
|
}
|
||||||
vel_y_ = ITEM_VEL_Y;
|
vel_y_ = ITEM_VEL_Y;
|
||||||
accel_y_ = ITEM_ACCEL_Y;
|
accel_y_ = ITEM_ACCEL_Y;
|
||||||
collider_.r = width_ / 2;
|
collider_.r = width_ / 2;
|
||||||
|
sprite_->startRotate();
|
||||||
|
sprite_->setRotateAmount(rotate_speed_);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,6 +106,7 @@ void Item::move(float deltaTime) {
|
|||||||
// Si toca el borde lateral
|
// Si toca el borde lateral
|
||||||
if (pos_x_ == MIN_X || pos_x_ == MAX_X) {
|
if (pos_x_ == MIN_X || pos_x_ == MAX_X) {
|
||||||
vel_x_ = -vel_x_; // Invierte la velocidad horizontal
|
vel_x_ = -vel_x_; // Invierte la velocidad horizontal
|
||||||
|
sprite_->scaleRotateAmount(-1.0F); // Invierte la rotación
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si colisiona por arriba, rebota (excepto la máquina de café)
|
// Si colisiona por arriba, rebota (excepto la máquina de café)
|
||||||
@@ -117,8 +120,9 @@ void Item::move(float deltaTime) {
|
|||||||
|
|
||||||
// Si colisiona con la parte inferior
|
// Si colisiona con la parte inferior
|
||||||
if (pos_y_ > play_area_.h - height_) {
|
if (pos_y_ > play_area_.h - height_) {
|
||||||
// Corrige la posición
|
pos_y_ = play_area_.h - height_; // Corrige la posición
|
||||||
pos_y_ = play_area_.h - height_;
|
sprite_->scaleRotateAmount(0.5F); // Reduce la rotación
|
||||||
|
sprite_->stopRotate(300.0F); // Detiene la rotacion
|
||||||
|
|
||||||
switch (type_) {
|
switch (type_) {
|
||||||
case ItemType::COFFEE_MACHINE:
|
case ItemType::COFFEE_MACHINE:
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ enum class ItemType : int {
|
|||||||
class Item {
|
class Item {
|
||||||
public:
|
public:
|
||||||
// --- Constantes ---
|
// --- Constantes ---
|
||||||
|
static constexpr float WIDTH = 20.0F; // Anchura del item
|
||||||
|
static constexpr float HEIGHT = 20.0F; // ALtura del item
|
||||||
static constexpr int COFFEE_MACHINE_WIDTH = 30; // Anchura de la máquina de café
|
static constexpr int COFFEE_MACHINE_WIDTH = 30; // Anchura de la máquina de café
|
||||||
static constexpr int COFFEE_MACHINE_HEIGHT = 39; // Altura de la máquina de café
|
static constexpr int COFFEE_MACHINE_HEIGHT = 39; // Altura de la máquina de café
|
||||||
static constexpr float LIFETIME_DURATION_S = 10.0f; // Duración de vida del ítem en segundos
|
static constexpr float LIFETIME_DURATION_S = 10.0f; // Duración de vida del ítem en segundos
|
||||||
@@ -76,14 +78,15 @@ class Item {
|
|||||||
SDL_FRect play_area_; // Rectángulo con la zona de juego
|
SDL_FRect play_area_; // Rectángulo con la zona de juego
|
||||||
Circle collider_; // Círculo de colisión del objeto
|
Circle collider_; // Círculo de colisión del objeto
|
||||||
ItemType type_; // Tipo de objeto
|
ItemType type_; // Tipo de objeto
|
||||||
float pos_x_; // Posición X del objeto
|
float pos_x_ = 0.0F; // Posición X del objeto
|
||||||
float pos_y_; // Posición Y del objeto
|
float pos_y_ = 0.0F; // Posición Y del objeto
|
||||||
float vel_x_; // Velocidad en el eje X
|
float vel_x_ = 0.0F; // Velocidad en el eje X
|
||||||
float vel_y_; // Velocidad en el eje Y
|
float vel_y_ = 0.0F; // Velocidad en el eje Y
|
||||||
float accel_x_ = 0.0F; // Aceleración en el eje X
|
float accel_x_ = 0.0F; // Aceleración en el eje X
|
||||||
float accel_y_; // Aceleración en el eje Y
|
float accel_y_ = 0.0F; // Aceleración en el eje Y
|
||||||
int width_; // Ancho del objeto
|
float width_ = WIDTH; // Ancho del objeto
|
||||||
int height_; // Alto del objeto
|
float height_ = HEIGHT; // Alto del objeto
|
||||||
|
float rotate_speed_ = 0.0F; // Velocidad de rotacion
|
||||||
float lifetime_timer_ = 0.0f; // Acumulador de tiempo de vida del ítem (segundos)
|
float lifetime_timer_ = 0.0f; // Acumulador de tiempo de vida del ítem (segundos)
|
||||||
bool floor_collision_ = false; // Indica si el objeto colisiona con el suelo
|
bool floor_collision_ = false; // Indica si el objeto colisiona con el suelo
|
||||||
bool enabled_ = true; // Indica si el objeto está habilitado
|
bool enabled_ = true; // Indica si el objeto está habilitado
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "moving_sprite.h"
|
#include "moving_sprite.h"
|
||||||
|
|
||||||
|
#include <cmath> // Para std::abs
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "texture.h" // Para Texture
|
#include "texture.h" // Para Texture
|
||||||
@@ -90,6 +91,21 @@ void MovingSprite::setRotate(bool enable) {
|
|||||||
rotate_.enabled = enable;
|
rotate_.enabled = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Habilita la rotación y establece el centro en el centro del sprite
|
||||||
|
void MovingSprite::startRotate() {
|
||||||
|
rotate_.enabled = true;
|
||||||
|
rotate_.center.x = pos_.w / 2.0F;
|
||||||
|
rotate_.center.y = pos_.h / 2.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detiene la rotación y resetea el ángulo a cero
|
||||||
|
void MovingSprite::stopRotate(float threshold) {
|
||||||
|
if (threshold == 0.0F || std::abs(rotate_.amount) <= threshold) {
|
||||||
|
rotate_.enabled = false;
|
||||||
|
rotate_.angle = 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Establece la posición y_ el tamaño del objeto
|
// Establece la posición y_ el tamaño del objeto
|
||||||
void MovingSprite::setPos(SDL_FRect rect) {
|
void MovingSprite::setPos(SDL_FRect rect) {
|
||||||
x_ = rect.x;
|
x_ = rect.x;
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ class MovingSprite : public Sprite {
|
|||||||
// --- Estructuras ---
|
// --- Estructuras ---
|
||||||
struct Rotate {
|
struct Rotate {
|
||||||
bool enabled{false}; // Indica si ha de rotar
|
bool enabled{false}; // Indica si ha de rotar
|
||||||
int speed{1}; // Velocidad de giro
|
|
||||||
double angle{0.0}; // Ángulo para dibujarlo
|
double angle{0.0}; // Ángulo para dibujarlo
|
||||||
float amount{0.0F}; // Cantidad de grados a girar en cada iteración
|
float amount{0.0F}; // Cantidad de grados a girar en cada iteración
|
||||||
SDL_FPoint center{.x = 0.0F, .y = 0.0F}; // Centro de rotación
|
SDL_FPoint center{.x = 0.0F, .y = 0.0F}; // Centro de rotación
|
||||||
@@ -47,8 +46,10 @@ class MovingSprite : public Sprite {
|
|||||||
void setAngle(double value) { rotate_.angle = value; } // Establece el ángulo
|
void setAngle(double value) { rotate_.angle = value; } // Establece el ángulo
|
||||||
void setRotatingCenter(SDL_FPoint point) { rotate_.center = point; } // Establece el centro de rotación
|
void setRotatingCenter(SDL_FPoint point) { rotate_.center = point; } // Establece el centro de rotación
|
||||||
void setRotate(bool enable); // Activa o desactiva el efecto de rotación
|
void setRotate(bool enable); // Activa o desactiva el efecto de rotación
|
||||||
void setRotateSpeed(int value) { rotate_.speed = std::max(1, value); } // Establece la velocidad de rotación
|
void startRotate(); // Habilita la rotación con centro automático
|
||||||
void setRotateAmount(double value) { rotate_.amount = value; } // Establece la cantidad de rotación
|
void stopRotate(float threshold = 0.0F); // Detiene la rotación y resetea ángulo
|
||||||
|
void setRotateAmount(double value) { rotate_.amount = value; } // Establece la velocidad de rotación
|
||||||
|
void scaleRotateAmount(float value) { rotate_.amount *= value; } // Modifica la velocidad de rotacion
|
||||||
void switchRotate() { rotate_.amount *= -1; } // Cambia el sentido de la rotación
|
void switchRotate() { rotate_.amount *= -1; } // Cambia el sentido de la rotación
|
||||||
void setFlip(SDL_FlipMode flip) { flip_ = flip; } // Establece el flip
|
void setFlip(SDL_FlipMode flip) { flip_ = flip; } // Establece el flip
|
||||||
void flip() { flip_ = (flip_ == SDL_FLIP_HORIZONTAL) ? SDL_FLIP_NONE : SDL_FLIP_HORIZONTAL; } // Cambia el flip
|
void flip() { flip_ = (flip_ == SDL_FLIP_HORIZONTAL) ? SDL_FLIP_NONE : SDL_FLIP_HORIZONTAL; } // Cambia el flip
|
||||||
|
|||||||
@@ -87,7 +87,6 @@ auto setParams(const std::string& var, const std::string& value) -> bool {
|
|||||||
static const std::unordered_map<std::string, std::function<void(const std::string&)>> INT_PARAMS = {
|
static const std::unordered_map<std::string, std::function<void(const std::string&)>> INT_PARAMS = {
|
||||||
{"game.width", [](const std::string& v) { param.game.width = std::stoi(v); }},
|
{"game.width", [](const std::string& v) { param.game.width = std::stoi(v); }},
|
||||||
{"game.height", [](const std::string& v) { param.game.height = std::stoi(v); }},
|
{"game.height", [](const std::string& v) { param.game.height = std::stoi(v); }},
|
||||||
{"game.item_size", [](const std::string& v) { param.game.item_size = std::stoi(v); }},
|
|
||||||
{"game.play_area.rect.x", [](const std::string& v) { param.game.play_area.rect.x = std::stoi(v); }},
|
{"game.play_area.rect.x", [](const std::string& v) { param.game.play_area.rect.x = std::stoi(v); }},
|
||||||
{"game.play_area.rect.y", [](const std::string& v) { param.game.play_area.rect.y = std::stoi(v); }},
|
{"game.play_area.rect.y", [](const std::string& v) { param.game.play_area.rect.y = std::stoi(v); }},
|
||||||
{"game.play_area.rect.w", [](const std::string& v) { param.game.play_area.rect.w = std::stoi(v); }},
|
{"game.play_area.rect.w", [](const std::string& v) { param.game.play_area.rect.w = std::stoi(v); }},
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
struct ParamGame {
|
struct ParamGame {
|
||||||
float width = GameDefaults::Game::WIDTH;
|
float width = GameDefaults::Game::WIDTH;
|
||||||
float height = GameDefaults::Game::HEIGHT;
|
float height = GameDefaults::Game::HEIGHT;
|
||||||
float item_size = GameDefaults::Game::ITEM_SIZE;
|
|
||||||
Zone play_area{}; // Se inicializa en el constructor de Param
|
Zone play_area{}; // Se inicializa en el constructor de Param
|
||||||
Zone game_area{}; // Se inicializa en el constructor de Param
|
Zone game_area{}; // Se inicializa en el constructor de Param
|
||||||
int name_entry_idle_time = GameDefaults::Game::NAME_ENTRY_IDLE_TIME;
|
int name_entry_idle_time = GameDefaults::Game::NAME_ENTRY_IDLE_TIME;
|
||||||
|
|||||||
@@ -217,6 +217,10 @@ class Player {
|
|||||||
[[nodiscard]] auto getUsesKeyboard() const -> bool { return uses_keyboard_; }
|
[[nodiscard]] auto getUsesKeyboard() const -> bool { return uses_keyboard_; }
|
||||||
[[nodiscard]] auto getController() const -> int { return controller_index_; }
|
[[nodiscard]] auto getController() const -> int { return controller_index_; }
|
||||||
|
|
||||||
|
// Demo file management
|
||||||
|
[[nodiscard]] auto getDemoFile() const -> size_t { return demo_file_; }
|
||||||
|
void setDemoFile(size_t demo_file) { demo_file_ = demo_file; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// --- Constantes de física y movimiento ---
|
// --- Constantes de física y movimiento ---
|
||||||
static constexpr float BASE_SPEED = 90.0f; // Velocidad base del jugador (pixels/segundo)
|
static constexpr float BASE_SPEED = 90.0f; // Velocidad base del jugador (pixels/segundo)
|
||||||
@@ -304,6 +308,7 @@ class Player {
|
|||||||
int power_up_x_offset_ = 0; // Desplazamiento del sprite de PowerUp respecto al sprite del jugador
|
int power_up_x_offset_ = 0; // Desplazamiento del sprite de PowerUp respecto al sprite del jugador
|
||||||
int continue_counter_ = 10; // Contador para poder continuar
|
int continue_counter_ = 10; // Contador para poder continuar
|
||||||
int controller_index_ = 0; // Índice del array de mandos que utilizará para moverse
|
int controller_index_ = 0; // Índice del array de mandos que utilizará para moverse
|
||||||
|
size_t demo_file_ = 0; // Indice del fichero de datos para el modo demo
|
||||||
float name_entry_idle_time_accumulator_ = 0.0f; // Tiempo idle acumulado para poner nombre (milisegundos)
|
float name_entry_idle_time_accumulator_ = 0.0f; // Tiempo idle acumulado para poner nombre (milisegundos)
|
||||||
float name_entry_total_time_accumulator_ = 0.0f; // Tiempo total acumulado poniendo nombre (milisegundos)
|
float name_entry_total_time_accumulator_ = 0.0f; // Tiempo total acumulado poniendo nombre (milisegundos)
|
||||||
int step_counter_ = 0; // Cuenta los pasos para los estados en los que camina automáticamente
|
int step_counter_ = 0; // Cuenta los pasos para los estados en los que camina automáticamente
|
||||||
@@ -350,16 +355,11 @@ class Player {
|
|||||||
void updateFireSystem(float deltaTime); // Método principal del nuevo sistema de disparo
|
void updateFireSystem(float deltaTime); // Método principal del nuevo sistema de disparo
|
||||||
void updateFunctionalLine(float deltaTime); // Actualiza la línea funcional (CanFire)
|
void updateFunctionalLine(float deltaTime); // Actualiza la línea funcional (CanFire)
|
||||||
void updateVisualLine(float deltaTime); // Actualiza la línea visual (Animaciones)
|
void updateVisualLine(float deltaTime); // Actualiza la línea visual (Animaciones)
|
||||||
void startFiring(int cooldown_frames); // Inicia un nuevo disparo en ambas líneas
|
|
||||||
void updateFiringStateFromVisual(); // Sincroniza firing_state_ con visual_fire_state_
|
void updateFiringStateFromVisual(); // Sincroniza firing_state_ con visual_fire_state_
|
||||||
void transitionToRecoilingNew(); // Transición AIMING → RECOILING
|
void transitionToRecoilingNew(); // Transición AIMING → RECOILING
|
||||||
void transitionToThreatPose(); // Transición RECOILING → THREAT_POSE
|
void transitionToThreatPose(); // Transición RECOILING → THREAT_POSE
|
||||||
void transitionToNormalNew(); // Transición THREAT_POSE → NORMAL
|
void transitionToNormalNew(); // Transición THREAT_POSE → NORMAL
|
||||||
|
|
||||||
// --- Sistema de disparo obsoleto (legacy) ---
|
|
||||||
void handleFiringCooldown(float deltaTime); // Gestiona el tiempo de espera después de disparar
|
|
||||||
void handleRecoilAndCooling(float deltaTime); // Procesa retroceso y enfriamiento
|
|
||||||
void handleCoolingState(float deltaTime); // Actualiza estado de enfriamiento
|
|
||||||
// --- Manejadores de movimiento ---
|
// --- Manejadores de movimiento ---
|
||||||
void handlePlayingMovement(float deltaTime); // Gestiona el movimiento durante el juego
|
void handlePlayingMovement(float deltaTime); // Gestiona el movimiento durante el juego
|
||||||
void handleRecoverMovement(); // Comprueba si ha acabado la animación de recuperación
|
void handleRecoverMovement(); // Comprueba si ha acabado la animación de recuperación
|
||||||
|
|||||||
@@ -12,14 +12,13 @@
|
|||||||
|
|
||||||
#include "asset.h" // Para Asset
|
#include "asset.h" // Para Asset
|
||||||
#include "color.h" // Para Color
|
#include "color.h" // Para Color
|
||||||
#ifndef NO_AUDIO
|
|
||||||
#include "external/jail_audio.h" // Para JA_LoadMusic, JA_LoadSound, JA_DeleteMusic, JA_DeleteSound
|
#include "external/jail_audio.h" // Para JA_LoadMusic, JA_LoadSound, JA_DeleteMusic, JA_DeleteSound
|
||||||
#endif
|
|
||||||
#include "lang.h" // Para getText
|
#include "lang.h" // Para getText
|
||||||
#include "param.h" // Para Param, param, ParamResource, ParamGame
|
#include "param.h" // Para Param, param, ParamResource, ParamGame
|
||||||
#include "resource_helper.h" // Para ResourceHelper
|
#include "resource_helper.h" // Para ResourceHelper
|
||||||
#include "screen.h" // Para Screen
|
#include "screen.h" // Para Screen
|
||||||
#include "text.h" // Para Text
|
#include "text.h" // Para Text
|
||||||
|
#include "version.h" // Para Version::APP_NAME y Version::GIT_HASH
|
||||||
|
|
||||||
struct JA_Music_t; // lines 11-11
|
struct JA_Music_t; // lines 11-11
|
||||||
struct JA_Sound_t; // lines 12-12
|
struct JA_Sound_t; // lines 12-12
|
||||||
@@ -317,6 +316,11 @@ auto Resource::getAnimation(const std::string &name) -> AnimationsFileBuffer & {
|
|||||||
|
|
||||||
// Obtiene el fichero con los datos para el modo demostración a partir de un índice
|
// Obtiene el fichero con los datos para el modo demostración a partir de un índice
|
||||||
auto Resource::getDemoData(int index) -> DemoData& {
|
auto Resource::getDemoData(int index) -> DemoData& {
|
||||||
|
if (index < 0 || index >= static_cast<int>(demos_.size())) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Index %d out of range for demo data (size: %d)", index, static_cast<int>(demos_.size()));
|
||||||
|
static DemoData empty_demo;
|
||||||
|
return empty_demo;
|
||||||
|
}
|
||||||
return demos_.at(index);
|
return demos_.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,7 +328,6 @@ auto Resource::getDemoData(int index) -> DemoData & {
|
|||||||
|
|
||||||
auto Resource::loadSoundLazy(const std::string& name) -> JA_Sound_t* {
|
auto Resource::loadSoundLazy(const std::string& name) -> JA_Sound_t* {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Loading sound lazily: %s", name.c_str());
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Loading sound lazily: %s", name.c_str());
|
||||||
#ifndef NO_AUDIO
|
|
||||||
auto sound_list = Asset::get()->getListByType(Asset::Type::SOUND);
|
auto sound_list = Asset::get()->getListByType(Asset::Type::SOUND);
|
||||||
for (const auto& file : sound_list) {
|
for (const auto& file : sound_list) {
|
||||||
if (getFileName(file) == name) {
|
if (getFileName(file) == name) {
|
||||||
@@ -332,13 +335,11 @@ auto Resource::loadSoundLazy(const std::string &name) -> JA_Sound_t * {
|
|||||||
return JA_LoadSound(audio_path.c_str());
|
return JA_LoadSound(audio_path.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Resource::loadMusicLazy(const std::string& name) -> JA_Music_t* {
|
auto Resource::loadMusicLazy(const std::string& name) -> JA_Music_t* {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Loading music lazily: %s", name.c_str());
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Loading music lazily: %s", name.c_str());
|
||||||
#ifndef NO_AUDIO
|
|
||||||
auto music_list = Asset::get()->getListByType(Asset::Type::MUSIC);
|
auto music_list = Asset::get()->getListByType(Asset::Type::MUSIC);
|
||||||
for (const auto& file : music_list) {
|
for (const auto& file : music_list) {
|
||||||
if (getFileName(file) == name) {
|
if (getFileName(file) == name) {
|
||||||
@@ -346,7 +347,6 @@ auto Resource::loadMusicLazy(const std::string &name) -> JA_Music_t * {
|
|||||||
return JA_LoadMusic(audio_path.c_str());
|
return JA_LoadMusic(audio_path.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,10 +425,8 @@ auto Resource::loadAnimationLazy(const std::string &name) -> AnimationsFileBuffe
|
|||||||
|
|
||||||
// Vacia todos los vectores de recursos
|
// Vacia todos los vectores de recursos
|
||||||
void Resource::clear() {
|
void Resource::clear() {
|
||||||
#ifndef NO_AUDIO
|
|
||||||
clearSounds();
|
clearSounds();
|
||||||
clearMusics();
|
clearMusics();
|
||||||
#endif
|
|
||||||
textures_.clear();
|
textures_.clear();
|
||||||
text_files_.clear();
|
text_files_.clear();
|
||||||
texts_.clear();
|
texts_.clear();
|
||||||
@@ -448,10 +446,8 @@ void Resource::load() {
|
|||||||
screen->setVSync(false);
|
screen->setVSync(false);
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n** LOADING RESOURCES");
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n** LOADING RESOURCES");
|
||||||
#ifndef NO_AUDIO
|
|
||||||
loadSounds(); // Carga sonidos
|
loadSounds(); // Carga sonidos
|
||||||
loadMusics(); // Carga músicas
|
loadMusics(); // Carga músicas
|
||||||
#endif
|
|
||||||
loadTextures(); // Carga texturas
|
loadTextures(); // Carga texturas
|
||||||
loadTextFiles(); // Carga ficheros de texto
|
loadTextFiles(); // Carga ficheros de texto
|
||||||
loadAnimations(); // Carga animaciones
|
loadAnimations(); // Carga animaciones
|
||||||
@@ -484,12 +480,8 @@ void Resource::loadSounds() {
|
|||||||
for (const auto& l : list) {
|
for (const auto& l : list) {
|
||||||
auto name = getFileName(l);
|
auto name = getFileName(l);
|
||||||
updateLoadingProgress(name);
|
updateLoadingProgress(name);
|
||||||
#ifndef NO_AUDIO
|
|
||||||
std::string audio_path = createTempAudioFile(l, temp_audio_files_);
|
std::string audio_path = createTempAudioFile(l, temp_audio_files_);
|
||||||
sounds_.emplace_back(name, JA_LoadSound(audio_path.c_str()));
|
sounds_.emplace_back(name, JA_LoadSound(audio_path.c_str()));
|
||||||
#else
|
|
||||||
sounds_.emplace_back(name, nullptr);
|
|
||||||
#endif
|
|
||||||
printWithDots("Sound : ", name, "[ LOADED ]");
|
printWithDots("Sound : ", name, "[ LOADED ]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -503,12 +495,8 @@ void Resource::loadMusics() {
|
|||||||
for (const auto& l : list) {
|
for (const auto& l : list) {
|
||||||
auto name = getFileName(l);
|
auto name = getFileName(l);
|
||||||
updateLoadingProgress(name);
|
updateLoadingProgress(name);
|
||||||
#ifndef NO_AUDIO
|
|
||||||
std::string audio_path = createTempAudioFile(l, temp_audio_files_);
|
std::string audio_path = createTempAudioFile(l, temp_audio_files_);
|
||||||
musics_.emplace_back(name, JA_LoadMusic(audio_path.c_str()));
|
musics_.emplace_back(name, JA_LoadMusic(audio_path.c_str()));
|
||||||
#else
|
|
||||||
musics_.emplace_back(name, nullptr);
|
|
||||||
#endif
|
|
||||||
printWithDots("Music : ", name, "[ LOADED ]");
|
printWithDots("Music : ", name, "[ LOADED ]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -555,12 +543,13 @@ void Resource::loadAnimations() {
|
|||||||
// Carga los datos para el modo demostración
|
// Carga los datos para el modo demostración
|
||||||
void Resource::loadDemoData() {
|
void Resource::loadDemoData() {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> DEMO FILES");
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> DEMO FILES");
|
||||||
|
auto list = Asset::get()->getListByType(Asset::Type::DEMODATA);
|
||||||
|
demos_.clear();
|
||||||
|
|
||||||
constexpr std::array<const char *, 2> DEMO_FILES = {"demo1.bin", "demo2.bin"};
|
for (const auto& l : list) {
|
||||||
|
auto name = getFileName(l);
|
||||||
for (const auto &file : DEMO_FILES) {
|
updateLoadingProgress(name);
|
||||||
updateLoadingProgress(file);
|
demos_.emplace_back(loadDemoDataFromFile(l));
|
||||||
demos_.emplace_back(loadDemoDataFromFile(Asset::get()->get(file)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -738,9 +727,7 @@ void Resource::createText() {
|
|||||||
void Resource::clearSounds() {
|
void Resource::clearSounds() {
|
||||||
for (auto& sound : sounds_) {
|
for (auto& sound : sounds_) {
|
||||||
if (sound.sound != nullptr) {
|
if (sound.sound != nullptr) {
|
||||||
#ifndef NO_AUDIO
|
|
||||||
JA_DeleteSound(sound.sound);
|
JA_DeleteSound(sound.sound);
|
||||||
#endif
|
|
||||||
sound.sound = nullptr;
|
sound.sound = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -751,9 +738,7 @@ void Resource::clearSounds() {
|
|||||||
void Resource::clearMusics() {
|
void Resource::clearMusics() {
|
||||||
for (auto& music : musics_) {
|
for (auto& music : musics_) {
|
||||||
if (music.music != nullptr) {
|
if (music.music != nullptr) {
|
||||||
#ifndef NO_AUDIO
|
|
||||||
JA_DeleteMusic(music.music);
|
JA_DeleteMusic(music.music);
|
||||||
#endif
|
|
||||||
music.music = nullptr;
|
music.music = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -809,20 +794,27 @@ void Resource::renderProgress() {
|
|||||||
Lang::getText("[RESOURCE] LOADING") + " : " + loading_resource_name_,
|
Lang::getText("[RESOURCE] LOADING") + " : " + loading_resource_name_,
|
||||||
param.resource.color);
|
param.resource.color);
|
||||||
|
|
||||||
// Muestra información del monitor alineada con la barra de carga
|
// Muestra nombre de la aplicación y versión
|
||||||
loading_text_->writeColored(
|
loading_text_->writeColored(
|
||||||
X_PADDING,
|
X_PADDING,
|
||||||
Y_PADDING,
|
Y_PADDING,
|
||||||
|
std::string(Version::APP_NAME) + " (" + Version::GIT_HASH + ")",
|
||||||
|
param.resource.color);
|
||||||
|
|
||||||
|
// Muestra información del monitor desplazada hacia abajo
|
||||||
|
loading_text_->writeColored(
|
||||||
|
X_PADDING,
|
||||||
|
Y_PADDING + 18,
|
||||||
screen->getDisplayMonitorName(),
|
screen->getDisplayMonitorName(),
|
||||||
param.resource.color);
|
param.resource.color);
|
||||||
loading_text_->writeColored(
|
loading_text_->writeColored(
|
||||||
X_PADDING,
|
X_PADDING,
|
||||||
Y_PADDING + 9,
|
Y_PADDING + 27,
|
||||||
std::to_string(screen->getDisplayMonitorWidth()) + "x" + std::to_string(screen->getDisplayMonitorHeight()),
|
std::to_string(screen->getDisplayMonitorWidth()) + "x" + std::to_string(screen->getDisplayMonitorHeight()),
|
||||||
param.resource.color);
|
param.resource.color);
|
||||||
loading_text_->writeColored(
|
loading_text_->writeColored(
|
||||||
X_PADDING,
|
X_PADDING,
|
||||||
Y_PADDING + 18,
|
Y_PADDING + 36,
|
||||||
std::to_string(screen->getDisplayMonitorRefreshRate()) + "Hz",
|
std::to_string(screen->getDisplayMonitorRefreshRate()) + "Hz",
|
||||||
param.resource.color);
|
param.resource.color);
|
||||||
|
|
||||||
@@ -850,12 +842,11 @@ void Resource::checkEvents() {
|
|||||||
// Carga los datos para el modo demostración (sin mostrar progreso)
|
// Carga los datos para el modo demostración (sin mostrar progreso)
|
||||||
void Resource::loadDemoDataQuiet() {
|
void Resource::loadDemoDataQuiet() {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> DEMO FILES (quiet load)");
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> DEMO FILES (quiet load)");
|
||||||
|
auto list = Asset::get()->getListByType(Asset::Type::DEMODATA);
|
||||||
|
demos_.clear();
|
||||||
|
|
||||||
constexpr std::array<const char *, 2> DEMO_FILES = {"demo1.bin", "demo2.bin"};
|
for (const auto& l : list) {
|
||||||
|
demos_.emplace_back(loadDemoDataFromFile(l));
|
||||||
for (const auto &file : DEMO_FILES) {
|
|
||||||
demos_.emplace_back(loadDemoDataFromFile(Asset::get()->get(file)));
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Demo file loaded: %s", file);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include "animated_sprite.h" // Para AnimationsFileBuffer
|
#include "animated_sprite.h" // Para AnimationsFileBuffer
|
||||||
#include "text.h" // Para Text, TextFile
|
#include "text.h" // Para Text, TextFile
|
||||||
#include "texture.h" // Para Texture
|
#include "texture.h" // Para Texture
|
||||||
#include "utils.h" // Para DemoData
|
#include "demo.h" // Para DemoData
|
||||||
|
|
||||||
struct JA_Music_t;
|
struct JA_Music_t;
|
||||||
struct JA_Sound_t;
|
struct JA_Sound_t;
|
||||||
|
|||||||
@@ -217,6 +217,10 @@ void Screen::renderInfo() {
|
|||||||
// FPS
|
// FPS
|
||||||
const std::string FPS_TEXT = std::to_string(fps_.last_value) + " FPS";
|
const std::string FPS_TEXT = std::to_string(fps_.last_value) + " FPS";
|
||||||
debug_info_.text->writeDX(Text::COLOR | Text::STROKE, param.game.width - debug_info_.text->length(FPS_TEXT) - 2, 1 + debug_info_.text->getCharacterSize(), FPS_TEXT, 1, param.debug.color, 1, param.debug.color.DARKEN(150));
|
debug_info_.text->writeDX(Text::COLOR | Text::STROKE, param.game.width - debug_info_.text->length(FPS_TEXT) - 2, 1 + debug_info_.text->getCharacterSize(), FPS_TEXT, 1, param.debug.color, 1, param.debug.color.DARKEN(150));
|
||||||
|
#ifdef RECORDING
|
||||||
|
// RECORDING
|
||||||
|
debug_info_.text->writeDX(Text::COLOR | Text::STROKE, param.game.width - debug_info_.text->length("RECORDING"), 2*(1 + debug_info_.text->getCharacterSize()), "RECORDING", 1, param.debug.color, 1, param.debug.color.DARKEN(150));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
#include <SDL3/SDL.h> // Para SDL_GetTicks, SDL_SetRenderTarget, SDL_CreateTexture, SDL_Delay, SDL_DestroyTexture, SDL_EventType, SDL_GetRenderTarget, SDL_PollEvent, SDL_RenderTexture, SDL_SetTextureBlendMode, SDL_BLENDMODE_BLEND, SDL_Event, SDL_PixelFormat, SDL_Point, SDL_TextureAccess
|
#include <SDL3/SDL.h> // Para SDL_GetTicks, SDL_SetRenderTarget, SDL_CreateTexture, SDL_Delay, SDL_DestroyTexture, SDL_EventType, SDL_GetRenderTarget, SDL_PollEvent, SDL_RenderTexture, SDL_SetTextureBlendMode, SDL_BLENDMODE_BLEND, SDL_Event, SDL_PixelFormat, SDL_Point, SDL_TextureAccess
|
||||||
|
|
||||||
#include <algorithm> // Para find, clamp, find_if, min
|
#include <algorithm> // Para find, clamp, find_if, min, std::shuffle, std::iota
|
||||||
#include <array> // Para array
|
#include <array> // Para array
|
||||||
#include <cstdlib> // Para rand, size_t
|
#include <cstdlib> // Para rand, size_t
|
||||||
#include <functional> // Para function
|
#include <functional> // Para function
|
||||||
#include <iterator> // Para size
|
#include <iterator> // Para size
|
||||||
#include <memory> // Para shared_ptr, unique_ptr, __shared_ptr_access, allocator, make_unique, operator==, make_shared
|
#include <memory> // Para shared_ptr, unique_ptr, __shared_ptr_access, allocator, make_unique, operator==, make_shared
|
||||||
|
#include <random> // std::random_device, std::default_random_engine
|
||||||
#include <utility> // Para move
|
#include <utility> // Para move
|
||||||
|
|
||||||
#include "asset.h" // Para Asset
|
#include "asset.h" // Para Asset
|
||||||
@@ -48,7 +49,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Game::Game(Player::Id player_id, int current_stage, bool demo)
|
Game::Game(Player::Id player_id, int current_stage, bool demo_enabled)
|
||||||
: renderer_(Screen::get()->getRenderer()),
|
: renderer_(Screen::get()->getRenderer()),
|
||||||
screen_(Screen::get()),
|
screen_(Screen::get()),
|
||||||
input_(Input::get()),
|
input_(Input::get()),
|
||||||
@@ -62,7 +63,7 @@ Game::Game(Player::Id player_id, int current_stage, bool demo)
|
|||||||
tabe_(std::make_unique<Tabe>()),
|
tabe_(std::make_unique<Tabe>()),
|
||||||
hit_(Hit(Resource::get()->getTexture("hit.png"))) {
|
hit_(Hit(Resource::get()->getTexture("hit.png"))) {
|
||||||
// Pasa variables
|
// Pasa variables
|
||||||
demo_.enabled = demo;
|
demo_.enabled = demo_enabled;
|
||||||
|
|
||||||
// Otras variables
|
// Otras variables
|
||||||
Section::name = Section::Name::GAME;
|
Section::name = Section::Name::GAME;
|
||||||
@@ -83,7 +84,9 @@ Game::Game(Player::Id player_id, int current_stage, bool demo)
|
|||||||
fade_in_->setPostDuration(0);
|
fade_in_->setPostDuration(0);
|
||||||
fade_in_->setType(Fade::Type::RANDOM_SQUARE2);
|
fade_in_->setType(Fade::Type::RANDOM_SQUARE2);
|
||||||
fade_in_->setMode(Fade::Mode::IN);
|
fade_in_->setMode(Fade::Mode::IN);
|
||||||
|
#ifndef RECORDING
|
||||||
fade_in_->activate();
|
fade_in_->activate();
|
||||||
|
#endif
|
||||||
|
|
||||||
fade_out_->setColor(param.fade.color);
|
fade_out_->setColor(param.fade.color);
|
||||||
fade_out_->setPostDuration(param.fade.post_duration_ms);
|
fade_out_->setPostDuration(param.fade.post_duration_ms);
|
||||||
@@ -109,6 +112,9 @@ Game::Game(Player::Id player_id, int current_stage, bool demo)
|
|||||||
pause_manager_->setServiceMenuPause(is_active);
|
pause_manager_->setServiceMenuPause(is_active);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
#ifdef RECORDING
|
||||||
|
setState(State::PLAYING);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::~Game() {
|
Game::~Game() {
|
||||||
@@ -402,6 +408,7 @@ void Game::destroyAllItems() {
|
|||||||
|
|
||||||
// Comprueba la colisión entre el jugador y los globos activos
|
// Comprueba la colisión entre el jugador y los globos activos
|
||||||
auto Game::checkPlayerBalloonCollision(std::shared_ptr<Player>& player) -> std::shared_ptr<Balloon> {
|
auto Game::checkPlayerBalloonCollision(std::shared_ptr<Player>& player) -> std::shared_ptr<Balloon> {
|
||||||
|
#ifndef RECORDING
|
||||||
for (auto& balloon : balloon_manager_->getBalloons()) {
|
for (auto& balloon : balloon_manager_->getBalloons()) {
|
||||||
if (!balloon->isInvulnerable() && !balloon->isPowerBall()) {
|
if (!balloon->isInvulnerable() && !balloon->isPowerBall()) {
|
||||||
if (checkCollision(player->getCollider(), balloon->getCollider())) {
|
if (checkCollision(player->getCollider(), balloon->getCollider())) {
|
||||||
@@ -409,6 +416,7 @@ auto Game::checkPlayerBalloonCollision(std::shared_ptr<Player> &player) -> std::
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return nullptr; // No se ha producido ninguna colisión
|
return nullptr; // No se ha producido ninguna colisión
|
||||||
}
|
}
|
||||||
@@ -778,8 +786,8 @@ void Game::throwCoffee(int x, int y) {
|
|||||||
|
|
||||||
smart_sprites_.back()->setPosX(x - 8);
|
smart_sprites_.back()->setPosX(x - 8);
|
||||||
smart_sprites_.back()->setPosY(y - 8);
|
smart_sprites_.back()->setPosY(y - 8);
|
||||||
smart_sprites_.back()->setWidth(param.game.item_size);
|
smart_sprites_.back()->setWidth(Item::WIDTH);
|
||||||
smart_sprites_.back()->setHeight(param.game.item_size);
|
smart_sprites_.back()->setHeight(Item::HEIGHT);
|
||||||
smart_sprites_.back()->setVelX((-1.0F + ((rand() % 5) * 0.5F)) * 60.0f); // Convertir a pixels/segundo
|
smart_sprites_.back()->setVelX((-1.0F + ((rand() % 5) * 0.5F)) * 60.0f); // Convertir a pixels/segundo
|
||||||
smart_sprites_.back()->setVelY(-4.0F * 60.0f); // Convertir a pixels/segundo
|
smart_sprites_.back()->setVelY(-4.0F * 60.0f); // Convertir a pixels/segundo
|
||||||
smart_sprites_.back()->setAccelX(0.0F);
|
smart_sprites_.back()->setAccelX(0.0F);
|
||||||
@@ -788,10 +796,9 @@ void Game::throwCoffee(int x, int y) {
|
|||||||
smart_sprites_.back()->setDestY(param.game.height + 1);
|
smart_sprites_.back()->setDestY(param.game.height + 1);
|
||||||
smart_sprites_.back()->setEnabled(true);
|
smart_sprites_.back()->setEnabled(true);
|
||||||
smart_sprites_.back()->setFinishedDelay(0.0F);
|
smart_sprites_.back()->setFinishedDelay(0.0F);
|
||||||
smart_sprites_.back()->setSpriteClip(0, param.game.item_size, param.game.item_size, param.game.item_size);
|
smart_sprites_.back()->setSpriteClip(0, Item::HEIGHT, Item::WIDTH, Item::HEIGHT);
|
||||||
smart_sprites_.back()->setRotatingCenter({param.game.item_size / 2, param.game.item_size / 2});
|
smart_sprites_.back()->setRotatingCenter({Item::WIDTH / 2, Item::HEIGHT / 2});
|
||||||
smart_sprites_.back()->setRotate(true);
|
smart_sprites_.back()->setRotate(true);
|
||||||
smart_sprites_.back()->setRotateSpeed(10);
|
|
||||||
smart_sprites_.back()->setRotateAmount(90.0);
|
smart_sprites_.back()->setRotateAmount(90.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -909,9 +916,9 @@ void Game::update(float deltaTime) {
|
|||||||
screen_->update(deltaTime); // Actualiza el objeto screen
|
screen_->update(deltaTime); // Actualiza el objeto screen
|
||||||
Audio::update(); // Actualiza el objeto audio
|
Audio::update(); // Actualiza el objeto audio
|
||||||
|
|
||||||
updateDemo();
|
updateDemo(deltaTime);
|
||||||
#ifdef RECORDING
|
#ifdef RECORDING
|
||||||
updateRecording();
|
updateRecording(deltaTime);
|
||||||
#endif
|
#endif
|
||||||
updateGameStates(deltaTime);
|
updateGameStates(deltaTime);
|
||||||
fillCanvas();
|
fillCanvas();
|
||||||
@@ -1012,10 +1019,8 @@ void Game::run() {
|
|||||||
last_time_ = SDL_GetTicks();
|
last_time_ = SDL_GetTicks();
|
||||||
|
|
||||||
while (Section::name == Section::Name::GAME) {
|
while (Section::name == Section::Name::GAME) {
|
||||||
#ifndef RECORDING
|
|
||||||
checkInput();
|
|
||||||
#endif
|
|
||||||
const float delta_time = calculateDeltaTime();
|
const float delta_time = calculateDeltaTime();
|
||||||
|
checkInput();
|
||||||
update(delta_time);
|
update(delta_time);
|
||||||
handleEvents(); // Tiene que ir antes del render
|
handleEvents(); // Tiene que ir antes del render
|
||||||
render();
|
render();
|
||||||
@@ -1287,19 +1292,16 @@ void Game::demoHandlePassInput() {
|
|||||||
|
|
||||||
// Gestiona las entradas de los jugadores en el modo demo, incluyendo movimientos y disparos automáticos.
|
// Gestiona las entradas de los jugadores en el modo demo, incluyendo movimientos y disparos automáticos.
|
||||||
void Game::demoHandleInput() {
|
void Game::demoHandleInput() {
|
||||||
int index = 0;
|
|
||||||
for (const auto& player : players_) {
|
for (const auto& player : players_) {
|
||||||
if (player->isPlaying()) {
|
if (player->isPlaying()) {
|
||||||
// Maneja el input específico del jugador en modo demo.
|
demoHandlePlayerInput(player, player->getDemoFile()); // Maneja el input específico del jugador en modo demo.
|
||||||
demoHandlePlayerInput(player, index);
|
|
||||||
}
|
}
|
||||||
++index;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Procesa las entradas para un jugador específico durante el modo demo.
|
// Procesa las entradas para un jugador específico durante el modo demo.
|
||||||
void Game::demoHandlePlayerInput(const std::shared_ptr<Player>& player, int index) {
|
void Game::demoHandlePlayerInput(const std::shared_ptr<Player>& player, int index) {
|
||||||
const auto &demo_data = demo_.data.at(index).at(demo_.counter);
|
const auto& demo_data = demo_.data.at(index).at(demo_.index);
|
||||||
|
|
||||||
if (demo_data.left == 1) {
|
if (demo_data.left == 1) {
|
||||||
player->setInput(Input::Action::LEFT);
|
player->setInput(Input::Action::LEFT);
|
||||||
@@ -1514,21 +1516,43 @@ void Game::handleNameInput(const std::shared_ptr<Player> &player) {
|
|||||||
|
|
||||||
// Inicializa las variables para el modo DEMO
|
// Inicializa las variables para el modo DEMO
|
||||||
void Game::initDemo(Player::Id player_id) {
|
void Game::initDemo(Player::Id player_id) {
|
||||||
|
#ifdef RECORDING
|
||||||
|
// En modo grabación, inicializar vector vacío para almacenar teclas
|
||||||
|
demo_.data.emplace_back(); // Vector vacío para grabación
|
||||||
|
demo_.data.at(0).reserve(TOTAL_DEMO_DATA); // Reservar espacio para 2000 elementos
|
||||||
|
#endif
|
||||||
|
|
||||||
if (demo_.enabled) {
|
if (demo_.enabled) {
|
||||||
// Cambia el estado del juego
|
// Cambia el estado del juego
|
||||||
setState(State::PLAYING);
|
setState(State::PLAYING);
|
||||||
|
|
||||||
// Aleatoriza la asignación del fichero con los datos del modo demostracion
|
#ifndef RECORDING
|
||||||
const auto DEMO1 = rand() % 2;
|
// En modo juego: cargar todas las demos y asignar una diferente a cada jugador
|
||||||
const auto DEMO2 = (DEMO1 == 0) ? 1 : 0;
|
auto const NUM_DEMOS = Asset::get()->getListByType(Asset::Type::DEMODATA).size();
|
||||||
demo_.data.emplace_back(Resource::get()->getDemoData(DEMO1));
|
for (size_t num_demo = 0; num_demo < NUM_DEMOS; ++num_demo) {
|
||||||
demo_.data.emplace_back(Resource::get()->getDemoData(DEMO2));
|
demo_.data.emplace_back(Resource::get()->getDemoData(num_demo));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crear índices mezclados para asignación aleatoria
|
||||||
|
std::vector<size_t> demo_indices(NUM_DEMOS);
|
||||||
|
std::iota(demo_indices.begin(), demo_indices.end(), 0);
|
||||||
|
std::random_device rd;
|
||||||
|
std::default_random_engine rng(rd());
|
||||||
|
std::shuffle(demo_indices.begin(), demo_indices.end(), rng);
|
||||||
|
|
||||||
|
// Asignar demos a jugadores (round-robin si hay más jugadores que demos)
|
||||||
|
for (size_t i = 0; i < players_.size(); ++i) {
|
||||||
|
size_t demo_index = demo_indices[i % NUM_DEMOS];
|
||||||
|
players_.at(i)->setDemoFile(demo_index);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Selecciona una pantalla al azar
|
// Selecciona una pantalla al azar
|
||||||
constexpr auto NUM_DEMOS = 3;
|
constexpr auto NUM_STAGES = 3;
|
||||||
const auto DEMO = rand() % NUM_DEMOS;
|
const auto STAGE = rand() % NUM_STAGES;
|
||||||
constexpr std::array<int, NUM_DEMOS> STAGES = {0, 3, 5};
|
constexpr std::array<float, NUM_STAGES> STAGES = {0.005F, 0.32F, 0.53F};
|
||||||
stage_manager_->jumpToStage(STAGES.at(DEMO));
|
stage_manager_->setTotalPower(stage_manager_->getTotalPowerNeededToCompleteGame() * STAGES.at(STAGE));
|
||||||
|
background_->setProgress(stage_manager_->getTotalPower());
|
||||||
|
|
||||||
// Activa o no al otro jugador
|
// Activa o no al otro jugador
|
||||||
if (rand() % 3 != 0) {
|
if (rand() % 3 != 0) {
|
||||||
@@ -1562,7 +1586,7 @@ void Game::initDemo(Player::Id player_id) {
|
|||||||
#else
|
#else
|
||||||
demo_.recording = false;
|
demo_.recording = false;
|
||||||
#endif
|
#endif
|
||||||
demo_.counter = 0;
|
demo_.index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa el marcador
|
// Inicializa el marcador
|
||||||
@@ -1617,7 +1641,11 @@ void Game::initPlayers(Player::Id player_id) {
|
|||||||
// Crea al jugador uno y lo pone en modo espera
|
// Crea al jugador uno y lo pone en modo espera
|
||||||
Player::Config config_player1{
|
Player::Config config_player1{
|
||||||
.id = Player::Id::PLAYER1,
|
.id = Player::Id::PLAYER1,
|
||||||
|
#ifdef RECORDING
|
||||||
|
.x = param.game.play_area.center_x - (Player::WIDTH / 2),
|
||||||
|
#else
|
||||||
.x = param.game.play_area.first_quarter_x - (Player::WIDTH / 2),
|
.x = param.game.play_area.first_quarter_x - (Player::WIDTH / 2),
|
||||||
|
#endif
|
||||||
.y = Y,
|
.y = Y,
|
||||||
.demo = demo_.enabled,
|
.demo = demo_.enabled,
|
||||||
.play_area = ¶m.game.play_area.rect,
|
.play_area = ¶m.game.play_area.rect,
|
||||||
@@ -1634,7 +1662,11 @@ void Game::initPlayers(Player::Id player_id) {
|
|||||||
player1->setName(Lang::getText("[SCOREBOARD] 1"));
|
player1->setName(Lang::getText("[SCOREBOARD] 1"));
|
||||||
player1->setGamepad(Options::gamepad_manager.getGamepad(Player::Id::PLAYER1).instance);
|
player1->setGamepad(Options::gamepad_manager.getGamepad(Player::Id::PLAYER1).instance);
|
||||||
player1->setUsesKeyboard(Player::Id::PLAYER1 == Options::keyboard.player_id);
|
player1->setUsesKeyboard(Player::Id::PLAYER1 == Options::keyboard.player_id);
|
||||||
|
#ifdef RECORDING
|
||||||
|
player1->setPlayingState(Player::State::PLAYING);
|
||||||
|
#else
|
||||||
player1->setPlayingState((player_id == Player::Id::BOTH_PLAYERS || player_id == Player::Id::PLAYER1) ? STATE : Player::State::WAITING);
|
player1->setPlayingState((player_id == Player::Id::BOTH_PLAYERS || player_id == Player::Id::PLAYER1) ? STATE : Player::State::WAITING);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Crea al jugador dos y lo pone en modo espera
|
// Crea al jugador dos y lo pone en modo espera
|
||||||
Player::Config config_player2{
|
Player::Config config_player2{
|
||||||
@@ -1692,7 +1724,7 @@ void Game::stopMusic() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las variables durante el modo demo
|
// Actualiza las variables durante el modo demo
|
||||||
void Game::updateDemo() {
|
void Game::updateDemo(float deltaTime) {
|
||||||
if (demo_.enabled) {
|
if (demo_.enabled) {
|
||||||
balloon_manager_->setCreationTimeEnabled(balloon_manager_->getNumBalloons() != 0);
|
balloon_manager_->setCreationTimeEnabled(balloon_manager_->getNumBalloons() != 0);
|
||||||
|
|
||||||
@@ -1700,16 +1732,12 @@ void Game::updateDemo() {
|
|||||||
fade_in_->update();
|
fade_in_->update();
|
||||||
fade_out_->update();
|
fade_out_->update();
|
||||||
|
|
||||||
// Incrementa el contador de la demo cada 1/60 segundos (16.67ms)
|
// Actualiza el contador de tiempo y el índice
|
||||||
static float demo_frame_timer = 0.0f;
|
demo_.elapsed_s += deltaTime;
|
||||||
demo_frame_timer += calculateDeltaTime();
|
demo_.index = static_cast<int>(demo_.elapsed_s * 60.0F);
|
||||||
if (demo_frame_timer >= 0.01667f && demo_.counter < TOTAL_DEMO_DATA) {
|
|
||||||
demo_.counter++;
|
|
||||||
demo_frame_timer -= 0.01667f; // Mantener precisión acumulada
|
|
||||||
}
|
|
||||||
|
|
||||||
// Activa el fundido antes de acabar con los datos de la demo
|
// Activa el fundido antes de acabar con los datos de la demo
|
||||||
if (demo_.counter == TOTAL_DEMO_DATA - 200) {
|
if (demo_.index == TOTAL_DEMO_DATA - 200) {
|
||||||
fade_out_->setType(Fade::Type::RANDOM_SQUARE2);
|
fade_out_->setType(Fade::Type::RANDOM_SQUARE2);
|
||||||
fade_out_->setPostDuration(param.fade.post_duration_ms);
|
fade_out_->setPostDuration(param.fade.post_duration_ms);
|
||||||
fade_out_->activate();
|
fade_out_->activate();
|
||||||
@@ -1725,22 +1753,28 @@ void Game::updateDemo() {
|
|||||||
|
|
||||||
#ifdef RECORDING
|
#ifdef RECORDING
|
||||||
// Actualiza las variables durante el modo de grabación
|
// Actualiza las variables durante el modo de grabación
|
||||||
void Game::updateRecording() {
|
void Game::updateRecording(float deltaTime) {
|
||||||
// Solo mira y guarda el input en cada update
|
// Actualiza el contador de tiempo y el índice
|
||||||
checkInput();
|
demo_.elapsed_s += deltaTime;
|
||||||
|
demo_.index = static_cast<int>(demo_.elapsed_s * 60.0F);
|
||||||
|
|
||||||
// Incrementa el contador de la demo cada 1/60 segundos (16.67ms)
|
if (demo_.index >= TOTAL_DEMO_DATA) {
|
||||||
static float recording_frame_timer = 0.0f;
|
Section::name = Section::Name::QUIT;
|
||||||
recording_frame_timer += calculateDeltaTime();
|
return;
|
||||||
if (recording_frame_timer >= 0.01667f && demo_.counter < TOTAL_DEMO_DATA) {
|
|
||||||
demo_.counter++;
|
|
||||||
recording_frame_timer -= 0.01667f; // Mantener precisión acumulada
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si se ha llenado el vector con datos, sale del programa
|
// Almacenar las teclas del frame actual en el vector de grabación
|
||||||
else {
|
if (demo_.index < TOTAL_DEMO_DATA && demo_.data.size() > 0) {
|
||||||
section::name = section::Name::QUIT;
|
// Asegurar que el vector tenga el tamaño suficiente
|
||||||
return;
|
if (demo_.data.at(0).size() <= static_cast<size_t>(demo_.index)) {
|
||||||
|
demo_.data.at(0).resize(demo_.index + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Almacenar las teclas del frame actual
|
||||||
|
demo_.data.at(0).at(demo_.index) = demo_.keys;
|
||||||
|
|
||||||
|
// Resetear las teclas para el siguiente frame
|
||||||
|
demo_.keys = DemoKeys();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
#include "player.h" // Para Player
|
#include "player.h" // Para Player
|
||||||
#include "smart_sprite.h" // Para SmartSprite
|
#include "smart_sprite.h" // Para SmartSprite
|
||||||
#include "stage.h" // Para StageManager
|
#include "stage.h" // Para StageManager
|
||||||
#include "utils.h" // Para Demo
|
#include "demo.h" // Para Demo
|
||||||
|
#include "utils.h" // Para otras utilidades
|
||||||
|
|
||||||
class Background;
|
class Background;
|
||||||
class Balloon;
|
class Balloon;
|
||||||
@@ -56,7 +57,7 @@ class Game {
|
|||||||
static constexpr bool DEMO_ON = true; // Modo demo activado
|
static constexpr bool DEMO_ON = true; // Modo demo activado
|
||||||
|
|
||||||
// --- Constructor y destructor ---
|
// --- Constructor y destructor ---
|
||||||
Game(Player::Id player_id, int current_stage, bool demo); // Constructor principal
|
Game(Player::Id player_id, int current_stage, bool demo_enabled); // Constructor principal
|
||||||
~Game(); // Destructor
|
~Game(); // Destructor
|
||||||
|
|
||||||
// --- Bucle principal ---
|
// --- Bucle principal ---
|
||||||
@@ -325,7 +326,7 @@ class Game {
|
|||||||
|
|
||||||
// --- Modo demostración ---
|
// --- Modo demostración ---
|
||||||
void initDemo(Player::Id player_id); // Inicializa variables para el modo demostración
|
void initDemo(Player::Id player_id); // Inicializa variables para el modo demostración
|
||||||
void updateDemo(); // Actualiza lógica específica del modo demo
|
void updateDemo(float deltaTime); // Actualiza lógica específica del modo demo
|
||||||
|
|
||||||
// --- Recursos y renderizado ---
|
// --- Recursos y renderizado ---
|
||||||
void setResources(); // Asigna texturas y animaciones a los objetos
|
void setResources(); // Asigna texturas y animaciones a los objetos
|
||||||
@@ -346,7 +347,7 @@ class Game {
|
|||||||
|
|
||||||
// SISTEMA DE GRABACIÓN (CONDICIONAL)
|
// SISTEMA DE GRABACIÓN (CONDICIONAL)
|
||||||
#ifdef RECORDING
|
#ifdef RECORDING
|
||||||
void updateRecording(); // Actualiza variables durante modo de grabación
|
void updateRecording(float deltaTime); // Actualiza variables durante modo de grabación
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// --- Depuración (solo en modo DEBUG) ---
|
// --- Depuración (solo en modo DEBUG) ---
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "global_events.h" // Para check
|
#include "global_events.h" // Para check
|
||||||
#include "global_inputs.h" // Para check
|
#include "global_inputs.h" // Para check
|
||||||
#include "input.h" // Para Input
|
#include "input.h" // Para Input
|
||||||
|
#include "item.h" // Para Item
|
||||||
#include "lang.h" // Para getText
|
#include "lang.h" // Para getText
|
||||||
#include "param.h" // Para Param, param, ParamGame, ParamFade, Param...
|
#include "param.h" // Para Param, param, ParamGame, ParamFade, Param...
|
||||||
#include "resource.h" // Para Resource
|
#include "resource.h" // Para Resource
|
||||||
@@ -78,40 +79,40 @@ void Instructions::iniSprites() {
|
|||||||
|
|
||||||
// Inicializa los sprites
|
// Inicializa los sprites
|
||||||
for (int i = 0; i < (int)item_textures_.size(); ++i) {
|
for (int i = 0; i < (int)item_textures_.size(); ++i) {
|
||||||
auto sprite = std::make_unique<Sprite>(item_textures_[i], 0, 0, param.game.item_size, param.game.item_size);
|
auto sprite = std::make_unique<Sprite>(item_textures_[i], 0, 0, Item::WIDTH, Item::HEIGHT);
|
||||||
sprite->setPosition((SDL_FPoint){sprite_pos_.x, sprite_pos_.y + ((param.game.item_size + item_space_) * i)});
|
sprite->setPosition((SDL_FPoint){sprite_pos_.x, sprite_pos_.y + ((Item::HEIGHT + item_space_) * i)});
|
||||||
sprites_.push_back(std::move(sprite));
|
sprites_.push_back(std::move(sprite));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza los sprites
|
// Actualiza los sprites
|
||||||
void Instructions::updateSprites() {
|
void Instructions::updateSprites() {
|
||||||
SDL_FRect src_rect = {0, 0, param.game.item_size, param.game.item_size};
|
SDL_FRect src_rect = {0, 0, Item::WIDTH, Item::HEIGHT};
|
||||||
|
|
||||||
// Disquito (desplazamiento 12/60 = 0.2s)
|
// Disquito (desplazamiento 12/60 = 0.2s)
|
||||||
src_rect.y = param.game.item_size * (static_cast<int>((elapsed_time_ + 0.2f) / SPRITE_ANIMATION_CYCLE_S) % 2);
|
src_rect.y = Item::HEIGHT * (static_cast<int>((elapsed_time_ + 0.2f) / SPRITE_ANIMATION_CYCLE_S) % 2);
|
||||||
sprites_[0]->setSpriteClip(src_rect);
|
sprites_[0]->setSpriteClip(src_rect);
|
||||||
|
|
||||||
// Gavina (desplazamiento 9/60 = 0.15s)
|
// Gavina (desplazamiento 9/60 = 0.15s)
|
||||||
src_rect.y = param.game.item_size * (static_cast<int>((elapsed_time_ + 0.15f) / SPRITE_ANIMATION_CYCLE_S) % 2);
|
src_rect.y = Item::HEIGHT * (static_cast<int>((elapsed_time_ + 0.15f) / SPRITE_ANIMATION_CYCLE_S) % 2);
|
||||||
sprites_[1]->setSpriteClip(src_rect);
|
sprites_[1]->setSpriteClip(src_rect);
|
||||||
|
|
||||||
// Pacmar (desplazamiento 6/60 = 0.1s)
|
// Pacmar (desplazamiento 6/60 = 0.1s)
|
||||||
src_rect.y = param.game.item_size * (static_cast<int>((elapsed_time_ + 0.1f) / SPRITE_ANIMATION_CYCLE_S) % 2);
|
src_rect.y = Item::HEIGHT * (static_cast<int>((elapsed_time_ + 0.1f) / SPRITE_ANIMATION_CYCLE_S) % 2);
|
||||||
sprites_[2]->setSpriteClip(src_rect);
|
sprites_[2]->setSpriteClip(src_rect);
|
||||||
|
|
||||||
// Time Stopper (desplazamiento 3/60 = 0.05s)
|
// Time Stopper (desplazamiento 3/60 = 0.05s)
|
||||||
src_rect.y = param.game.item_size * (static_cast<int>((elapsed_time_ + 0.05f) / SPRITE_ANIMATION_CYCLE_S) % 2);
|
src_rect.y = Item::HEIGHT * (static_cast<int>((elapsed_time_ + 0.05f) / SPRITE_ANIMATION_CYCLE_S) % 2);
|
||||||
sprites_[3]->setSpriteClip(src_rect);
|
sprites_[3]->setSpriteClip(src_rect);
|
||||||
|
|
||||||
// Coffee (sin desplazamiento)
|
// Coffee (sin desplazamiento)
|
||||||
src_rect.y = param.game.item_size * (static_cast<int>(elapsed_time_ / SPRITE_ANIMATION_CYCLE_S) % 2);
|
src_rect.y = Item::HEIGHT * (static_cast<int>(elapsed_time_ / SPRITE_ANIMATION_CYCLE_S) % 2);
|
||||||
sprites_[4]->setSpriteClip(src_rect);
|
sprites_[4]->setSpriteClip(src_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rellena la textura de texto
|
// Rellena la textura de texto
|
||||||
void Instructions::fillTexture() {
|
void Instructions::fillTexture() {
|
||||||
const int X_OFFSET = param.game.item_size + 8;
|
const int X_OFFSET = Item::WIDTH + 8;
|
||||||
|
|
||||||
// Modifica el renderizador para pintar en la textura
|
// Modifica el renderizador para pintar en la textura
|
||||||
auto* temp = SDL_GetRenderTarget(renderer_);
|
auto* temp = SDL_GetRenderTarget(renderer_);
|
||||||
@@ -130,7 +131,7 @@ void Instructions::fillTexture() {
|
|||||||
constexpr int SPACE_POST_HEADER = 20;
|
constexpr int SPACE_POST_HEADER = 20;
|
||||||
constexpr int SPACE_PRE_HEADER = 28;
|
constexpr int SPACE_PRE_HEADER = 28;
|
||||||
const int SPACE_BETWEEN_LINES = text_->getCharacterSize() * 1.5F;
|
const int SPACE_BETWEEN_LINES = text_->getCharacterSize() * 1.5F;
|
||||||
const int SPACE_BETWEEN_ITEM_LINES = param.game.item_size + item_space_;
|
const int SPACE_BETWEEN_ITEM_LINES = Item::HEIGHT + item_space_;
|
||||||
const int SPACE_NEW_PARAGRAPH = SPACE_BETWEEN_LINES * 0.5F;
|
const int SPACE_NEW_PARAGRAPH = SPACE_BETWEEN_LINES * 0.5F;
|
||||||
|
|
||||||
const int SIZE = (NUM_LINES * SPACE_BETWEEN_LINES) + (NUM_ITEM_LINES * SPACE_BETWEEN_ITEM_LINES) + (NUM_POST_HEADERS * SPACE_POST_HEADER) + (NUM_PRE_HEADERS * SPACE_PRE_HEADER) + (SPACE_NEW_PARAGRAPH);
|
const int SIZE = (NUM_LINES * SPACE_BETWEEN_LINES) + (NUM_ITEM_LINES * SPACE_BETWEEN_ITEM_LINES) + (NUM_POST_HEADERS * SPACE_POST_HEADER) + (NUM_PRE_HEADERS * SPACE_PRE_HEADER) + (SPACE_NEW_PARAGRAPH);
|
||||||
@@ -178,7 +179,7 @@ void Instructions::fillTexture() {
|
|||||||
|
|
||||||
// Da valor a la variable
|
// Da valor a la variable
|
||||||
sprite_pos_.x = ANCHOR_ITEM;
|
sprite_pos_.x = ANCHOR_ITEM;
|
||||||
sprite_pos_.y = ANCHOR3 - ((param.game.item_size - text_->getCharacterSize()) / 2);
|
sprite_pos_.y = ANCHOR3 - ((Item::HEIGHT - text_->getCharacterSize()) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rellena el backbuffer
|
// Rellena el backbuffer
|
||||||
|
|||||||
@@ -151,6 +151,51 @@ auto StageManager::jumpToStage(size_t target_stage_index) -> bool {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto StageManager::setTotalPower(int target_total_power) -> bool {
|
||||||
|
if (target_total_power < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int total_power_needed = getTotalPowerNeededToCompleteGame();
|
||||||
|
if (target_total_power > total_power_needed) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calcular en qué fase debería estar y cuánto poder de esa fase
|
||||||
|
int accumulated_power = 0;
|
||||||
|
size_t target_stage_index = 0;
|
||||||
|
int target_current_power = 0;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < stages_.size(); ++i) {
|
||||||
|
int stage_power = stages_[i].getPowerToComplete();
|
||||||
|
|
||||||
|
if (accumulated_power + stage_power > target_total_power) {
|
||||||
|
// El objetivo está dentro de esta fase
|
||||||
|
target_stage_index = i;
|
||||||
|
target_current_power = target_total_power - accumulated_power;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
accumulated_power += stage_power;
|
||||||
|
|
||||||
|
if (accumulated_power == target_total_power) {
|
||||||
|
// El objetivo coincide exactamente con el final de esta fase
|
||||||
|
// Mover a la siguiente fase (si existe) con power 0
|
||||||
|
target_stage_index = (i + 1 < stages_.size()) ? i + 1 : i;
|
||||||
|
target_current_power = (i + 1 < stages_.size()) ? 0 : stage_power;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualizar estado
|
||||||
|
current_stage_index_ = target_stage_index;
|
||||||
|
current_power_ = target_current_power;
|
||||||
|
total_power_ = target_total_power;
|
||||||
|
|
||||||
|
updateStageStatuses();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
auto StageManager::subtractPower(int amount) -> bool {
|
auto StageManager::subtractPower(int amount) -> bool {
|
||||||
if (amount <= 0 || current_power_ < amount) {
|
if (amount <= 0 || current_power_ < amount) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ class StageManager : public IStageInfo {
|
|||||||
|
|
||||||
// --- Navegación ---
|
// --- Navegación ---
|
||||||
auto jumpToStage(size_t target_stage_index) -> bool; // Salta a una fase específica
|
auto jumpToStage(size_t target_stage_index) -> bool; // Salta a una fase específica
|
||||||
|
auto setTotalPower(int target_total_power) -> bool; // Establece el poder total y ajusta fase/progreso
|
||||||
|
|
||||||
// --- Consultas de estado ---
|
// --- Consultas de estado ---
|
||||||
[[nodiscard]] auto getCurrentStage() const -> std::optional<StageData>; // Obtiene la fase actual
|
[[nodiscard]] auto getCurrentStage() const -> std::optional<StageData>; // Obtiene la fase actual
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ Texture::Texture(SDL_Renderer *renderer, std::string path)
|
|||||||
surface_ = loadSurface(path_);
|
surface_ = loadSurface(path_);
|
||||||
|
|
||||||
// Añade la propia paleta del fichero a la lista
|
// Añade la propia paleta del fichero a la lista
|
||||||
addPaletteFromGifFile(path_);
|
addPaletteFromGifFile(path_, true); // Usar modo silencioso
|
||||||
|
|
||||||
// Crea la textura, establece el BlendMode y copia la surface a la textura
|
// Crea la textura, establece el BlendMode y copia la surface a la textura
|
||||||
createBlank(width_, height_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING);
|
createBlank(width_, height_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING);
|
||||||
@@ -301,7 +301,7 @@ void Texture::setPaletteColor(int palette, int index, Uint32 color) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carga una paleta desde un fichero
|
// Carga una paleta desde un fichero
|
||||||
auto Texture::loadPaletteFromFile(const std::string &file_path) -> Palette {
|
auto Texture::loadPaletteFromFile(const std::string &file_path, bool quiet) -> Palette {
|
||||||
Palette palette;
|
Palette palette;
|
||||||
|
|
||||||
std::vector<Uint8> buffer;
|
std::vector<Uint8> buffer;
|
||||||
@@ -329,7 +329,9 @@ auto Texture::loadPaletteFromFile(const std::string &file_path) -> Palette {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!quiet) {
|
||||||
printWithDots("Palette : ", getFileName(file_path), "[ LOADED ]");
|
printWithDots("Palette : ", getFileName(file_path), "[ LOADED ]");
|
||||||
|
}
|
||||||
|
|
||||||
// Usar la nueva función loadPalette, que devuelve un vector<uint32_t>
|
// Usar la nueva función loadPalette, que devuelve un vector<uint32_t>
|
||||||
GIF::Gif gif;
|
GIF::Gif gif;
|
||||||
@@ -349,14 +351,14 @@ auto Texture::loadPaletteFromFile(const std::string &file_path) -> Palette {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Añade una paleta a la lista
|
// Añade una paleta a la lista
|
||||||
void Texture::addPaletteFromGifFile(const std::string &path) {
|
void Texture::addPaletteFromGifFile(const std::string &path, bool quiet) {
|
||||||
palettes_.emplace_back(loadPaletteFromFile(path));
|
palettes_.emplace_back(loadPaletteFromFile(path, quiet));
|
||||||
setPaletteColor(palettes_.size() - 1, 0, 0x00000000);
|
setPaletteColor(palettes_.size() - 1, 0, 0x00000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Añade una paleta a la lista
|
// Añade una paleta a la lista
|
||||||
void Texture::addPaletteFromPalFile(const std::string &path) {
|
void Texture::addPaletteFromPalFile(const std::string &path) {
|
||||||
palettes_.emplace_back(readPalFile(path));
|
palettes_.emplace_back(readPalFile(path, true)); // Usar modo silencioso
|
||||||
setPaletteColor(palettes_.size() - 1, 0, 0x00000000);
|
setPaletteColor(palettes_.size() - 1, 0, 0x00000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,7 +374,7 @@ void Texture::setPalette(size_t palette) {
|
|||||||
auto Texture::getRenderer() -> SDL_Renderer * { return renderer_; }
|
auto Texture::getRenderer() -> SDL_Renderer * { return renderer_; }
|
||||||
|
|
||||||
// Carga una paleta desde un archivo .pal
|
// Carga una paleta desde un archivo .pal
|
||||||
auto Texture::readPalFile(const std::string &file_path) -> Palette {
|
auto Texture::readPalFile(const std::string &file_path, bool quiet) -> Palette {
|
||||||
Palette palette{};
|
Palette palette{};
|
||||||
palette.fill(0); // Inicializar todo con 0 (transparente por defecto)
|
palette.fill(0); // Inicializar todo con 0 (transparente por defecto)
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class Texture {
|
|||||||
void setAlpha(Uint8 alpha); // Establece el alpha para la modulación
|
void setAlpha(Uint8 alpha); // Establece el alpha para la modulación
|
||||||
|
|
||||||
// --- Paletas ---
|
// --- Paletas ---
|
||||||
void addPaletteFromGifFile(const std::string &path); // Añade una paleta a la lista
|
void addPaletteFromGifFile(const std::string &path, bool quiet = false); // Añade una paleta a la lista
|
||||||
void addPaletteFromPalFile(const std::string &path); // Añade una paleta a la lista
|
void addPaletteFromPalFile(const std::string &path); // Añade una paleta a la lista
|
||||||
void setPaletteColor(int palette, int index, Uint32 color); // Establece un color de la paleta
|
void setPaletteColor(int palette, int index, Uint32 color); // Establece un color de la paleta
|
||||||
void setPalette(size_t palette); // Cambia la paleta de la textura
|
void setPalette(size_t palette); // Cambia la paleta de la textura
|
||||||
@@ -76,8 +76,8 @@ class Texture {
|
|||||||
// --- Métodos internos ---
|
// --- Métodos internos ---
|
||||||
auto loadSurface(const std::string &file_path) -> std::shared_ptr<Surface>; // Crea una surface desde un fichero .gif
|
auto loadSurface(const std::string &file_path) -> std::shared_ptr<Surface>; // Crea una surface desde un fichero .gif
|
||||||
void flipSurface(); // Vuelca la surface en la textura
|
void flipSurface(); // Vuelca la surface en la textura
|
||||||
static auto loadPaletteFromFile(const std::string &file_path) -> Palette; // Carga una paleta desde un fichero
|
static auto loadPaletteFromFile(const std::string &file_path, bool quiet = false) -> Palette; // Carga una paleta desde un fichero
|
||||||
void unloadTexture(); // Libera la memoria de la textura
|
void unloadTexture(); // Libera la memoria de la textura
|
||||||
void unloadSurface(); // Libera la surface actual
|
void unloadSurface(); // Libera la surface actual
|
||||||
static auto readPalFile(const std::string &file_path) -> Palette; // Carga una paleta desde un archivo .pal
|
static auto readPalFile(const std::string &file_path, bool quiet = false) -> Palette; // Carga una paleta desde un archivo .pal
|
||||||
};
|
};
|
||||||
@@ -320,68 +320,6 @@ void printWithDots(const std::string &text1, const std::string &text2, const std
|
|||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "%s", formatted_text.c_str());
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "%s", formatted_text.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carga el fichero de datos para la demo
|
|
||||||
auto loadDemoDataFromFile(const std::string &file_path) -> DemoData {
|
|
||||||
DemoData dd;
|
|
||||||
|
|
||||||
SDL_IOStream *file = nullptr;
|
|
||||||
|
|
||||||
// Intentar cargar desde ResourceHelper primero
|
|
||||||
auto resource_data = ResourceHelper::loadFile(file_path);
|
|
||||||
if (!resource_data.empty()) {
|
|
||||||
file = SDL_IOFromConstMem(resource_data.data(), resource_data.size());
|
|
||||||
} else {
|
|
||||||
// Fallback a filesystem directo
|
|
||||||
file = SDL_IOFromFile(file_path.c_str(), "r+b");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (file == nullptr) {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error: Fichero no encontrado %s", file_path.c_str());
|
|
||||||
throw std::runtime_error("Fichero no encontrado: " + file_path);
|
|
||||||
}
|
|
||||||
printWithDots("DemoData : ", getFileName(file_path), "[ LOADED ]");
|
|
||||||
|
|
||||||
// Lee todos los datos del fichero y los deja en el destino
|
|
||||||
for (int i = 0; i < TOTAL_DEMO_DATA; ++i) {
|
|
||||||
DemoKeys dk = DemoKeys();
|
|
||||||
SDL_ReadIO(file, &dk, sizeof(DemoKeys));
|
|
||||||
dd.push_back(dk);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cierra el fichero
|
|
||||||
SDL_CloseIO(file);
|
|
||||||
|
|
||||||
return dd;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef RECORDING
|
|
||||||
// Guarda el fichero de datos para la demo
|
|
||||||
bool saveDemoFile(const std::string &file_path, const DemoData &dd) {
|
|
||||||
auto success = true;
|
|
||||||
auto file = SDL_IOFromFile(file_path.c_str(), "w+b");
|
|
||||||
|
|
||||||
if (file) {
|
|
||||||
// Guarda los datos
|
|
||||||
for (const auto &data : dd) {
|
|
||||||
if (SDL_RWwrite(file, &data, sizeof(DemoKeys), 1) != 1) {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error al escribir el fichero %s", getFileName(file_path).c_str());
|
|
||||||
success = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (success) {
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Writing file %s", getFileName(file_path).c_str());
|
|
||||||
}
|
|
||||||
// Cierra el fichero
|
|
||||||
SDL_CloseIO(file);
|
|
||||||
} else {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error: Unable to save %s file! %s", getFileName(file_path).c_str(), SDL_GetError());
|
|
||||||
success = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
#endif // RECORDING
|
|
||||||
|
|
||||||
// Obtiene el nombre de un fichero a partir de una ruta completa
|
// Obtiene el nombre de un fichero a partir de una ruta completa
|
||||||
auto getFileName(const std::string &path) -> std::string {
|
auto getFileName(const std::string &path) -> std::string {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
// --- Constantes ---
|
// --- Constantes ---
|
||||||
constexpr int BLOCK = 8;
|
constexpr int BLOCK = 8;
|
||||||
constexpr int TOTAL_DEMO_DATA = 2000;
|
|
||||||
|
|
||||||
// --- Estructuras ---
|
// --- Estructuras ---
|
||||||
struct Overrides {
|
struct Overrides {
|
||||||
@@ -32,44 +31,6 @@ struct Circle {
|
|||||||
r(radius) {}
|
r(radius) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DemoKeys {
|
|
||||||
Uint8 left;
|
|
||||||
Uint8 right;
|
|
||||||
Uint8 no_input;
|
|
||||||
Uint8 fire;
|
|
||||||
Uint8 fire_left;
|
|
||||||
Uint8 fire_right;
|
|
||||||
|
|
||||||
explicit DemoKeys(Uint8 l = 0, Uint8 r = 0, Uint8 ni = 0, Uint8 f = 0, Uint8 fl = 0, Uint8 fr = 0)
|
|
||||||
: left(l),
|
|
||||||
right(r),
|
|
||||||
no_input(ni),
|
|
||||||
fire(f),
|
|
||||||
fire_left(fl),
|
|
||||||
fire_right(fr) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
// --- Tipos ---
|
|
||||||
using DemoData = std::vector<DemoKeys>;
|
|
||||||
|
|
||||||
struct Demo {
|
|
||||||
bool enabled; // Indica si está activo el modo demo
|
|
||||||
bool recording; // Indica si está activado el modo para grabar la demo
|
|
||||||
int counter; // Contador para el modo demo
|
|
||||||
DemoKeys keys; // Variable con las pulsaciones de teclas del modo demo
|
|
||||||
std::vector<DemoData> data; // Vector con diferentes sets de datos con los movimientos para la demo
|
|
||||||
|
|
||||||
Demo()
|
|
||||||
: enabled(false),
|
|
||||||
recording(false),
|
|
||||||
counter(0) {}
|
|
||||||
Demo(bool e, bool r, int c, const DemoKeys &k, const std::vector<DemoData> &d)
|
|
||||||
: enabled(e),
|
|
||||||
recording(r),
|
|
||||||
counter(c),
|
|
||||||
keys(k),
|
|
||||||
data(d) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Zone {
|
struct Zone {
|
||||||
SDL_FRect rect; // Rectangulo que define la zona
|
SDL_FRect rect; // Rectangulo que define la zona
|
||||||
@@ -127,12 +88,6 @@ auto stringInVector(const std::vector<std::string> &vec, const std::string &str)
|
|||||||
void printWithDots(const std::string& text1, const std::string& text2, const std::string& text3); // Imprime una línea con puntos
|
void printWithDots(const std::string& text1, const std::string& text2, const std::string& text3); // Imprime una línea con puntos
|
||||||
auto truncateWithEllipsis(const std::string& input, size_t length) -> std::string; // Trunca un string y le añade puntos suspensivos
|
auto truncateWithEllipsis(const std::string& input, size_t length) -> std::string; // Trunca un string y le añade puntos suspensivos
|
||||||
|
|
||||||
// Demo
|
|
||||||
auto loadDemoDataFromFile(const std::string &file_path) -> DemoData;
|
|
||||||
|
|
||||||
#ifdef RECORDING
|
|
||||||
bool saveDemoFile(const std::string &file_path, const DemoData &dd);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Ficheros y rutas
|
// Ficheros y rutas
|
||||||
auto getFileName(const std::string& path) -> std::string; // Obtiene el nombre de un fichero a partir de una ruta
|
auto getFileName(const std::string& path) -> std::string; // Obtiene el nombre de un fichero a partir de una ruta
|
||||||
|
|||||||
6
source/version.h.in
Normal file
6
source/version.h.in
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Version {
|
||||||
|
constexpr const char* GIT_HASH = "@GIT_HASH@";
|
||||||
|
constexpr const char* APP_NAME = "Coffee Crisis Arcade Edition";
|
||||||
|
}
|
||||||
Binary file not shown.
@@ -1,9 +1,10 @@
|
|||||||
#include "../source/resource_pack.h"
|
#include "../source/resource_pack.h"
|
||||||
|
#include "../build/version.h" // Para Version::APP_NAME
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
void showHelp() {
|
void showHelp() {
|
||||||
std::cout << "Coffee Crisis Arcade Edition - Resource Packer" << std::endl;
|
std::cout << Version::APP_NAME << " - Resource Packer" << std::endl;
|
||||||
std::cout << "===============================================" << std::endl;
|
std::cout << "===============================================" << std::endl;
|
||||||
std::cout << "Usage: pack_resources [options] [input_dir] [output_file]" << std::endl;
|
std::cout << "Usage: pack_resources [options] [input_dir] [output_file]" << std::endl;
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
@@ -71,7 +72,7 @@ int main(int argc, char* argv[]) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Coffee Crisis Arcade Edition - Resource Packer" << std::endl;
|
std::cout << Version::APP_NAME << " - Resource Packer" << std::endl;
|
||||||
std::cout << "===============================================" << std::endl;
|
std::cout << "===============================================" << std::endl;
|
||||||
std::cout << "Input directory: " << dataDir << std::endl;
|
std::cout << "Input directory: " << dataDir << std::endl;
|
||||||
std::cout << "Output file: " << outputFile << std::endl;
|
std::cout << "Output file: " << outputFile << std::endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user