convertit Asset i Audio

This commit is contained in:
2025-05-27 11:06:17 +02:00
parent 9bc07b2bcb
commit ada141cb09
29 changed files with 493 additions and 472 deletions

View File

@@ -5,39 +5,28 @@
#include <string> // Para string
#include <vector> // Para vector
#include "moving_sprite.h" // Para MovingSprite
class Texture; // lines 9-9
class Texture;
struct Animation
{
std::string name; // Nombre de la animacion
std::vector<SDL_FRect> frames; // Cada uno de los frames que componen la animación
int speed; // Velocidad de la animación
int loop; // Indica a que frame vuelve la animación al terminar. -1 para que no vuelva
bool completed; // Indica si ha finalizado la animación
int current_frame; // Frame actual
int counter; // Contador para las animaciones
std::string name; // Nombre de la animación
std::vector<SDL_FRect> frames; // Frames que componen la animación
int speed; // Velocidad de reproducción
int loop; // Frame al que vuelve la animación al terminar (-1 para no repetir)
bool completed; // Indica si la animación ha finalizado
int current_frame; // Frame actual en reproducción
int counter; // Contador para la animación
Animation() : name(std::string()), speed(5), loop(0), completed(false), current_frame(0), counter(0) {}
};
using AnimationsFileBuffer = std::vector<std::string>;
// Carga las animaciones en un vector(Animations) desde un fichero
// Carga las animaciones desde un fichero en un vector
AnimationsFileBuffer loadAnimationsFromFile(const std::string &file_path);
class AnimatedSprite : public MovingSprite
{
protected:
// Variables
std::vector<Animation> animations_; // Vector con las diferentes animaciones
int current_animation_ = 0; // Animacion activa
// Calcula el frame correspondiente a la animación actual
void animate();
// Carga la animación desde un vector de cadenas
void loadFromAnimationsFileBuffer(const AnimationsFileBuffer &source);
public:
// Constructor
AnimatedSprite(std::shared_ptr<Texture> texture, const std::string &file_path);
@@ -48,19 +37,22 @@ public:
// Destructor
virtual ~AnimatedSprite() override = default;
// Actualiza las variables del objeto
void update() override;
// Actualización del objeto
void update() override; // Actualiza la animación
bool animationIsCompleted(); // Comprueba si la animación ha terminado
int getIndex(const std::string &name); // Obtiene el índice de una animación según su nombre
// Comprueba si ha terminado la animación
bool animationIsCompleted();
// Manipulación de animaciones
void setCurrentAnimation(const std::string &name = "default"); // Establece animación por nombre
void setCurrentAnimation(int index = 0); // Establece animación por índice
void resetAnimation(); // Reinicia la animación
// Obtiene el indice de la animación a partir del nombre
int getIndex(const std::string &name);
protected:
// Almacenamiento de animaciones
std::vector<Animation> animations_; // Vector de animaciones disponibles
int current_animation_ = 0; // Índice de la animación activa
// Establece la animacion actual
void setCurrentAnimation(const std::string &name = "default");
void setCurrentAnimation(int index = 0);
// Reinicia la animación
void resetAnimation();
};
// Procesos internos
void animate(); // Calcula el frame actual de la animación
void loadFromAnimationsFileBuffer(const AnimationsFileBuffer &source); // Carga animaciones desde un buffer
};

View File

