afegit define NO_AUDIO
renombrat define DEBUG a _DEBUG
This commit is contained in:
@@ -83,7 +83,7 @@ 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_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
|
||||||
@@ -113,7 +113,10 @@ target_compile_options(${PROJECT_NAME} PRIVATE -Wall)
|
|||||||
target_compile_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:RELEASE>:-Os -ffunction-sections -fdata-sections>)
|
target_compile_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:RELEASE>:-Os -ffunction-sections -fdata-sections>)
|
||||||
|
|
||||||
# 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>)
|
||||||
|
|
||||||
|
# Definir NO_AUDIO en todas las configuraciones
|
||||||
|
target_compile_definitions(${PROJECT_NAME} PRIVATE NO_AUDIO)
|
||||||
|
|
||||||
# Configuración específica para cada plataforma
|
# Configuración específica para cada plataforma
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
|
|
||||||
#include <SDL3/SDL.h> // Para SDL_LogInfo, SDL_LogCategory, SDL_G...
|
#include <SDL3/SDL.h> // Para SDL_LogInfo, SDL_LogCategory, SDL_G...
|
||||||
|
|
||||||
#include <algorithm> // Para clamp
|
#include <algorithm> // Para clamp
|
||||||
|
|
||||||
|
#ifndef NO_AUDIO
|
||||||
#include "external/jail_audio.h" // Para JA_FadeOutMusic, JA_Init, JA_PauseM...
|
#include "external/jail_audio.h" // Para JA_FadeOutMusic, JA_Init, JA_PauseM...
|
||||||
|
#endif
|
||||||
#include "options.h" // Para AudioOptions, audio, MusicOptions
|
#include "options.h" // Para AudioOptions, audio, MusicOptions
|
||||||
#include "resource.h" // Para Resource
|
#include "resource.h" // Para Resource
|
||||||
|
|
||||||
@@ -23,7 +26,11 @@ auto Audio::get() -> Audio * { return Audio::instance; }
|
|||||||
Audio::Audio() { initSDLAudio(); }
|
Audio::Audio() { initSDLAudio(); }
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
Audio::~Audio() { JA_Quit(); }
|
Audio::~Audio() {
|
||||||
|
#ifndef NO_AUDIO
|
||||||
|
JA_Quit();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Reproduce la música
|
// Reproduce la música
|
||||||
void Audio::playMusic(const std::string &name, const int loop) {
|
void Audio::playMusic(const std::string &name, const int loop) {
|
||||||
@@ -31,7 +38,9 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,7 +48,9 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,7 +58,9 @@ void Audio::pauseMusic() {
|
|||||||
// 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,21 +68,27 @@ 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_) {
|
if (music_enabled_) {
|
||||||
|
#ifndef NO_AUDIO
|
||||||
JA_FadeOutMusic(milliseconds);
|
JA_FadeOutMusic(milliseconds);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,8 +96,10 @@ void Audio::fadeOutMusic(int milliseconds) const {
|
|||||||
void Audio::setSoundVolume(int sound_volume, Group group) const {
|
void Audio::setSoundVolume(int sound_volume, Group group) const {
|
||||||
if (sound_enabled_) {
|
if (sound_enabled_) {
|
||||||
sound_volume = std::clamp(sound_volume, MIN_VOLUME, MAX_VOLUME);
|
sound_volume = std::clamp(sound_volume, MIN_VOLUME, MAX_VOLUME);
|
||||||
|
#ifndef NO_AUDIO
|
||||||
const float CONVERTED_VOLUME = (sound_volume / 100.0F) * (Options::audio.volume / 100.0F);
|
const float CONVERTED_VOLUME = (sound_volume / 100.0F) * (Options::audio.volume / 100.0F);
|
||||||
JA_SetSoundVolume(CONVERTED_VOLUME, static_cast<int>(group));
|
JA_SetSoundVolume(CONVERTED_VOLUME, static_cast<int>(group));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,8 +107,10 @@ 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,14 +129,16 @@ 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 {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_TEST, "\n** SDL_AUDIO: INITIALIZING\n");
|
|
||||||
|
|
||||||
JA_Init(FREQUENCY, SDL_AUDIO_S16LE, 2);
|
JA_Init(FREQUENCY, SDL_AUDIO_S16LE, 2);
|
||||||
enable(Options::audio.enabled);
|
enable(Options::audio.enabled);
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_TEST, "** SDL_AUDIO: INITIALIZATION COMPLETE\n");
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "** Audio system initialized successfully");
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "** Audio system disabled");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <SDL3/SDL.h> // Para SDL_Scancode, SDL_GamepadButton, SDL_LogCategory, SDL_LogInfo, SDL_SetLogPriority, SDL_LogPriority, SDL_Quit
|
#include <SDL3/SDL.h> // Para SDL_Scancode, SDL_GamepadButton, SDL_LogCategory, SDL_LogInfo, SDL_SetLogPriority, SDL_LogPriority, SDL_Quit
|
||||||
#include <sys/stat.h> // Para mkdir, stat, S_IRWXU
|
#include <sys/stat.h> // Para mkdir, stat, S_IRWXU
|
||||||
#include <unistd.h> // Para getuid
|
#include <unistd.h> // Para getuid
|
||||||
|
|
||||||
#include <algorithm> // Para min
|
#include <algorithm> // Para min
|
||||||
#include <cerrno> // Para errno, EEXIST, EACCES, ENAMETOOLONG
|
#include <cerrno> // Para errno, EEXIST, EACCES, ENAMETOOLONG
|
||||||
#include <cstdio> // Para printf, perror
|
#include <cstdio> // Para printf, perror
|
||||||
@@ -45,7 +46,7 @@ Director::Director(int argc, std::span<char *> argv) {
|
|||||||
#ifdef RECORDING
|
#ifdef RECORDING
|
||||||
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::GAME;
|
||||||
Section::options = Section::Options::GAME_PLAY_1P;
|
Section::options = Section::Options::GAME_PLAY_1P;
|
||||||
#else // NORMAL GAME
|
#else // NORMAL GAME
|
||||||
@@ -134,7 +135,7 @@ void Director::loadParams() {
|
|||||||
// Carga el fichero de puntuaciones
|
// Carga el fichero de puntuaciones
|
||||||
void Director::loadScoreFile() {
|
void Director::loadScoreFile() {
|
||||||
auto manager = std::make_unique<ManageHiScoreTable>(Options::settings.hi_score_table);
|
auto manager = std::make_unique<ManageHiScoreTable>(Options::settings.hi_score_table);
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
manager->clear();
|
manager->clear();
|
||||||
#else
|
#else
|
||||||
if (overrides.clear_hi_score_table) {
|
if (overrides.clear_hi_score_table) {
|
||||||
@@ -546,7 +547,7 @@ void Director::runGame() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
constexpr int CURRENT_STAGE = 0;
|
constexpr int CURRENT_STAGE = 0;
|
||||||
#else
|
#else
|
||||||
constexpr int CURRENT_STAGE = 0;
|
constexpr int CURRENT_STAGE = 0;
|
||||||
|
|||||||
2
source/external/jail_audio.cpp
vendored
2
source/external/jail_audio.cpp
vendored
@@ -102,7 +102,7 @@ Uint32 JA_UpdateCallback(void *userdata, SDL_TimerID timerID, Uint32 interval) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void JA_Init(const int freq, const SDL_AudioFormat format, const int num_channels) {
|
void JA_Init(const int freq, const SDL_AudioFormat format, const int num_channels) {
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG);
|
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
2
source/external/jail_shader.cpp
vendored
2
source/external/jail_shader.cpp
vendored
@@ -276,7 +276,7 @@ bool init(SDL_Window *window, SDL_Texture *back_buffer_texture, const std::strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
usingOpenGL = true;
|
usingOpenGL = true;
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Shader system initialized successfully.");
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "** Shader system initialized successfully");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ auto checkInputs() -> bool {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
// Debug info
|
// Debug info
|
||||||
if (Input::get()->checkInput(InputAction::SHOW_INFO, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD)) {
|
if (Input::get()->checkInput(InputAction::SHOW_INFO, INPUT_DO_NOT_ALLOW_REPEAT, InputDevice::KEYBOARD)) {
|
||||||
Screen::get()->toggleDebugInfo();
|
Screen::get()->toggleDebugInfo();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
#include <SDL3/SDL.h> // Para SDL_LogInfo, SDL_LogCategory, SDL_LogError, SDL_SetRenderDrawColor, SDL_EventType, SDL_PollEvent, SDL_RenderFillRect, SDL_RenderRect, SDLK_ESCAPE, SDL_Event
|
#include <SDL3/SDL.h> // Para SDL_LogInfo, SDL_LogCategory, SDL_LogError, SDL_SetRenderDrawColor, SDL_EventType, SDL_PollEvent, SDL_RenderFillRect, SDL_RenderRect, SDLK_ESCAPE, SDL_Event
|
||||||
|
|
||||||
#include <algorithm> // Para find_if, max
|
#include <algorithm> // Para find_if, max
|
||||||
#include <array> // Para array
|
#include <array> // Para array
|
||||||
#include <cstdlib> // Para exit
|
#include <cstdlib> // Para exit
|
||||||
@@ -9,7 +10,9 @@
|
|||||||
|
|
||||||
#include "asset.h" // Para Asset, AssetType
|
#include "asset.h" // Para Asset, AssetType
|
||||||
#include "color.h" // Para Color
|
#include "color.h" // Para Color
|
||||||
|
#ifndef NO_AUDIO
|
||||||
#include "external/jail_audio.h" // Para JA_DeleteMusic, JA_DeleteSound, JA_LoadMusic, JA_LoadSound
|
#include "external/jail_audio.h" // Para JA_DeleteMusic, JA_DeleteSound, JA_LoadMusic, JA_LoadSound
|
||||||
|
#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 "screen.h" // Para Screen
|
#include "screen.h" // Para Screen
|
||||||
@@ -38,8 +41,10 @@ Resource::~Resource() { clear(); }
|
|||||||
|
|
||||||
// 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();
|
||||||
@@ -59,8 +64,10 @@ 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
|
||||||
@@ -173,7 +180,9 @@ 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
|
||||||
sounds_.emplace_back(name, JA_LoadSound(l.c_str()));
|
sounds_.emplace_back(name, JA_LoadSound(l.c_str()));
|
||||||
|
#endif
|
||||||
printWithDots("Sound : ", name, "[ LOADED ]");
|
printWithDots("Sound : ", name, "[ LOADED ]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -187,7 +196,9 @@ 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
|
||||||
musics_.emplace_back(name, JA_LoadMusic(l.c_str()));
|
musics_.emplace_back(name, JA_LoadMusic(l.c_str()));
|
||||||
|
#endif
|
||||||
printWithDots("Music : ", name, "[ LOADED ]");
|
printWithDots("Music : ", name, "[ LOADED ]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -338,7 +349,9 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -349,7 +362,9 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
|
||||||
#include <SDL3/SDL.h> // Para SDL_SetRenderTarget, SDL_LogCategory, SDL_LogInfo, SDL_RenderTexture, SDL_SetRenderDrawColor, SDL_SetRenderVSync, SDL_GetError, SDL_LogError, SDL_RendererLogicalPresentation, SDL_SetRenderLogicalPresentation, SDL_CreateTexture, SDL_DestroyTexture, SDL_DestroyWindow, SDL_GetTicks, SDL_Quit, SDL_RENDERER_VSYNC_DISABLED, SDL_RenderClear, SDL_CreateRenderer, SDL_CreateWindow, SDL_DestroyRenderer, SDL_DisplayID, SDL_FRect, SDL_GetCurrentDisplayMode, SDL_GetDisplayName, SDL_GetDisplays, SDL_GetRenderTarget, SDL_GetWindowPosition, SDL_GetWindowSize, SDL_Init, SDL_LogWarn, SDL_PixelFormat, SDL_RenderFillRect, SDL_RenderPresent, SDL_SetHint, SDL_SetRenderDrawBlendMode, SDL_SetTextureScaleMode, SDL_SetWindowFullscreen, SDL_SetWindowPosition, SDL_SetWindowSize, SDL_TextureAccess, SDL_free, SDL_BLENDMODE_BLEND, SDL_HINT_RENDER_DRIVER, SDL_INIT_VIDEO, SDL_PRIu32, SDL_ScaleMode, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_OPENGL, SDL_WindowFlags
|
#include <SDL3/SDL.h> // Para SDL_SetRenderTarget, SDL_LogCategory, SDL_LogInfo, SDL_RenderTexture, SDL_SetRenderDrawColor, SDL_SetRenderVSync, SDL_GetError, SDL_LogError, SDL_RendererLogicalPresentation, SDL_SetRenderLogicalPresentation, SDL_CreateTexture, SDL_DestroyTexture, SDL_DestroyWindow, SDL_GetTicks, SDL_Quit, SDL_RENDERER_VSYNC_DISABLED, SDL_RenderClear, SDL_CreateRenderer, SDL_CreateWindow, SDL_DestroyRenderer, SDL_DisplayID, SDL_FRect, SDL_GetCurrentDisplayMode, SDL_GetDisplayName, SDL_GetDisplays, SDL_GetRenderTarget, SDL_GetWindowPosition, SDL_GetWindowSize, SDL_Init, SDL_LogWarn, SDL_PixelFormat, SDL_RenderFillRect, SDL_RenderPresent, SDL_SetHint, SDL_SetRenderDrawBlendMode, SDL_SetTextureScaleMode, SDL_SetWindowFullscreen, SDL_SetWindowPosition, SDL_SetWindowSize, SDL_TextureAccess, SDL_free, SDL_BLENDMODE_BLEND, SDL_HINT_RENDER_DRIVER, SDL_INIT_VIDEO, SDL_PRIu32, SDL_ScaleMode, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_OPENGL, SDL_WindowFlags
|
||||||
|
|
||||||
#include <algorithm> // Para min, max
|
#include <algorithm> // Para min, max
|
||||||
#include <fstream> // Para basic_ifstream, ifstream
|
#include <fstream> // Para basic_ifstream, ifstream
|
||||||
#include <iterator> // Para istreambuf_iterator, operator==
|
#include <iterator> // Para istreambuf_iterator, operator==
|
||||||
@@ -49,7 +50,7 @@ Screen::Screen()
|
|||||||
// Crea el objeto de texto
|
// Crea el objeto de texto
|
||||||
createText();
|
createText();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
debug_info_.text = text_;
|
debug_info_.text = text_;
|
||||||
setDebugInfoEnabled(true);
|
setDebugInfoEnabled(true);
|
||||||
#endif
|
#endif
|
||||||
@@ -86,7 +87,7 @@ void Screen::render() {
|
|||||||
// Vuelca el contenido del renderizador en pantalla exceptuando ciertas partes
|
// Vuelca el contenido del renderizador en pantalla exceptuando ciertas partes
|
||||||
void Screen::coreRender() {
|
void Screen::coreRender() {
|
||||||
fps_.increment();
|
fps_.increment();
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
renderInfo();
|
renderInfo();
|
||||||
#endif
|
#endif
|
||||||
renderScreen(); // Renderiza el contenido del game_canvas_
|
renderScreen(); // Renderiza el contenido del game_canvas_
|
||||||
@@ -206,7 +207,7 @@ void Screen::renderShake() {
|
|||||||
SDL_SetRenderTarget(renderer_, current_target);
|
SDL_SetRenderTarget(renderer_, current_target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
// Muestra información por pantalla
|
// Muestra información por pantalla
|
||||||
void Screen::renderInfo() {
|
void Screen::renderInfo() {
|
||||||
if (debug_info_.show) {
|
if (debug_info_.show) {
|
||||||
@@ -267,7 +268,7 @@ void Screen::renderOverlays() {
|
|||||||
renderAttenuate();
|
renderAttenuate();
|
||||||
service_menu_->render();
|
service_menu_->render();
|
||||||
notifier_->render();
|
notifier_->render();
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
renderInfo();
|
renderInfo();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -335,9 +336,8 @@ auto Screen::initSDLVideo() -> bool {
|
|||||||
SDL_SetRenderLogicalPresentation(renderer_, param.game.width, param.game.height, Options::video.integer_scale ? SDL_LOGICAL_PRESENTATION_INTEGER_SCALE : SDL_LOGICAL_PRESENTATION_LETTERBOX);
|
SDL_SetRenderLogicalPresentation(renderer_, param.game.width, param.game.height, Options::video.integer_scale ? SDL_LOGICAL_PRESENTATION_INTEGER_SCALE : SDL_LOGICAL_PRESENTATION_LETTERBOX);
|
||||||
SDL_SetRenderDrawBlendMode(renderer_, SDL_BLENDMODE_BLEND);
|
SDL_SetRenderDrawBlendMode(renderer_, SDL_BLENDMODE_BLEND);
|
||||||
SDL_SetRenderVSync(renderer_, Options::video.v_sync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
SDL_SetRenderVSync(renderer_, Options::video.v_sync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
||||||
// SDL_SetWindowFullscreen(window_, Options::video.fullscreen);
|
|
||||||
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "SDL Video initialized successfully.");
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "** Video system initialized successfully");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL3/SDL.h> // Para SDL_FRect, SDL_HideWindow, SDL_Renderer, SDL_ShowWindow, Uint32, SDL_Texture, SDL_Window
|
#include <SDL3/SDL.h> // Para SDL_FRect, SDL_HideWindow, SDL_Renderer, SDL_ShowWindow, Uint32, SDL_Texture, SDL_Window
|
||||||
|
|
||||||
#include <memory> // Para shared_ptr
|
#include <memory> // Para shared_ptr
|
||||||
#include <string> // Para string
|
#include <string> // Para string
|
||||||
|
|
||||||
@@ -53,7 +54,7 @@ class Screen {
|
|||||||
[[nodiscard]] static auto getVSync() -> bool { return Options::video.v_sync; } // Obtiene el valor de V-Sync
|
[[nodiscard]] static auto getVSync() -> bool { return Options::video.v_sync; } // Obtiene el valor de V-Sync
|
||||||
[[nodiscard]] auto getText() const -> std::shared_ptr<Text> { return text_; } // Obtiene el puntero al texto de Screen
|
[[nodiscard]] auto getText() const -> std::shared_ptr<Text> { return text_; } // Obtiene el puntero al texto de Screen
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
// --- Debug ---
|
// --- Debug ---
|
||||||
void toggleDebugInfo() { debug_info_.show = !debug_info_.show; }
|
void toggleDebugInfo() { debug_info_.show = !debug_info_.show; }
|
||||||
void setDebugInfoEnabled(bool value) { debug_info_.show = value; }
|
void setDebugInfoEnabled(bool value) { debug_info_.show = value; }
|
||||||
@@ -161,7 +162,7 @@ class Screen {
|
|||||||
[[nodiscard]] auto isEnabled() const -> bool { return enabled; }
|
[[nodiscard]] auto isEnabled() const -> bool { return enabled; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
struct Debug {
|
struct Debug {
|
||||||
std::shared_ptr<Text> text;
|
std::shared_ptr<Text> text;
|
||||||
bool show = false;
|
bool show = false;
|
||||||
@@ -187,7 +188,7 @@ class Screen {
|
|||||||
FlashEffect flash_effect_; // Efecto de flash en pantalla
|
FlashEffect flash_effect_; // Efecto de flash en pantalla
|
||||||
ShakeEffect shake_effect_; // Efecto de agitar la pantalla
|
ShakeEffect shake_effect_; // Efecto de agitar la pantalla
|
||||||
bool attenuate_effect_ = false; // Indica si la pantalla ha de estar atenuada
|
bool attenuate_effect_ = false; // Indica si la pantalla ha de estar atenuada
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
Debug debug_info_; // Información de debug
|
Debug debug_info_; // Información de debug
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
|
||||||
#include <SDL3/SDL.h> // Para SDL_GetTicks, SDL_SetRenderTarget, SDL_EventType, SDL_CreateTexture, SDL_Delay, SDL_DestroyTexture, SDL_Event, SDL_GetRenderTarget, SDL_PollEvent, SDL_RenderTexture, SDL_SetTextureBlendMode, SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6, SDLK_7, SDLK_8, SDLK_9, SDL_BLENDMODE_BLEND, SDL_PixelFormat, SDL_Point, SDL_TextureAccess
|
#include <SDL3/SDL.h> // Para SDL_GetTicks, SDL_SetRenderTarget, SDL_EventType, SDL_CreateTexture, SDL_Delay, SDL_DestroyTexture, SDL_Event, SDL_GetRenderTarget, SDL_PollEvent, SDL_RenderTexture, SDL_SetTextureBlendMode, SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6, SDLK_7, SDLK_8, SDLK_9, SDL_BLENDMODE_BLEND, SDL_PixelFormat, SDL_Point, SDL_TextureAccess
|
||||||
|
|
||||||
#include <algorithm> // Para max, find_if, clamp, find, min
|
#include <algorithm> // Para max, find_if, clamp, find, min
|
||||||
#include <array> // Para array
|
#include <array> // Para array
|
||||||
#include <cstdlib> // Para rand, size_t
|
#include <cstdlib> // Para rand, size_t
|
||||||
@@ -88,7 +89,7 @@ Game::Game(int player_id, int current_stage, bool demo)
|
|||||||
initPaths();
|
initPaths();
|
||||||
setTotalPower();
|
setTotalPower();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
// Si se empieza en una fase que no es la primera
|
// Si se empieza en una fase que no es la primera
|
||||||
if (!demo_.enabled) {
|
if (!demo_.enabled) {
|
||||||
for (int i = 0; i < Stage::number; ++i) {
|
for (int i = 0; i < Stage::number; ++i) {
|
||||||
@@ -1120,7 +1121,7 @@ void Game::checkEvents() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
checkDebugEvents(event);
|
checkDebugEvents(event);
|
||||||
#endif
|
#endif
|
||||||
GlobalEvents::check(event);
|
GlobalEvents::check(event);
|
||||||
@@ -1685,7 +1686,7 @@ void Game::updateGameStateShowingGetReadyMessage() {
|
|||||||
|
|
||||||
// Actualiza las variables durante el transcurso normal del juego
|
// Actualiza las variables durante el transcurso normal del juego
|
||||||
void Game::updateGameStatePlaying() {
|
void Game::updateGameStatePlaying() {
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
if (auto_pop_balloons_) {
|
if (auto_pop_balloons_) {
|
||||||
Stage::addPower(5);
|
Stage::addPower(5);
|
||||||
}
|
}
|
||||||
@@ -1818,7 +1819,7 @@ void Game::checkServiceMenu() {
|
|||||||
service_menu_was_active_ = service_menu_is_active;
|
service_menu_was_active_ = service_menu_is_active;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
// Comprueba los eventos en el modo DEBUG
|
// Comprueba los eventos en el modo DEBUG
|
||||||
void Game::checkDebugEvents(const SDL_Event &event) {
|
void Game::checkDebugEvents(const SDL_Event &event) {
|
||||||
if (event.type == SDL_EVENT_KEY_DOWN && static_cast<int>(event.key.repeat) == 0) {
|
if (event.type == SDL_EVENT_KEY_DOWN && static_cast<int>(event.key.repeat) == 0) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL3/SDL.h> // Para SDL_Event, SDL_Renderer, SDL_Texture, Uint64
|
#include <SDL3/SDL.h> // Para SDL_Event, SDL_Renderer, SDL_Texture, Uint64
|
||||||
|
|
||||||
#include <memory> // Para shared_ptr, unique_ptr
|
#include <memory> // Para shared_ptr, unique_ptr
|
||||||
#include <string> // Para string
|
#include <string> // Para string
|
||||||
#include <vector> // Para vector
|
#include <vector> // Para vector
|
||||||
@@ -146,7 +147,7 @@ class Game {
|
|||||||
GameState state_ = GameState::FADE_IN; // Estado
|
GameState state_ = GameState::FADE_IN; // Estado
|
||||||
std::vector<std::shared_ptr<Player>> players_to_reorder_;
|
std::vector<std::shared_ptr<Player>> players_to_reorder_;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
bool auto_pop_balloons_ = false; // Si es true, incrementa automaticamente los globos explotados
|
bool auto_pop_balloons_ = false; // Si es true, incrementa automaticamente los globos explotados
|
||||||
|
|
||||||
// Comprueba los eventos en el modo DEBUG
|
// Comprueba los eventos en el modo DEBUG
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "intro.h"
|
#include "intro.h"
|
||||||
|
|
||||||
#include <SDL3/SDL.h> // Para SDL_GetTicks, SDL_SetRenderDrawColor, SDL_FRect, SDL_RenderFillRect, SDL_GetRenderTarget, SDL_RenderClear, SDL_RenderRect, SDL_SetRenderTarget, SDL_BLENDMODE_BLEND, SDL_PixelFormat, SDL_PollEvent, SDL_RenderTexture, SDL_TextureAccess, SDLK_A, SDLK_C, SDLK_D, SDLK_F, SDLK_S, SDLK_V, SDLK_X, SDLK_Z, SDL_Event, SDL_EventType, Uint32
|
#include <SDL3/SDL.h> // Para SDL_GetTicks, SDL_SetRenderDrawColor, SDL_FRect, SDL_RenderFillRect, SDL_GetRenderTarget, SDL_RenderClear, SDL_RenderRect, SDL_SetRenderTarget, SDL_BLENDMODE_BLEND, SDL_PixelFormat, SDL_PollEvent, SDL_RenderTexture, SDL_TextureAccess, SDLK_A, SDLK_C, SDLK_D, SDLK_F, SDLK_S, SDLK_V, SDLK_X, SDLK_Z, SDL_Event, SDL_EventType, Uint32
|
||||||
|
|
||||||
#include <algorithm> // Para max
|
#include <algorithm> // Para max
|
||||||
#include <array> // Para array
|
#include <array> // Para array
|
||||||
#include <functional> // Para function
|
#include <functional> // Para function
|
||||||
@@ -25,7 +26,7 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "writer.h" // Para Writer
|
#include "writer.h" // Para Writer
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
#include <iomanip> // Para operator<<, setfill, setw
|
#include <iomanip> // Para operator<<, setfill, setw
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ Intro::Intro()
|
|||||||
void Intro::checkEvents() {
|
void Intro::checkEvents() {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
if (event.type == SDL_EVENT_KEY_DOWN && static_cast<int>(event.key.repeat) == 1) {
|
if (event.type == SDL_EVENT_KEY_DOWN && static_cast<int>(event.key.repeat) == 1) {
|
||||||
static Color color_ = param.intro.bg_color;
|
static Color color_ = param.intro.bg_color;
|
||||||
handleDebugColorKeys(event.key.key, color_);
|
handleDebugColorKeys(event.key.key, color_);
|
||||||
@@ -536,7 +537,7 @@ void Intro::renderTextRect() {
|
|||||||
SDL_RenderFillRect(Screen::get()->getRenderer(), &rect_);
|
SDL_RenderFillRect(Screen::get()->getRenderer(), &rect_);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
// Helper functions for color adjustment
|
// Helper functions for color adjustment
|
||||||
void Intro::adjustColorComponent(uint8_t &component, bool increase) {
|
void Intro::adjustColorComponent(uint8_t &component, bool increase) {
|
||||||
if (increase && component < 255) {
|
if (increase && component < 255) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <SDL3/SDL.h> // Para SDL_Keycode, Uint32, Uint64
|
#include <SDL3/SDL.h> // Para SDL_Keycode, Uint32, Uint64
|
||||||
#include <stdint.h> // Para uint8_t
|
#include <stdint.h> // Para uint8_t
|
||||||
|
|
||||||
#include <memory> // Para unique_ptr
|
#include <memory> // Para unique_ptr
|
||||||
#include <vector> // Para vector
|
#include <vector> // Para vector
|
||||||
|
|
||||||
@@ -69,7 +70,7 @@ class Intro {
|
|||||||
void renderTexts(); // Dibuja los textos
|
void renderTexts(); // Dibuja los textos
|
||||||
static void renderTextRect(); // Dibuja el rectangulo de fondo del texto;
|
static void renderTextRect(); // Dibuja el rectangulo de fondo del texto;
|
||||||
void updatePostState(); // Actualiza el estado POST
|
void updatePostState(); // Actualiza el estado POST
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
void adjustColorComponent(uint8_t& component, bool increase);
|
void adjustColorComponent(uint8_t& component, bool increase);
|
||||||
void adjustAllColorComponents(Color& color, bool increase);
|
void adjustAllColorComponents(Color& color, bool increase);
|
||||||
void handleDebugColorKeys(SDL_Keycode key, Color& color);
|
void handleDebugColorKeys(SDL_Keycode key, Color& color);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "title.h"
|
#include "title.h"
|
||||||
|
|
||||||
#include <SDL3/SDL.h> // Para SDL_GetTicks, Uint32, SDL_EventType
|
#include <SDL3/SDL.h> // Para SDL_GetTicks, Uint32, SDL_EventType
|
||||||
|
|
||||||
#include <algorithm> // Para find_if
|
#include <algorithm> // Para find_if
|
||||||
#include <cstddef> // Para size_t
|
#include <cstddef> // Para size_t
|
||||||
#include <iostream> // Para basic_ostream, basic_ostream::operator<<
|
#include <iostream> // Para basic_ostream, basic_ostream::operator<<
|
||||||
@@ -31,7 +32,7 @@
|
|||||||
|
|
||||||
class Texture;
|
class Texture;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
#include <iomanip> // Para operator<<, setfill, setw
|
#include <iomanip> // Para operator<<, setfill, setw
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -107,7 +108,7 @@ void Title::render() {
|
|||||||
void Title::checkEvents() {
|
void Title::checkEvents() {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
#ifdef DEBUG
|
#ifdef _DEBUG
|
||||||
if (event.type == SDL_EVENT_KEY_DOWN && static_cast<int>(event.key.repeat) == 1) {
|
if (event.type == SDL_EVENT_KEY_DOWN && static_cast<int>(event.key.repeat) == 1) {
|
||||||
static Color color_ = param.title.bg_color;
|
static Color color_ = param.title.bg_color;
|
||||||
switch (event.key.key) {
|
switch (event.key.key) {
|
||||||
|
|||||||
Reference in New Issue
Block a user