@@ -5,27 +5,6 @@
#include <string> // Para allocator, string, char_traits, operator+
#include "utils.h" // Para getFileName
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
Asset *Asset::asset_ = nullptr;
// [SINGLETON] Crearemos el objeto asset con esta función estática
void Asset::init(const std::string &executable_path)
{
Asset::asset_ = new Asset(executable_path);
}
// [SINGLETON] Destruiremos el objeto asset con esta función estática
void Asset::destroy()
{
delete Asset::asset_;
}
// [SINGLETON] Con este método obtenemos el objeto asset y podemos trabajar con él
Asset *Asset::get()
{
return Asset::asset_;
}
// Añade un elemento a la lista
void Asset::add(const std::string &file, AssetType type, bool required, bool absolute)
{

View File

@@ -1,8 +1,8 @@
#pragma once
#include <string> // Para string
#include <vector> // Para vector
#include "utils.h" // Para getPath
#include <string> // Para manejar cadenas de texto
#include <vector> // Para estructuras dinámicas de datos
#include "utils.h" // Para la función getPath
enum class AssetType : int
{
@@ -21,59 +21,54 @@ enum class AssetType : int
// Clase Asset
class Asset
{
private:
// [SINGLETON] Objeto asset privado
static Asset *asset_;
public:
// Obtención de la instancia única (*Meyers Singleton*)
static Asset &get()
{
static Asset instance;
return instance;
}
// Estructura para definir un item
void init(const std::string &executable_path)
{
executable_path_ = getPath(executable_path);
}
// Manejo de archivos
void add(const std::string &file, AssetType type, bool required = true, bool absolute = false); // Añade un recurso
std::string get(const std::string &text) const; // Devuelve la ruta completa de un recurso
bool check() const; // Verifica la existencia de todos los elementos
std::vector<std::string> getListByType(AssetType type) const; // Obtiene lista de recursos de un tipo específico
private:
// Estructura para definir un recurso
struct AssetItem
{
std::string file; // Ruta del fichero desde la raíz del directorio
AssetType type; // Indica el tipo de recurso
bool required; // Indica si es un fichero que debe de existir
AssetType type; // Tipo de recurso
bool required; // Indica si el fichero es obligatorio
// Constructor
AssetItem(const std::string &filePath, AssetType assetType, bool isRequired)
: file(filePath), type(assetType), required(isRequired) {}
};
// Variables
int longest_name_ = 0; // Contiene la longitud del nombre de fichero mas largo
std::vector<AssetItem> file_list_; // Listado con todas las rutas a los ficheros
std::string executable_path_; // Ruta al ejecutable
// Variables internas
int longest_name_ = 0; // Longitud del nombre de archivo más largo
std::vector<AssetItem> file_list_; // Lista con todas las rutas de los archivos
std::string executable_path_; // Ruta del ejecutable
// Comprueba que existe un fichero
bool checkFile(const std::string &path) const;
// Métodos internos
bool checkFile(const std::string &path) const; // Verifica si un archivo existe
std::string getTypeName(AssetType type) const; // Obtiene el nombre textual del tipo de recurso
// Devuelve el nombre del tipo de recurso
std::string getTypeName(AssetType type) const;
// Constructor privado
Asset() = default;
// Constructor
explicit Asset(const std::string &executable_path)
: executable_path_(getPath(executable_path)) {}
// Destructor
// Destructor privado
~Asset() = default;
public:
// [SINGLETON] Crearemos el objeto con esta función estática
static void init(const std::string &executable_path);
// [SINGLETON] Destruiremos el objeto con esta función estática
static void destroy();
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
static Asset *get();
// Añade un elemento a la lista
void add(const std::string &file, AssetType type, bool required = true, bool absolute = false);
// Devuelve la ruta completa a un fichero a partir de una cadena
std::string get(const std::string &text) const;
// Comprueba que existen todos los elementos
bool check() const;
// Devuelve la lista de recursos de un tipo
std::vector<std::string> getListByType(AssetType type) const;
};
// Evita copia y asignación
Asset(const Asset &) = delete;
Asset &operator=(const Asset &) = delete;
};

View File

@@ -4,27 +4,6 @@
#include "resource.h"
#include <SDL3/SDL.h>
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
Audio *Audio::audio_ = nullptr;
// [SINGLETON] Crearemos el objeto asset con esta función estática
void Audio::init()
{
Audio::audio_ = new Audio();
}
// [SINGLETON] Destruiremos el objeto asset con esta función estática
void Audio::destroy()
{
delete Audio::audio_;
}
// [SINGLETON] Con este método obtenemos el objeto asset y podemos trabajar con él
Audio *Audio::get()
{
return Audio::audio_;
}
// Constructor
Audio::Audio()
{

View File

@@ -5,59 +5,57 @@
class Audio
{
private:
// [SINGLETON] Objeto audio privado
static Audio *audio_;
// Constructor
Audio(); // Constructor privado para el patrón Singleton
// Destructor
~Audio(); // Destructor privado para el patrón Singleton
// Variables
bool enabled_ = true; // Indica si el audio está habilitado
bool sound_enabled_ = true; // Indica si los sonidos están habilitados
bool music_enabled_ = true; // Indica si la música está habilitada
public:
// [SINGLETON] Crearemos el objeto con esta función estática
static void init(); // Inicializa el objeto Singleton
// Obtención de la instancia única (*Meyers Singleton*)
static Audio &get()
{
static Audio instance;
return instance;
}
// [SINGLETON] Destruiremos el objeto con esta función estática
static void destroy(); // Destruye el objeto Singleton
// Manejo de reproducción de música
void playMusic(const std::string &name, int loop = -1); // Reproduce música en bucle
void pauseMusic(); // Pausa la reproducción de música
void stopMusic(); // Detiene la música completamente
void fadeOutMusic(int milliseconds); // Fundido de salida de la música
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
static Audio *get(); // Devuelve la instancia del Singleton
// Manejo de efectos de sonido
void playSound(const std::string &name); // Reproduce un sonido puntual
void stopAllSounds(); // Detiene todos los sonidos activos
void playMusic(const std::string &name, const int loop = -1); // Reproduce la música
void pauseMusic(); // Pausa la música
void stopMusic(); // Detiene la música
// Configuración de audio general
void enable() { enabled_ = true; } // Habilita el audio
void disable() { enabled_ = false; } // Deshabilita el audio
void enable(bool value) { enabled_ = value; } // Establece estado del audio
void toggleEnabled() { enabled_ = !enabled_; } // Alterna estado del audio
void playSound(const std::string &name); // Reproduce un sonido
void stopAllSounds(); // Detiene todos los sonidos
// Configuración de sonido
void enableSound() { sound_enabled_ = true; } // Habilita los sonidos
void disableSound() { sound_enabled_ = false; } // Deshabilita los sonidos
void enableSound(bool value) { sound_enabled_ = value; } // Establece estado de sonidos
void toggleSound() { sound_enabled_ = !sound_enabled_; } // Alterna estado de sonidos
void fadeOutMusic(int milliseconds); // Realiza un fundido de salida de la música
// Configuración de música
void enableMusic() { music_enabled_ = true; } // Habilita la música
void disableMusic() { music_enabled_ = false; } // Deshabilita la música
void enableMusic(bool value) { music_enabled_ = value; } // Establece estado de música
void toggleMusic() { music_enabled_ = !music_enabled_; } // Alterna estado de música
// Audio
void enable() { enabled_ = true; } // Habilita el audio
void disable() { enabled_ = false; } // Deshabilita el audio
void enable(bool value) { enabled_ = value; } // Habilita o deshabilita el audio
void toggleEnabled() { enabled_ = !enabled_; } // Alterna el estado del audio
// Control de volumen
void setSoundVolume(int volume); // Ajusta volumen de efectos de sonido
void setMusicVolume(int volume); // Ajusta volumen de música
// Sound
void enableSound() { sound_enabled_ = true; } // Habilita los sonidos
void disableSound() { sound_enabled_ = false; } // Deshabilita los sonidos
void enableSound(bool value) { sound_enabled_ = value; } // Habilita o deshabilita los sonidos
void toggleSound() { sound_enabled_ = !sound_enabled_; } // Alterna el estado de los sonidos
private:
// Variables internas
bool enabled_ = true; // Estado general del audio
bool sound_enabled_ = true; // Estado de los efectos de sonido
bool music_enabled_ = true; // Estado de la música
// Music
void enableMusic() { music_enabled_ = true; } // Habilita la música
void disableMusic() { music_enabled_ = false; } // Deshabilita la música
void enableMusic(bool value) { music_enabled_ = value; } // Habilita o deshabilita la música
void toggleMusic() { music_enabled_ = !music_enabled_; } // Alterna el estado de la música
// Constructor privado (Meyers Singleton)
Audio();
~Audio();
// Volume
void setSoundVolume(int volume); // Establece el volumen de los sonidos
void setMusicVolume(int volume); // Establece el volumen de la música
};
// Prevención de copia y asignación
Audio(const Audio &) = delete;
Audio &operator=(const Audio &) = delete;
};

View File

@@ -414,6 +414,6 @@ void Balloon::playSound()
{
if (sound_enabled_)
{
Audio::get()->playSound(sound_);
Audio::get().playSound(sound_);
}
}

View File

@@ -320,7 +320,7 @@ int BalloonManager::destroyAllBalloons()
}
balloon_deploy_counter_ = 300;
Audio::get()->playSound("power_ball_explosion.wav");
Audio::get().playSound("power_ball_explosion.wav");
Screen::get()->flash(FLASH_COLOR, 3);
Screen::get()->shake();

View File

@@ -71,7 +71,7 @@ Credits::~Credits()
SDL_DestroyTexture(text_texture_);
SDL_DestroyTexture(canvas_);
resetVolume();
Audio::get()->stopMusic();
Audio::get().stopMusic();
}
// Bucle principal
@@ -437,7 +437,7 @@ void Credits::updateBlackRects()
{
// Si los rectangulos izquierdo y derecho han llegado al centro
setVolume(0);
Audio::get()->stopMusic();
Audio::get().stopMusic();
if (counter_pre_fade_ == 400)
{
fade_out_->activate();
@@ -471,7 +471,7 @@ void Credits::updateAllFades()
fade_in_->update();
if (fade_in_->hasEnded())
{
Audio::get()->playMusic("credits.ogg");
Audio::get().playMusic("credits.ogg");
}
fade_out_->update();
@@ -485,14 +485,14 @@ void Credits::updateAllFades()
void Credits::setVolume(int amount)
{
options.audio.music.volume = std::clamp(amount, 0, 100);
Audio::get()->setMusicVolume(options.audio.music.volume);
Audio::get().setMusicVolume(options.audio.music.volume);
}
// Reestablece el nivel de volumen
void Credits::resetVolume()
{
options.audio.music.volume = initial_volume_;
Audio::get()->setMusicVolume(options.audio.music.volume);
Audio::get().setMusicVolume(options.audio.music.volume);
}
// Cambia el color del fondo

View File

@@ -84,21 +84,26 @@ Director::~Director()
// Inicializa todo
void Director::init()
{
Asset::init(executable_path_); // Crea el objeto que controla los ficheros de recursos
setFileList(); // Crea el indice de ficheros
loadOptionsFile(Asset::get()->get("config.txt")); // Carga el fichero de configuración
loadParams(); // Carga los parametros
loadScoreFile(); // Carga el fichero de puntuaciones
// Configuración inicial de recursos
Asset::get().init(executable_path_); // Inicializa el sistema de gestión de archivos
setFileList(); // Crea el índice de archivos
loadOptionsFile(Asset::get().get("config.txt")); // Carga el archivo de configuración
loadParams(); // Carga los parámetros del programa
loadScoreFile(); // Carga el archivo de puntuaciones
// Inicializa y crea el resto de objetos
lang::loadFromFile(getLangFile(static_cast<lang::Code>(options.game.language)));
Screen::init();
Audio::init();
Resource::init();
Input::init(Asset::get()->get("gamecontrollerdb.txt"));
bindInputs();
// Inicialización de subsistemas
lang::loadFromFile(getLangFile(static_cast<lang::Code>(options.game.language))); // Carga el archivo de idioma
Screen::init(); // Inicializa la pantalla y el sistema de renderizado
Audio::get(); // Activa el sistema de audio
Resource::init(); // Inicializa el sistema de gestión de recursos
Input::init(Asset::get().get("gamecontrollerdb.txt")); // Carga configuración de controles
bindInputs(); // Asigna los controles a la entrada del sistema
// Inicialización del sistema de notificaciones
Notifier::init(std::string(), Resource::get()->getText("8bithud"));
#ifdef DEBUG
// Configuración adicional en modo depuración
Screen::get()->initDebugInfo();
Screen::get()->setDebugInfoEnabled(true);
#endif
@@ -107,14 +112,12 @@ void Director::init()
// Cierra todo
void Director::close()
{
saveOptionsFile(Asset::get()->get("config.txt"));
saveOptionsFile(Asset::get().get("config.txt"));
Notifier::destroy();
Input::destroy();
Resource::destroy();
Audio::destroy();
Screen::destroy();
Asset::destroy();
SDL_Quit();
@@ -130,7 +133,7 @@ void Director::loadParams()
#ifdef ANBERNIC
const std::string paramFilePath = asset->get("param_320x240.txt");
#else
const std::string paramFilePath = overrides.param_file == "--320x240" ? Asset::get()->get("param_320x240.txt") : Asset::get()->get("param_320x256.txt");
const std::string paramFilePath = overrides.param_file == "--320x240" ? Asset::get().get("param_320x240.txt") : Asset::get().get("param_320x256.txt");
#endif
loadParamsFromFile(paramFilePath);
}
@@ -145,7 +148,7 @@ void Director::loadScoreFile()
}
else
{
manager->loadFromFile(Asset::get()->get("score.bin"));
manager->loadFromFile(Asset::get().get("score.bin"));
}
}
@@ -264,189 +267,189 @@ void Director::setFileList()
#endif
// Ficheros de configuración
Asset::get()->add(system_folder_ + "/config.txt", AssetType::DATA, false, true);
Asset::get()->add(system_folder_ + "/score.bin", AssetType::DATA, false, true);
Asset::get()->add(prefix + "/data/config/param_320x240.txt", AssetType::DATA);
Asset::get()->add(prefix + "/data/config/param_320x256.txt", AssetType::DATA);
Asset::get()->add(prefix + "/data/config/demo1.bin", AssetType::DATA);
Asset::get()->add(prefix + "/data/config/demo2.bin", AssetType::DATA);
Asset::get()->add(prefix + "/data/config/gamecontrollerdb.txt", AssetType::DATA);
Asset::get().add(system_folder_ + "/config.txt", AssetType::DATA, false, true);
Asset::get().add(system_folder_ + "/score.bin", AssetType::DATA, false, true);
Asset::get().add(prefix + "/data/config/param_320x240.txt", AssetType::DATA);
Asset::get().add(prefix + "/data/config/param_320x256.txt", AssetType::DATA);
Asset::get().add(prefix + "/data/config/demo1.bin", AssetType::DATA);
Asset::get().add(prefix + "/data/config/demo2.bin", AssetType::DATA);
Asset::get().add(prefix + "/data/config/gamecontrollerdb.txt", AssetType::DATA);
// Musicas
Asset::get()->add(prefix + "/data/music/intro.ogg", AssetType::MUSIC);
Asset::get()->add(prefix + "/data/music/playing.ogg", AssetType::MUSIC);
Asset::get()->add(prefix + "/data/music/title.ogg", AssetType::MUSIC);
Asset::get()->add(prefix + "/data/music/credits.ogg", AssetType::MUSIC);
Asset::get().add(prefix + "/data/music/intro.ogg", AssetType::MUSIC);
Asset::get().add(prefix + "/data/music/playing.ogg", AssetType::MUSIC);
Asset::get().add(prefix + "/data/music/title.ogg", AssetType::MUSIC);
Asset::get().add(prefix + "/data/music/credits.ogg", AssetType::MUSIC);
// Sonidos
Asset::get()->add(prefix + "/data/sound/balloon.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/bubble1.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/bubble2.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/bubble3.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/bubble4.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/bullet.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/clock.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/coffee_out.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/continue_clock.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/game_start.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/hi_score_achieved.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/item_drop.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/item_pickup.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/logo.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/notify.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/player_collision.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/power_ball_explosion.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/stage_change.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/tabe.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/title.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/voice_coffee.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/voice_get_ready.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/voice_no.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/voice_power_up.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/walk.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/debian_drop.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/debian_pickup.wav", AssetType::SOUND);
Asset::get()->add(prefix + "/data/sound/tabe_hit.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/balloon.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/bubble1.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/bubble2.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/bubble3.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/bubble4.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/bullet.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/clock.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/coffee_out.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/continue_clock.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/game_start.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/hi_score_achieved.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/item_drop.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/item_pickup.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/logo.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/notify.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/player_collision.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/power_ball_explosion.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/stage_change.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/tabe.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/title.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/voice_coffee.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/voice_get_ready.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/voice_no.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/voice_power_up.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/walk.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/debian_drop.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/debian_pickup.wav", AssetType::SOUND);
Asset::get().add(prefix + "/data/sound/tabe_hit.wav", AssetType::SOUND);
// Shaders
Asset::get()->add(prefix + "/data/shaders/crtpi_256.glsl", AssetType::DATA);
Asset::get()->add(prefix + "/data/shaders/crtpi_240.glsl", AssetType::DATA);
Asset::get().add(prefix + "/data/shaders/crtpi_256.glsl", AssetType::DATA);
Asset::get().add(prefix + "/data/shaders/crtpi_240.glsl", AssetType::DATA);
// Texturas
{ // Controllers
Asset::get()->add(prefix + "/data/gfx/controllers/controllers.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/controllers/controllers.png", AssetType::BITMAP);
}
{ // Balloons
Asset::get()->add(prefix + "/data/gfx/balloon/balloon1.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/balloon/balloon1.ani", AssetType::ANIMATION);
Asset::get()->add(prefix + "/data/gfx/balloon/balloon2.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/balloon/balloon2.ani", AssetType::ANIMATION);
Asset::get()->add(prefix + "/data/gfx/balloon/balloon3.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/balloon/balloon3.ani", AssetType::ANIMATION);
Asset::get()->add(prefix + "/data/gfx/balloon/balloon4.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/balloon/balloon4.ani", AssetType::ANIMATION);
Asset::get().add(prefix + "/data/gfx/balloon/balloon1.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/balloon/balloon1.ani", AssetType::ANIMATION);
Asset::get().add(prefix + "/data/gfx/balloon/balloon2.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/balloon/balloon2.ani", AssetType::ANIMATION);
Asset::get().add(prefix + "/data/gfx/balloon/balloon3.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/balloon/balloon3.ani", AssetType::ANIMATION);
Asset::get().add(prefix + "/data/gfx/balloon/balloon4.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/balloon/balloon4.ani", AssetType::ANIMATION);
}
{ // Explosions
Asset::get()->add(prefix + "/data/gfx/balloon/explosion1.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/balloon/explosion1.ani", AssetType::ANIMATION);
Asset::get()->add(prefix + "/data/gfx/balloon/explosion2.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/balloon/explosion2.ani", AssetType::ANIMATION);
Asset::get()->add(prefix + "/data/gfx/balloon/explosion3.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/balloon/explosion3.ani", AssetType::ANIMATION);
Asset::get()->add(prefix + "/data/gfx/balloon/explosion4.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/balloon/explosion4.ani", AssetType::ANIMATION);
Asset::get().add(prefix + "/data/gfx/balloon/explosion1.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/balloon/explosion1.ani", AssetType::ANIMATION);
Asset::get().add(prefix + "/data/gfx/balloon/explosion2.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/balloon/explosion2.ani", AssetType::ANIMATION);
Asset::get().add(prefix + "/data/gfx/balloon/explosion3.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/balloon/explosion3.ani", AssetType::ANIMATION);
Asset::get().add(prefix + "/data/gfx/balloon/explosion4.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/balloon/explosion4.ani", AssetType::ANIMATION);
}
{ // Power Ball
Asset::get()->add(prefix + "/data/gfx/balloon/powerball.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/balloon/powerball.ani", AssetType::ANIMATION);
Asset::get().add(prefix + "/data/gfx/balloon/powerball.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/balloon/powerball.ani", AssetType::ANIMATION);
}
{ // Bala
Asset::get()->add(prefix + "/data/gfx/bullet/bullet.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/bullet/bullet.png", AssetType::BITMAP);
}
{ // Tabe
Asset::get()->add(prefix + "/data/gfx/tabe/tabe.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/tabe/tabe.ani", AssetType::ANIMATION);
Asset::get().add(prefix + "/data/gfx/tabe/tabe.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/tabe/tabe.ani", AssetType::ANIMATION);
}
{ // Juego
Asset::get()->add(prefix + "/data/gfx/game/game_buildings.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/game/game_clouds1.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/game/game_clouds2.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/game/game_grass.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/game/game_power_meter.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/game/game_sky_colors.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/game/game_sun.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/game/game_moon.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/game/game_buildings.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/game/game_clouds1.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/game/game_clouds2.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/game/game_grass.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/game/game_power_meter.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/game/game_sky_colors.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/game/game_sun.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/game/game_moon.png", AssetType::BITMAP);
}
{ // Intro
Asset::get()->add(prefix + "/data/gfx/intro/intro1.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/intro/intro2.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/intro/intro3.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/intro/intro4.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/intro/intro5.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/intro/intro6.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/intro/intro1.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/intro/intro2.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/intro/intro3.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/intro/intro4.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/intro/intro5.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/intro/intro6.png", AssetType::BITMAP);
}
{ // Logo
Asset::get()->add(prefix + "/data/gfx/logo/logo_jailgames.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/logo/logo_jailgames_mini.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/logo/logo_since_1998.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/logo/logo_jailgames.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/logo/logo_jailgames_mini.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/logo/logo_since_1998.png", AssetType::BITMAP);
}
{ // Items
Asset::get()->add(prefix + "/data/gfx/item/item_points1_disk.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/item/item_points1_disk.ani", AssetType::ANIMATION);
Asset::get()->add(prefix + "/data/gfx/item/item_points2_gavina.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/item/item_points2_gavina.ani", AssetType::ANIMATION);
Asset::get()->add(prefix + "/data/gfx/item/item_points3_pacmar.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/item/item_points3_pacmar.ani", AssetType::ANIMATION);
Asset::get()->add(prefix + "/data/gfx/item/item_clock.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/item/item_clock.ani", AssetType::ANIMATION);
Asset::get()->add(prefix + "/data/gfx/item/item_coffee.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/item/item_coffee.ani", AssetType::ANIMATION);
Asset::get()->add(prefix + "/data/gfx/item/item_debian.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/item/item_debian.ani", AssetType::ANIMATION);
Asset::get()->add(prefix + "/data/gfx/item/item_coffee_machine.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/item/item_coffee_machine.ani", AssetType::ANIMATION);
Asset::get().add(prefix + "/data/gfx/item/item_points1_disk.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/item/item_points1_disk.ani", AssetType::ANIMATION);
Asset::get().add(prefix + "/data/gfx/item/item_points2_gavina.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/item/item_points2_gavina.ani", AssetType::ANIMATION);
Asset::get().add(prefix + "/data/gfx/item/item_points3_pacmar.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/item/item_points3_pacmar.ani", AssetType::ANIMATION);
Asset::get().add(prefix + "/data/gfx/item/item_clock.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/item/item_clock.ani", AssetType::ANIMATION);
Asset::get().add(prefix + "/data/gfx/item/item_coffee.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/item/item_coffee.ani", AssetType::ANIMATION);
Asset::get().add(prefix + "/data/gfx/item/item_debian.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/item/item_debian.ani", AssetType::ANIMATION);
Asset::get().add(prefix + "/data/gfx/item/item_coffee_machine.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/item/item_coffee_machine.ani", AssetType::ANIMATION);
}
{ // Titulo
Asset::get()->add(prefix + "/data/gfx/title/title_bg_tile.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/title/title_coffee.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/title/title_crisis.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/title/title_arcade_edition.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/title/title_dust.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/title/title_dust.ani", AssetType::ANIMATION);
Asset::get().add(prefix + "/data/gfx/title/title_bg_tile.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/title/title_coffee.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/title/title_crisis.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/title/title_arcade_edition.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/title/title_dust.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/title/title_dust.ani", AssetType::ANIMATION);
}
{ // Jugador 1
Asset::get()->add(prefix + "/data/gfx/player/player1.gif", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/player/player1_1_coffee_palette.gif", AssetType::PALETTE);
Asset::get()->add(prefix + "/data/gfx/player/player1_2_coffee_palette.gif", AssetType::PALETTE);
Asset::get()->add(prefix + "/data/gfx/player/player1_invencible_palette.gif", AssetType::PALETTE);
Asset::get()->add(prefix + "/data/gfx/player/player1_power.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/player/player1.gif", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/player/player1_1_coffee_palette.gif", AssetType::PALETTE);
Asset::get().add(prefix + "/data/gfx/player/player1_2_coffee_palette.gif", AssetType::PALETTE);
Asset::get().add(prefix + "/data/gfx/player/player1_invencible_palette.gif", AssetType::PALETTE);
Asset::get().add(prefix + "/data/gfx/player/player1_power.png", AssetType::BITMAP);
}
{ // Jugador 2
Asset::get()->add(prefix + "/data/gfx/player/player2.gif", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/gfx/player/player2_1_coffee_palette.gif", AssetType::PALETTE);
Asset::get()->add(prefix + "/data/gfx/player/player2_2_coffee_palette.gif", AssetType::PALETTE);
Asset::get()->add(prefix + "/data/gfx/player/player2_invencible_palette.gif", AssetType::PALETTE);
Asset::get()->add(prefix + "/data/gfx/player/player2_power.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/player/player2.gif", AssetType::BITMAP);
Asset::get().add(prefix + "/data/gfx/player/player2_1_coffee_palette.gif", AssetType::PALETTE);
Asset::get().add(prefix + "/data/gfx/player/player2_2_coffee_palette.gif", AssetType::PALETTE);
Asset::get().add(prefix + "/data/gfx/player/player2_invencible_palette.gif", AssetType::PALETTE);
Asset::get().add(prefix + "/data/gfx/player/player2_power.png", AssetType::BITMAP);
}
{ // Animaciones del jugador
Asset::get()->add(prefix + "/data/gfx/player/player.ani", AssetType::ANIMATION);
Asset::get()->add(prefix + "/data/gfx/player/player_power.ani", AssetType::ANIMATION);
Asset::get().add(prefix + "/data/gfx/player/player.ani", AssetType::ANIMATION);
Asset::get().add(prefix + "/data/gfx/player/player_power.ani", AssetType::ANIMATION);
}
// Fuentes de texto
Asset::get()->add(prefix + "/data/font/8bithud.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/font/8bithud.txt", AssetType::FONT);
Asset::get()->add(prefix + "/data/font/smb2.gif", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/font/smb2_palette1.pal", AssetType::PALETTE);
Asset::get()->add(prefix + "/data/font/smb2.txt", AssetType::FONT);
Asset::get()->add(prefix + "/data/font/04b_25.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/font/04b_25.txt", AssetType::FONT);
Asset::get()->add(prefix + "/data/font/04b_25_2x.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/font/04b_25_2x.txt", AssetType::FONT);
Asset::get()->add(prefix + "/data/font/04b_25_metal.png", AssetType::BITMAP);
Asset::get()->add(prefix + "/data/font/04b_25_grey.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/font/8bithud.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/font/8bithud.txt", AssetType::FONT);
Asset::get().add(prefix + "/data/font/smb2.gif", AssetType::BITMAP);
Asset::get().add(prefix + "/data/font/smb2_palette1.pal", AssetType::PALETTE);
Asset::get().add(prefix + "/data/font/smb2.txt", AssetType::FONT);
Asset::get().add(prefix + "/data/font/04b_25.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/font/04b_25.txt", AssetType::FONT);
Asset::get().add(prefix + "/data/font/04b_25_2x.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/font/04b_25_2x.txt", AssetType::FONT);
Asset::get().add(prefix + "/data/font/04b_25_metal.png", AssetType::BITMAP);
Asset::get().add(prefix + "/data/font/04b_25_grey.png", AssetType::BITMAP);
// Textos
Asset::get()->add(prefix + "/data/lang/es_ES.txt", AssetType::LANG);
Asset::get()->add(prefix + "/data/lang/en_UK.txt", AssetType::LANG);
Asset::get()->add(prefix + "/data/lang/ba_BA.txt", AssetType::LANG);
Asset::get().add(prefix + "/data/lang/es_ES.txt", AssetType::LANG);
Asset::get().add(prefix + "/data/lang/en_UK.txt", AssetType::LANG);
Asset::get().add(prefix + "/data/lang/ba_BA.txt", AssetType::LANG);
// Si falta algun fichero, sale del programa
if (!Asset::get()->check())
if (!Asset::get().check())
{
throw std::runtime_error("Falta algun fichero");
}
@@ -601,8 +604,8 @@ void Director::runDemoGame()
// Ejecuta la sección init
void Director::runInit()
{
Audio::get()->stopMusic();
Audio::get()->stopAllSounds();
Audio::get().stopMusic();
Audio::get().stopAllSounds();
if (section::options == section::Options::RELOAD || true)
{
Resource::get()->reload();
@@ -674,19 +677,19 @@ std::string Director::getLangFile(lang::Code code)
switch (code)
{
case lang::Code::ba_BA:
return Asset::get()->get("ba_BA.txt");
return Asset::get().get("ba_BA.txt");
break;
case lang::Code::es_ES:
return Asset::get()->get("es_ES.txt");
return Asset::get().get("es_ES.txt");
break;
case lang::Code::en_UK:
return Asset::get()->get("en_UK.txt");
return Asset::get().get("en_UK.txt");
break;
default:
break;
}
return Asset::get()->get("en_UK.txt");
return Asset::get().get("en_UK.txt");
}
#ifdef ARCADE

View File

@@ -1,76 +1,13 @@
#pragma once
#include <string> // Para string
#include <string> // Para manejar cadenas de texto
namespace lang
{
enum class Code : int;
} // lines 8-8
}
class Director
{
private:
// Variables
std::string executable_path_; // Path del ejecutable
std::string system_folder_; // Carpeta del sistema donde guardar datos
// Asigna los botones y teclas al objeto Input
void bindInputs();
// Crea el indice de ficheros
void setFileList();
// Comprueba los parametros del programa
void checkProgramArguments(int argc, const char *argv[]);
// Crea la carpeta del sistema donde guardar datos
void createSystemFolder(const std::string &folder);
// Ejecuta la sección con el logo
void runLogo();
// Ejecuta la sección con la secuencia de introducción
void runIntro();
// Ejecuta la sección con el titulo del juego
void runTitle();
// Ejecuta la sección donde se juega al juego
void runGame();
// Ejecuta la sección donde se muestran las instrucciones
void runInstructions();
// Ejecuta la sección donde se muestran los creditos del programa
void runCredits();
// Ejecuta la sección donde se muestra la tabla de puntuaciones
void runHiScoreTable();
// Ejecuta el juego en modo demo
void runDemoGame();
// Ejecuta la sección init
void runInit();
// Obtiene una fichero a partir de un lang::Code
std::string getLangFile(lang::Code code);
#ifdef ARCADE
// Apaga el sistema
void shutdownSystem(bool should_shutdown);
#endif
// Inicializa todo
void init();
// Cierra todo
void close();
// Carga los parametros
void loadParams();
// Carga el fichero de puntuaciones
void loadScoreFile();
public:
// Constructor
Director(int argc, const char *argv[]);
@@ -78,6 +15,43 @@ public:
// Destructor
~Director();
// Bucle principal
// Bucle principal de la aplicación
int run();
};
private:
// Variables internas
std::string executable_path_; // Ruta del ejecutable
std::string system_folder_; // Carpeta del sistema para almacenar datos
// Inicialización y cierre del sistema
void init(); // Inicializa la aplicación
void close(); // Cierra y libera recursos
// Configuración inicial
void loadParams(); // Carga los parámetros del programa
void loadScoreFile(); // Carga el fichero de puntuaciones
void createSystemFolder(const std::string &folder); // Crea la carpeta del sistema
// Gestión de entrada y archivos
void bindInputs(); // Asigna botones y teclas al sistema de entrada
void setFileList(); // Crea el índice de archivos disponibles
void checkProgramArguments(int argc, const char *argv[]); // Verifica los parámetros del programa
// Diferentes secciones del programa
void runLogo(); // Ejecuta la pantalla con el logo
void runIntro(); // Ejecuta la introducción del juego
void runTitle(); // Ejecuta la pantalla de título
void runGame(); // Inicia el juego
void runInstructions(); // Muestra las instrucciones
void runCredits(); // Muestra los créditos del juego
void runHiScoreTable(); // Muestra la tabla de puntuaciones
void runDemoGame(); // Ejecuta el modo demo
void runInit(); // Ejecuta la fase de inicialización
// Gestión de archivos de idioma
std::string getLangFile(lang::Code code); // Obtiene un fichero de idioma según el código
#ifdef ARCADE
void shutdownSystem(bool should_shutdown); // Apaga el sistema (modo arcade)
#endif
};

View File

@@ -133,7 +133,7 @@ void EnterName::decIndex()
void EnterName::updateNameFromCharacterIndex()
{
name_.clear();
for (int i = 0; i < NAME_SIZE; ++i)
for (size_t i = 0; i < NAME_SIZE; ++i)
{
name_.push_back(character_list_[character_index_[i]]);
}

View File

@@ -20,7 +20,7 @@ class EnterName
private:
std::string character_list_; // Lista de todos los caracteres permitidos
std::string name_; // Nombre introducido
int position_ = 0; // Posición a editar del nombre
size_t position_ = 0; // Posición a editar del nombre
bool position_overflow_ = false; // Indica si hemos incrementado la posición más allá del límite
std::array<int, NAME_SIZE> character_index_; // Indice de la lista para cada uno de los caracteres que forman el nombre

View File

@@ -39,8 +39,6 @@
Game::Game(int player_id, int current_stage, bool demo)
: renderer_(Screen::get()->getRenderer()),
screen_(Screen::get()),
audio_(Audio::get()),
asset_(Asset::get()),
input_(Input::get()),
background_(std::make_unique<Background>()),
canvas_(SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.play_area.rect.w, param.game.play_area.rect.h)),
@@ -103,19 +101,19 @@ Game::~Game()
// [Modo DEMO] Vuelve a activar los sonidos
if (demo_.enabled)
{
audio_->enableSound();
Audio::get().enableSound();
}
else
{
// [Modo JUEGO] Guarda puntuaciones y transita a modo título
auto manager = std::make_unique<ManageHiScoreTable>(options.game.hi_score_table);
manager->saveToFile(asset_->get("score.bin"));
manager->saveToFile(Asset::get().get("score.bin"));
section::attract_mode = section::AttractMode::TITLE_TO_DEMO;
audio_->stopMusic();
Audio::get().stopMusic();
}
#ifdef RECORDING
saveDemoFile(Asset::get()->get("demo1.bin"), demo_.data.at(0));
saveDemoFile(Asset::get().get("demo1.bin"), demo_.data.at(0));
#endif
Scoreboard::destroy();
@@ -203,7 +201,7 @@ void Game::updateHiScore()
if (hi_score_achieved_ == false)
{
hi_score_achieved_ = true;
audio_->playSound("hi_score_achieved.wav");
Audio::get().playSound("hi_score_achieved.wav");
}
}
}
@@ -261,7 +259,7 @@ void Game::updateStage()
// Cambio de fase
Stage::power = Stage::get(Stage::number).power_to_complete - Stage::power;
++Stage::number;
audio_->playSound("stage_change.wav");
Audio::get().playSound("stage_change.wav");
balloon_manager_->resetBalloonSpeed();
screen_->flash(FLASH_COLOR, 3);
screen_->shake();
@@ -313,7 +311,7 @@ void Game::updateGameStateGameOver()
if (game_over_counter_ == GAME_OVER_COUNTER_)
{
createMessage({paths_.at(2), paths_.at(3)}, Resource::get()->getTexture("game_text_game_over"));
audio_->fadeOutMusic(1000);
Audio::get().fadeOutMusic(1000);
balloon_manager_->setSounds(true);
}
@@ -330,7 +328,7 @@ void Game::updateGameStateGameOver()
if (options.audio.enabled)
{
const float VOL = static_cast<float>(64 * (100 - fade_out_->getValue())) / 100.0f;
audio_->setSoundVolume(static_cast<int>(VOL));
Audio::get().setSoundVolume(static_cast<int>(VOL));
}
}
@@ -349,8 +347,8 @@ void Game::updateGameStateGameOver()
section::options = section::Options::HI_SCORE_AFTER_PLAYING;
if (options.audio.enabled)
{
audio_->stopAllSounds();
audio_->setSoundVolume(options.audio.sound.volume);
Audio::get().stopAllSounds();
Audio::get().setSoundVolume(options.audio.sound.volume);
}
}
}
@@ -483,7 +481,7 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
player->addScore(1000);
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(0)->getWidth()) / 2;
createItemText(x, game_text_textures_.at(0));
audio_->playSound("item_pickup.wav");
Audio::get().playSound("item_pickup.wav");
break;
}
case ItemType::GAVINA:
@@ -491,7 +489,7 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
player->addScore(2500);
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(1)->getWidth()) / 2;
createItemText(x, game_text_textures_.at(1));
audio_->playSound("item_pickup.wav");
Audio::get().playSound("item_pickup.wav");
break;
}
case ItemType::PACMAR:
@@ -499,7 +497,7 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
player->addScore(5000);
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(2)->getWidth()) / 2;
createItemText(x, game_text_textures_.at(2));
audio_->playSound("item_pickup.wav");
Audio::get().playSound("item_pickup.wav");
break;
}
case ItemType::DEBIAN:
@@ -507,7 +505,7 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
player->addScore(100000);
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(6)->getWidth()) / 2;
createItemText(x, game_text_textures_.at(6));
audio_->playSound("debian_pickup.wav");
Audio::get().playSound("debian_pickup.wav");
break;
}
case ItemType::CLOCK:
@@ -515,7 +513,7 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
enableTimeStopItem();
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(5)->getWidth()) / 2;
createItemText(x, game_text_textures_.at(5));
audio_->playSound("item_pickup.wav");
Audio::get().playSound("item_pickup.wav");
break;
}
case ItemType::COFFEE:
@@ -532,7 +530,7 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(4)->getWidth()) / 2;
createItemText(x, game_text_textures_.at(4));
}
audio_->playSound("voice_coffee.wav");
Audio::get().playSound("voice_coffee.wav");
break;
}
case ItemType::COFFEE_MACHINE:
@@ -541,7 +539,7 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
coffee_machine_enabled_ = false;
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(3)->getWidth()) / 2;
createItemText(x, game_text_textures_.at(3));
audio_->playSound("voice_power_up.wav");
Audio::get().playSound("voice_power_up.wav");
break;
}
default:
@@ -570,7 +568,7 @@ void Game::checkBulletCollision()
if (tabe_->tryToGetBonus())
{
createItem(ItemType::DEBIAN, pos.x, pos.y);
audio_->playSound("debian_drop.wav");
Audio::get().playSound("debian_drop.wav");
}
else
{
@@ -578,7 +576,7 @@ void Game::checkBulletCollision()
{
createItem(ItemType::COFFEE, pos.x, pos.y);
}
audio_->playSound("tabe_hit.wav");
Audio::get().playSound("tabe_hit.wav");
}
break;
}
@@ -600,7 +598,7 @@ void Game::checkBulletCollision()
if (dropped_item != ItemType::COFFEE_MACHINE)
{
createItem(dropped_item, balloon->getPosX(), balloon->getPosY());
audio_->playSound("item_drop.wav");
Audio::get().playSound("item_drop.wav");
}
else
{
@@ -622,7 +620,7 @@ void Game::checkBulletCollision()
updateHiScore();
// Sonido de explosión
audio_->playSound("balloon.wav");
Audio::get().playSound("balloon.wav");
// Deshabilita la bala
bullet->disable();
@@ -678,7 +676,7 @@ void Game::updateItems()
item->update();
if (item->isOnFloor())
{
audio_->playSound("title.wav");
Audio::get().playSound("title.wav");
screen_->shake();
}
}
@@ -905,16 +903,16 @@ void Game::killPlayer(std::shared_ptr<Player> &player)
// Lo pierde
player->removeExtraHit();
throwCoffee(player->getPosX() + (player->getWidth() / 2), player->getPosY() + (player->getHeight() / 2));
audio_->playSound("coffee_out.wav");
Audio::get().playSound("coffee_out.wav");
screen_->shake();
}
else
{
// Si no tiene cafes, muere
balloon_manager_->stopAllBalloons();
audio_->playSound("player_collision.wav");
Audio::get().playSound("player_collision.wav");
screen_->shake();
audio_->playSound("voice_no.wav");
Audio::get().playSound("voice_no.wav");
player->setPlayingState(PlayerState::DYING);
if (allPlayersAreNotPlaying())
{
@@ -934,7 +932,7 @@ void Game::updateTimeStopped()
{
if (time_stopped_counter_ % 30 == 0)
{
audio_->playSound("clock.wav");
Audio::get().playSound("clock.wav");
}
}
else
@@ -942,12 +940,12 @@ void Game::updateTimeStopped()
if (time_stopped_counter_ % 30 == 0)
{
balloon_manager_->normalColorsToAllBalloons();
audio_->playSound("clock.wav");
Audio::get().playSound("clock.wav");
}
else if (time_stopped_counter_ % 30 == 15)
{
balloon_manager_->reverseColorsToAllBalloons();
audio_->playSound("clock.wav");
Audio::get().playSound("clock.wav");
}
}
}
@@ -1270,7 +1268,7 @@ void Game::addScoreToScoreBoard(const std::shared_ptr<Player> &player)
const auto entry = HiScoreEntry(trim(player->getRecordName()), player->getScore(), player->get1CC());
auto manager = std::make_unique<ManageHiScoreTable>(options.game.hi_score_table);
options.game.last_hi_score_entry.at(player->getId() - 1) = manager->add(entry);
manager->saveToFile(asset_->get("score.bin"));
manager->saveToFile(Asset::get().get("score.bin"));
hi_score_.name = options.game.hi_score_table.front().name;
}
@@ -1429,7 +1427,7 @@ void Game::handleFireInput(const std::shared_ptr<Player> &player, BulletType bul
player->setInput(bulletType == BulletType::UP ? InputAction::FIRE_CENTER : bulletType == BulletType::LEFT ? InputAction::FIRE_LEFT
: InputAction::FIRE_RIGHT);
createBullet(player->getPosX() + (player->getWidth() / 2) - 6, player->getPosY() + (player->getHeight() / 2), bulletType, player->isPowerUp(), player->getId());
audio_->playSound("bullet.wav");
Audio::get().playSound("bullet.wav");
// Establece un tiempo de espera para el próximo disparo.
const int cooldown = player->isPowerUp() ? 5 : options.game.autofire ? 10
@@ -1631,7 +1629,7 @@ void Game::initDemo(int player_id)
}
// Deshabilita los sonidos
audio_->disableSound();
Audio::get().disableSound();
// Configura los marcadores
scoreboard_->setMode(SCOREBOARD_LEFT_PANEL, ScoreboardMode::DEMO);
@@ -1733,7 +1731,7 @@ void Game::initPlayers(int player_id)
// Hace sonar la música
void Game::playMusic()
{
audio_->playMusic("playing.ogg");
Audio::get().playMusic("playing.ogg");
}
// Detiene la música
@@ -1741,7 +1739,7 @@ void Game::stopMusic()
{
if (!demo_.enabled)
{
audio_->stopMusic();
Audio::get().stopMusic();
}
}
@@ -1825,7 +1823,7 @@ void Game::updateGameStateEnteringPlayer()
{
setState(GameState::SHOWING_GET_READY_MESSAGE);
createMessage({paths_.at(0), paths_.at(1)}, Resource::get()->getTexture("game_text_get_ready"));
audio_->playSound("voice_get_ready.wav");
Audio::get().playSound("voice_get_ready.wav");
}
}
}
@@ -1878,7 +1876,7 @@ void Game::updateGameStatePlaying()
checkAndUpdateBalloonSpeed();
checkState();
cleanVectors();
//playMusic();
// playMusic();
}
// Vacía los vectores de elementos deshabilitados

View File

@@ -123,8 +123,6 @@ private:
// Objetos y punteros
SDL_Renderer *renderer_; // El renderizador de la ventana
Screen *screen_; // Objeto encargado de dibujar en pantalla
Audio *audio_; // Objeto encargado de gestionar el audio
Asset *asset_; // Objeto que gestiona todos los ficheros de recursos
Input *input_; // Manejador de entrada
Scoreboard *scoreboard_; // Objeto para dibujar el marcador

View File

@@ -123,7 +123,7 @@ void GameLogo::update()
coffee_crisis_status_ = Status::SHAKING;
// Reproduce el efecto sonoro
Audio::get()->playSound("title.wav");
Audio::get().playSound("title.wav");
Screen::get()->flash(Color(0xFF, 0xFF, 0xFF), FLASH_LENGHT, FLASH_DELAY);
Screen::get()->shake();
}
@@ -187,7 +187,7 @@ void GameLogo::update()
zoom_ = 1.0f;
arcade_edition_sprite_->setZoom(zoom_);
shake_.init(1, 2, 8, arcade_edition_sprite_->getX());
Audio::get()->playSound("title.wav");
Audio::get().playSound("title.wav");
Screen::get()->flash(Color(0xFF, 0xFF, 0xFF), FLASH_LENGHT, FLASH_DELAY);
Screen::get()->shake();
}

View File

@@ -60,7 +60,7 @@ namespace globalInputs
void toggleAudio()
{
options.audio.enabled = !options.audio.enabled;
Audio::get()->enable(options.audio.enabled);
Audio::get().enable(options.audio.enabled);
Notifier::get()->show({"Audio " + boolToOnOff(options.audio.enabled)});
}
@@ -91,13 +91,13 @@ namespace globalInputs
switch (code)
{
case lang::Code::ba_BA:
return Asset::get()->get("ba_BA.txt");
return Asset::get().get("ba_BA.txt");
break;
case lang::Code::es_ES:
return Asset::get()->get("es_ES.txt");
return Asset::get().get("es_ES.txt");
break;
default:
return Asset::get()->get("en_UK.txt");
return Asset::get().get("en_UK.txt");
break;
}
}
@@ -151,7 +151,7 @@ namespace globalInputs
switch (section::name)
{
case section::Name::INTRO:
Audio::get()->stopMusic();
Audio::get().stopMusic();
/* Continua en el case de abajo */
case section::Name::LOGO:
case section::Name::HI_SCORE_TABLE:

View File

@@ -150,7 +150,7 @@ void HiScoreTable::checkInput()
// Bucle para la pantalla de instrucciones
void HiScoreTable::run()
{
Audio::get()->playMusic("title.ogg");
Audio::get().playMusic("title.ogg");
while (section::name == section::Name::HI_SCORE_TABLE)
{
checkInput();

View File

@@ -272,7 +272,7 @@ void Instructions::checkInput()
// Bucle para la pantalla de instrucciones
void Instructions::run()
{
Audio::get()->playMusic("title.ogg");
Audio::get().playMusic("title.ogg");
while (section::name == section::Name::INSTRUCTIONS)
{
checkInput();

View File

@@ -281,7 +281,7 @@ void Intro::render()
// Bucle principal
void Intro::run()
{
Audio::get()->playMusic("intro.ogg", 0);
Audio::get().playMusic("intro.ogg", 0);
while (section::name == section::Name::INTRO)
{
checkInput();
@@ -513,7 +513,7 @@ void Intro::updatePostState()
// Finaliza la intro después de 1 segundo
if (ELAPSED_TIME >= 1000)
{
Audio::get()->stopMusic();
Audio::get().stopMusic();
section::name = section::Name::TITLE;
section::options = section::Options::TITLE_1;
}

View File

@@ -165,7 +165,11 @@ void JA_Init(const int freq, const SDL_AudioFormat format, const int channels)
if (!sdlAudioDevice)
SDL_CloseAudioDevice(sdlAudioDevice);
sdlAudioDevice = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &JA_audioSpec);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, (sdlAudioDevice == 0) ? "Failed to initialize SDL audio!\n" : "OK!\n");
if (sdlAudioDevice == 0)
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to initialize SDL audio!\n");
else
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "SDL audio initialized successfully.\n");
// SDL_PauseAudioDevice(sdlAudioDevice);
JA_timerID = SDL_AddTimer(30, JA_UpdateCallback, nullptr);
}

View File

@@ -60,7 +60,7 @@ Logo::~Logo()
{
jail_texture_->setColor(255, 255, 255);
since_texture_->setColor(255, 255, 255);
Audio::get()->stopAllSounds();
Audio::get().stopAllSounds();
}
// Comprueba el manejador de eventos
@@ -84,7 +84,7 @@ void Logo::updateJAILGAMES()
{
if (counter_ == 30)
{
Audio::get()->playSound("logo.wav");
Audio::get().playSound("logo.wav");
}
if (counter_ > 30)
@@ -181,7 +181,7 @@ void Logo::render()
// Bucle para el logo del juego
void Logo::run()
{
Audio::get()->fadeOutMusic(300);
Audio::get().fadeOutMusic(300);
while (section::name == section::Name::LOGO)
{
checkInput();

View File

@@ -76,7 +76,7 @@ void Notifier::update()
if (notifications_[i].state == NotificationStatus::RISING)
{
// Reproduce el sonido de la notificación
Audio::get()->playSound("notify.wav");
Audio::get().playSound("notify.wav");
}
}
}

View File

@@ -221,7 +221,7 @@ void Player::move()
++step_counter_;
if (step_counter_ % 10 == 0)
{
Audio::get()->playSound("walk.wav");
Audio::get().playSound("walk.wav");
}
switch (id_)
@@ -252,7 +252,7 @@ void Player::move()
++step_counter_;
if (step_counter_ % 10 == 0)
{
Audio::get()->playSound("walk.wav");
Audio::get().playSound("walk.wav");
}
switch (id_)
@@ -752,7 +752,7 @@ void Player::decContinueCounter()
}
else
{
Audio::get()->playSound("continue_clock.wav");
Audio::get().playSound("continue_clock.wav");
}
}
@@ -798,5 +798,5 @@ void Player::shiftSprite()
void Player::playRandomBubbleSound()
{
const std::vector<std::string> sounds = {"bubble1.wav", "bubble2.wav", "bubble3.wav", "bubble4.wav"};
Audio::get()->playSound(sounds.at(rand() % sounds.size()));
Audio::get().playSound(sounds.at(rand() % sounds.size()));
}

View File

@@ -3,7 +3,7 @@
#include <algorithm> // Para find_if
#include <stdexcept> // Para runtime_error
#include "asset.h" // Para Asset, AssetType
#include "jail_audio.h" // Para JA_DeleteMusic, JA_DeleteSound, JA_LoadMusic
#include "jail_audio.h" // Para JA_DeleteMusic, JA_DeleteSound, JA_LoadMusic
#include "lang.h" // Para getText
#include "screen.h" // Para Screen
#include "text.h" // Para Text, loadTextFile
@@ -180,7 +180,7 @@ DemoData &Resource::getDemoData(int index)
void Resource::loadSounds()
{
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> SOUND FILES");
auto list = Asset::get()->getListByType(AssetType::SOUND);
auto list = Asset::get().getListByType(AssetType::SOUND);
sounds_.clear();
for (const auto &l : list)
@@ -195,7 +195,7 @@ void Resource::loadSounds()
void Resource::loadMusics()
{
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> MUSIC FILES");
auto list = Asset::get()->getListByType(AssetType::MUSIC);
auto list = Asset::get().getListByType(AssetType::MUSIC);
musics_.clear();
for (const auto &l : list)
@@ -210,7 +210,7 @@ void Resource::loadMusics()
void Resource::loadTextures()
{
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> TEXTURES");
auto list = Asset::get()->getListByType(AssetType::BITMAP);
auto list = Asset::get().getListByType(AssetType::BITMAP);
textures_.clear();
for (const auto &l : list)
@@ -224,7 +224,7 @@ void Resource::loadTextures()
void Resource::loadTextFiles()
{
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> TEXT FILES");
auto list = Asset::get()->getListByType(AssetType::FONT);
auto list = Asset::get().getListByType(AssetType::FONT);
text_files_.clear();
for (const auto &l : list)
@@ -238,7 +238,7 @@ void Resource::loadTextFiles()
void Resource::loadAnimations()
{
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> ANIMATIONS");
auto list = Asset::get()->getListByType(AssetType::ANIMATION);
auto list = Asset::get().getListByType(AssetType::ANIMATION);
animations_.clear();
for (const auto &l : list)
@@ -252,8 +252,8 @@ void Resource::loadAnimations()
void Resource::loadDemoData()
{
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> DEMO FILES");
demos_.emplace_back(loadDemoDataFromFile(Asset::get()->get("demo1.bin")));
demos_.emplace_back(loadDemoDataFromFile(Asset::get()->get("demo2.bin")));
demos_.emplace_back(loadDemoDataFromFile(Asset::get().get("demo1.bin")));
demos_.emplace_back(loadDemoDataFromFile(Asset::get().get("demo2.bin")));
}
// Añade paletas a las texturas
@@ -262,17 +262,17 @@ void Resource::addPalettes()
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> PALETTES");
// Jugador 1
getTexture("player1.gif")->addPaletteFromFile(Asset::get()->get("player1_1_coffee_palette.gif"));
getTexture("player1.gif")->addPaletteFromFile(Asset::get()->get("player1_2_coffee_palette.gif"));
getTexture("player1.gif")->addPaletteFromFile(Asset::get()->get("player1_invencible_palette.gif"));
getTexture("player1.gif")->addPaletteFromFile(Asset::get().get("player1_1_coffee_palette.gif"));
getTexture("player1.gif")->addPaletteFromFile(Asset::get().get("player1_2_coffee_palette.gif"));
getTexture("player1.gif")->addPaletteFromFile(Asset::get().get("player1_invencible_palette.gif"));
// Jugador 2
getTexture("player2.gif")->addPaletteFromFile(Asset::get()->get("player2_1_coffee_palette.gif"));
getTexture("player2.gif")->addPaletteFromFile(Asset::get()->get("player2_2_coffee_palette.gif"));
getTexture("player2.gif")->addPaletteFromFile(Asset::get()->get("player2_invencible_palette.gif"));
getTexture("player2.gif")->addPaletteFromFile(Asset::get().get("player2_1_coffee_palette.gif"));
getTexture("player2.gif")->addPaletteFromFile(Asset::get().get("player2_2_coffee_palette.gif"));
getTexture("player2.gif")->addPaletteFromFile(Asset::get().get("player2_invencible_palette.gif"));
// Fuentes
getTexture("smb2.gif")->addPaletteFromFile(Asset::get()->get("smb2_palette1.pal"));
getTexture("smb2.gif")->addPaletteFromFile(Asset::get().get("smb2_palette1.pal"));
}
// Crea texturas

View File

@@ -231,7 +231,7 @@ void Screen::renderInfo()
void Screen::loadShaders()
{
const std::string GLSL_FILE = param.game.game_area.rect.h == 256 ? "crtpi_256.glsl" : "crtpi_240.glsl";
std::ifstream f(Asset::get()->get(GLSL_FILE).c_str());
std::ifstream f(Asset::get().get(GLSL_FILE).c_str());
shader_source_ = std::string((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
}

70
source/service_menu.cpp Normal file
View File

@@ -0,0 +1,70 @@
#include "service_menu.h"
#include <iostream>
ServiceMenu::ServiceMenu() {
// Inicializa los valores por defecto del menú de servicio
is_active = false;
selected_option = 0;
options = {"Test de Sonido", "Test de Video", "Contadores", "Salir"};
}
void ServiceMenu::show() {
is_active = true;
while (is_active) {
render();
handle_input();
}
}
void ServiceMenu::render() {
std::cout << "=== MENÚ DE SERVICIO ===" << std::endl;
for (size_t i = 0; i < options.size(); ++i) {
if (i == selected_option)
std::cout << "> ";
else
std::cout << " ";
std::cout << options[i] << std::endl;
}
}
void ServiceMenu::handle_input() {
char input;
std::cin >> input;
switch (input) {
case 'w':
if (selected_option > 0) selected_option--;
break;
case 's':
if (selected_option < options.size() - 1) selected_option++;
break;
case '\n':
case '\r':
case 'e':
execute_option(selected_option);
break;
case 'q':
is_active = false;
break;
default:
break;
}
}
void ServiceMenu::execute_option(size_t option) {
switch (option) {
case 0:
std::cout << "Ejecutando test de sonido..." << std::endl;
break;
case 1:
std::cout << "Ejecutando test de video..." << std::endl;
break;
case 2:
std::cout << "Mostrando contadores..." << std::endl;
break;
case 3:
is_active = false;
break;
default:
break;
}
}

31
source/service_menu.h Normal file
View File

@@ -0,0 +1,31 @@
#pragma once
#include <vector>
#include <string>
class ServiceMenu
{
public:
static ServiceMenu &get_instance()
{
static ServiceMenu instance;
return instance;
}
// Eliminar copia y asignación
ServiceMenu(const ServiceMenu &) = delete;
ServiceMenu &operator=(const ServiceMenu &) = delete;
void show();
void render();
void handle_input();
void execute_option(size_t option);
private:
ServiceMenu();
~ServiceMenu() = default;
bool is_active;
size_t selected_option;
std::vector<std::string> options;
};

View File

@@ -131,7 +131,7 @@ void Tabe::setRandomFlyPath(TabeDirection direction, int lenght)
direction_ = direction;
fly_distance_ = lenght;
waiting_counter_ = 5 + rand() % 15;
Audio::get()->playSound("tabe.wav");
Audio::get().playSound("tabe.wav");
constexpr float SPEED = 2.0f;

View File

@@ -55,7 +55,7 @@ Title::Title()
Title::~Title()
{
Resource::get()->getTexture("smb2.gif")->setPalette(0);
Audio::get()->stopAllSounds();
Audio::get().stopAllSounds();
}
// Actualiza las variables del objeto
@@ -200,8 +200,8 @@ void Title::checkInput()
{
if ((state_ == TitleState::LOGO_FINISHED || ALLOW_TITLE_ANIMATION_SKIP) && !fade_->isEnabled())
{
Audio::get()->playSound("game_start.wav");
Audio::get()->fadeOutMusic(1500);
Audio::get().playSound("game_start.wav");
Audio::get().fadeOutMusic(1500);
switch (CONTROLLER.player_id)
{
case 1:
@@ -322,7 +322,7 @@ void Title::updateFade()
// Se ha pulsado para jugar
section::name = section::Name::GAME;
section::options = selection_;
Audio::get()->stopMusic();
Audio::get().stopMusic();
}
}
}
@@ -339,7 +339,7 @@ void Title::updateState()
if (game_logo_->hasFinished())
{
state_ = TitleState::LOGO_FINISHED;
Audio::get()->playMusic("title.ogg");
Audio::get().playMusic("title.ogg");
}
break;
}