convertit Asset i Audio
This commit is contained in:
@@ -5,39 +5,28 @@
|
|||||||
#include <string> // Para string
|
#include <string> // Para string
|
||||||
#include <vector> // Para vector
|
#include <vector> // Para vector
|
||||||
#include "moving_sprite.h" // Para MovingSprite
|
#include "moving_sprite.h" // Para MovingSprite
|
||||||
class Texture; // lines 9-9
|
class Texture;
|
||||||
|
|
||||||
struct Animation
|
struct Animation
|
||||||
{
|
{
|
||||||
std::string name; // Nombre de la animacion
|
std::string name; // Nombre de la animación
|
||||||
std::vector<SDL_FRect> frames; // Cada uno de los frames que componen la animación
|
std::vector<SDL_FRect> frames; // Frames que componen la animación
|
||||||
int speed; // Velocidad de la animación
|
int speed; // Velocidad de reproducción
|
||||||
int loop; // Indica a que frame vuelve la animación al terminar. -1 para que no vuelva
|
int loop; // Frame al que vuelve la animación al terminar (-1 para no repetir)
|
||||||
bool completed; // Indica si ha finalizado la animación
|
bool completed; // Indica si la animación ha finalizado
|
||||||
int current_frame; // Frame actual
|
int current_frame; // Frame actual en reproducción
|
||||||
int counter; // Contador para las animaciones
|
int counter; // Contador para la animación
|
||||||
|
|
||||||
Animation() : name(std::string()), speed(5), loop(0), completed(false), current_frame(0), counter(0) {}
|
Animation() : name(std::string()), speed(5), loop(0), completed(false), current_frame(0), counter(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
using AnimationsFileBuffer = std::vector<std::string>;
|
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);
|
AnimationsFileBuffer loadAnimationsFromFile(const std::string &file_path);
|
||||||
|
|
||||||
class AnimatedSprite : public MovingSprite
|
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:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
AnimatedSprite(std::shared_ptr<Texture> texture, const std::string &file_path);
|
AnimatedSprite(std::shared_ptr<Texture> texture, const std::string &file_path);
|
||||||
@@ -48,19 +37,22 @@ public:
|
|||||||
// Destructor
|
// Destructor
|
||||||
virtual ~AnimatedSprite() override = default;
|
virtual ~AnimatedSprite() override = default;
|
||||||
|
|
||||||
// Actualiza las variables del objeto
|
// Actualización del objeto
|
||||||
void update() override;
|
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
|
// Manipulación de animaciones
|
||||||
bool animationIsCompleted();
|
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
|
protected:
|
||||||
int getIndex(const std::string &name);
|
// 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
|
// Procesos internos
|
||||||
void setCurrentAnimation(const std::string &name = "default");
|
void animate(); // Calcula el frame actual de la animación
|
||||||
void setCurrentAnimation(int index = 0);
|
void loadFromAnimationsFileBuffer(const AnimationsFileBuffer &source); // Carga animaciones desde un buffer
|
||||||
|
|
||||||
// Reinicia la animación
|
|
||||||
void resetAnimation();
|
|
||||||
};
|
};
|
||||||
@@ -5,27 +5,6 @@
|
|||||||
#include <string> // Para allocator, string, char_traits, operator+
|
#include <string> // Para allocator, string, char_traits, operator+
|
||||||
#include "utils.h" // Para getFileName
|
#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
|
// Añade un elemento a la lista
|
||||||
void Asset::add(const std::string &file, AssetType type, bool required, bool absolute)
|
void Asset::add(const std::string &file, AssetType type, bool required, bool absolute)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string> // Para string
|
#include <string> // Para manejar cadenas de texto
|
||||||
#include <vector> // Para vector
|
#include <vector> // Para estructuras dinámicas de datos
|
||||||
#include "utils.h" // Para getPath
|
#include "utils.h" // Para la función getPath
|
||||||
|
|
||||||
enum class AssetType : int
|
enum class AssetType : int
|
||||||
{
|
{
|
||||||
@@ -21,59 +21,54 @@ enum class AssetType : int
|
|||||||
// Clase Asset
|
// Clase Asset
|
||||||
class Asset
|
class Asset
|
||||||
{
|
{
|
||||||
private:
|
public:
|
||||||
// [SINGLETON] Objeto asset privado
|
// Obtención de la instancia única (*Meyers Singleton*)
|
||||||
static Asset *asset_;
|
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
|
struct AssetItem
|
||||||
{
|
{
|
||||||
std::string file; // Ruta del fichero desde la raíz del directorio
|
std::string file; // Ruta del fichero desde la raíz del directorio
|
||||||
AssetType type; // Indica el tipo de recurso
|
AssetType type; // Tipo de recurso
|
||||||
bool required; // Indica si es un fichero que debe de existir
|
bool required; // Indica si el fichero es obligatorio
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
AssetItem(const std::string &filePath, AssetType assetType, bool isRequired)
|
AssetItem(const std::string &filePath, AssetType assetType, bool isRequired)
|
||||||
: file(filePath), type(assetType), required(isRequired) {}
|
: file(filePath), type(assetType), required(isRequired) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Variables
|
// Variables internas
|
||||||
int longest_name_ = 0; // Contiene la longitud del nombre de fichero mas largo
|
int longest_name_ = 0; // Longitud del nombre de archivo más largo
|
||||||
std::vector<AssetItem> file_list_; // Listado con todas las rutas a los ficheros
|
std::vector<AssetItem> file_list_; // Lista con todas las rutas de los archivos
|
||||||
std::string executable_path_; // Ruta al ejecutable
|
std::string executable_path_; // Ruta del ejecutable
|
||||||
|
|
||||||
// Comprueba que existe un fichero
|
// Métodos internos
|
||||||
bool checkFile(const std::string &path) const;
|
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
|
// Constructor privado
|
||||||
std::string getTypeName(AssetType type) const;
|
Asset() = default;
|
||||||
|
|
||||||
// Constructor
|
// Destructor privado
|
||||||
explicit Asset(const std::string &executable_path)
|
|
||||||
: executable_path_(getPath(executable_path)) {}
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
~Asset() = default;
|
~Asset() = default;
|
||||||
|
|
||||||
public:
|
// Evita copia y asignación
|
||||||
// [SINGLETON] Crearemos el objeto con esta función estática
|
Asset(const Asset &) = delete;
|
||||||
static void init(const std::string &executable_path);
|
Asset &operator=(const Asset &) = delete;
|
||||||
|
|
||||||
// [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;
|
|
||||||
};
|
};
|
||||||
@@ -4,27 +4,6 @@
|
|||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include <SDL3/SDL.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
|
// Constructor
|
||||||
Audio::Audio()
|
Audio::Audio()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,59 +5,57 @@
|
|||||||
|
|
||||||
class Audio
|
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:
|
public:
|
||||||
// [SINGLETON] Crearemos el objeto con esta función estática
|
// Obtención de la instancia única (*Meyers Singleton*)
|
||||||
static void init(); // Inicializa el objeto Singleton
|
static Audio &get()
|
||||||
|
{
|
||||||
|
static Audio instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
// [SINGLETON] Destruiremos el objeto con esta función estática
|
// Manejo de reproducción de música
|
||||||
static void destroy(); // Destruye el objeto Singleton
|
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
|
// Manejo de efectos de sonido
|
||||||
static Audio *get(); // Devuelve la instancia del Singleton
|
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
|
// Configuración de audio general
|
||||||
void pauseMusic(); // Pausa la música
|
|
||||||
void stopMusic(); // Detiene la música
|
|
||||||
|
|
||||||
void playSound(const std::string &name); // Reproduce un sonido
|
|
||||||
void stopAllSounds(); // Detiene todos los sonidos
|
|
||||||
|
|
||||||
void fadeOutMusic(int milliseconds); // Realiza un fundido de salida de la música
|
|
||||||
|
|
||||||
// Audio
|
|
||||||
void enable() { enabled_ = true; } // Habilita el audio
|
void enable() { enabled_ = true; } // Habilita el audio
|
||||||
void disable() { enabled_ = false; } // Deshabilita el audio
|
void disable() { enabled_ = false; } // Deshabilita el audio
|
||||||
void enable(bool value) { enabled_ = value; } // Habilita o deshabilita el audio
|
void enable(bool value) { enabled_ = value; } // Establece estado del audio
|
||||||
void toggleEnabled() { enabled_ = !enabled_; } // Alterna el estado del audio
|
void toggleEnabled() { enabled_ = !enabled_; } // Alterna estado del audio
|
||||||
|
|
||||||
// Sound
|
// Configuración de sonido
|
||||||
void enableSound() { sound_enabled_ = true; } // Habilita los sonidos
|
void enableSound() { sound_enabled_ = true; } // Habilita los sonidos
|
||||||
void disableSound() { sound_enabled_ = false; } // Deshabilita los sonidos
|
void disableSound() { sound_enabled_ = false; } // Deshabilita los sonidos
|
||||||
void enableSound(bool value) { sound_enabled_ = value; } // Habilita o deshabilita los sonidos
|
void enableSound(bool value) { sound_enabled_ = value; } // Establece estado de sonidos
|
||||||
void toggleSound() { sound_enabled_ = !sound_enabled_; } // Alterna el estado de los sonidos
|
void toggleSound() { sound_enabled_ = !sound_enabled_; } // Alterna estado de sonidos
|
||||||
|
|
||||||
// Music
|
// Configuración de música
|
||||||
void enableMusic() { music_enabled_ = true; } // Habilita la música
|
void enableMusic() { music_enabled_ = true; } // Habilita la música
|
||||||
void disableMusic() { music_enabled_ = false; } // Deshabilita 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 enableMusic(bool value) { music_enabled_ = value; } // Establece estado de música
|
||||||
void toggleMusic() { music_enabled_ = !music_enabled_; } // Alterna el estado de la música
|
void toggleMusic() { music_enabled_ = !music_enabled_; } // Alterna estado de música
|
||||||
|
|
||||||
// Volume
|
// Control de volumen
|
||||||
void setSoundVolume(int volume); // Establece el volumen de los sonidos
|
void setSoundVolume(int volume); // Ajusta volumen de efectos de sonido
|
||||||
void setMusicVolume(int volume); // Establece el volumen de la música
|
void setMusicVolume(int volume); // Ajusta volumen de música
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
// Constructor privado (Meyers Singleton)
|
||||||
|
Audio();
|
||||||
|
~Audio();
|
||||||
|
|
||||||
|
// Prevención de copia y asignación
|
||||||
|
Audio(const Audio &) = delete;
|
||||||
|
Audio &operator=(const Audio &) = delete;
|
||||||
};
|
};
|
||||||
@@ -414,6 +414,6 @@ void Balloon::playSound()
|
|||||||
{
|
{
|
||||||
if (sound_enabled_)
|
if (sound_enabled_)
|
||||||
{
|
{
|
||||||
Audio::get()->playSound(sound_);
|
Audio::get().playSound(sound_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -320,7 +320,7 @@ int BalloonManager::destroyAllBalloons()
|
|||||||
}
|
}
|
||||||
|
|
||||||
balloon_deploy_counter_ = 300;
|
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()->flash(FLASH_COLOR, 3);
|
||||||
Screen::get()->shake();
|
Screen::get()->shake();
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ Credits::~Credits()
|
|||||||
SDL_DestroyTexture(text_texture_);
|
SDL_DestroyTexture(text_texture_);
|
||||||
SDL_DestroyTexture(canvas_);
|
SDL_DestroyTexture(canvas_);
|
||||||
resetVolume();
|
resetVolume();
|
||||||
Audio::get()->stopMusic();
|
Audio::get().stopMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
@@ -437,7 +437,7 @@ void Credits::updateBlackRects()
|
|||||||
{
|
{
|
||||||
// Si los rectangulos izquierdo y derecho han llegado al centro
|
// Si los rectangulos izquierdo y derecho han llegado al centro
|
||||||
setVolume(0);
|
setVolume(0);
|
||||||
Audio::get()->stopMusic();
|
Audio::get().stopMusic();
|
||||||
if (counter_pre_fade_ == 400)
|
if (counter_pre_fade_ == 400)
|
||||||
{
|
{
|
||||||
fade_out_->activate();
|
fade_out_->activate();
|
||||||
@@ -471,7 +471,7 @@ void Credits::updateAllFades()
|
|||||||
fade_in_->update();
|
fade_in_->update();
|
||||||
if (fade_in_->hasEnded())
|
if (fade_in_->hasEnded())
|
||||||
{
|
{
|
||||||
Audio::get()->playMusic("credits.ogg");
|
Audio::get().playMusic("credits.ogg");
|
||||||
}
|
}
|
||||||
|
|
||||||
fade_out_->update();
|
fade_out_->update();
|
||||||
@@ -485,14 +485,14 @@ void Credits::updateAllFades()
|
|||||||
void Credits::setVolume(int amount)
|
void Credits::setVolume(int amount)
|
||||||
{
|
{
|
||||||
options.audio.music.volume = std::clamp(amount, 0, 100);
|
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
|
// Reestablece el nivel de volumen
|
||||||
void Credits::resetVolume()
|
void Credits::resetVolume()
|
||||||
{
|
{
|
||||||
options.audio.music.volume = initial_volume_;
|
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
|
// Cambia el color del fondo
|
||||||
|
|||||||
@@ -84,21 +84,26 @@ Director::~Director()
|
|||||||
// Inicializa todo
|
// Inicializa todo
|
||||||
void Director::init()
|
void Director::init()
|
||||||
{
|
{
|
||||||
Asset::init(executable_path_); // Crea el objeto que controla los ficheros de recursos
|
// Configuración inicial de recursos
|
||||||
setFileList(); // Crea el indice de ficheros
|
Asset::get().init(executable_path_); // Inicializa el sistema de gestión de archivos
|
||||||
loadOptionsFile(Asset::get()->get("config.txt")); // Carga el fichero de configuración
|
setFileList(); // Crea el índice de archivos
|
||||||
loadParams(); // Carga los parametros
|
loadOptionsFile(Asset::get().get("config.txt")); // Carga el archivo de configuración
|
||||||
loadScoreFile(); // Carga el fichero de puntuaciones
|
loadParams(); // Carga los parámetros del programa
|
||||||
|
loadScoreFile(); // Carga el archivo de puntuaciones
|
||||||
|
|
||||||
// Inicializa y crea el resto de objetos
|
// Inicialización de subsistemas
|
||||||
lang::loadFromFile(getLangFile(static_cast<lang::Code>(options.game.language)));
|
lang::loadFromFile(getLangFile(static_cast<lang::Code>(options.game.language))); // Carga el archivo de idioma
|
||||||
Screen::init();
|
Screen::init(); // Inicializa la pantalla y el sistema de renderizado
|
||||||
Audio::init();
|
Audio::get(); // Activa el sistema de audio
|
||||||
Resource::init();
|
Resource::init(); // Inicializa el sistema de gestión de recursos
|
||||||
Input::init(Asset::get()->get("gamecontrollerdb.txt"));
|
Input::init(Asset::get().get("gamecontrollerdb.txt")); // Carga configuración de controles
|
||||||
bindInputs();
|
bindInputs(); // Asigna los controles a la entrada del sistema
|
||||||
|
|
||||||
|
// Inicialización del sistema de notificaciones
|
||||||
Notifier::init(std::string(), Resource::get()->getText("8bithud"));
|
Notifier::init(std::string(), Resource::get()->getText("8bithud"));
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
// Configuración adicional en modo depuración
|
||||||
Screen::get()->initDebugInfo();
|
Screen::get()->initDebugInfo();
|
||||||
Screen::get()->setDebugInfoEnabled(true);
|
Screen::get()->setDebugInfoEnabled(true);
|
||||||
#endif
|
#endif
|
||||||
@@ -107,14 +112,12 @@ void Director::init()
|
|||||||
// Cierra todo
|
// Cierra todo
|
||||||
void Director::close()
|
void Director::close()
|
||||||
{
|
{
|
||||||
saveOptionsFile(Asset::get()->get("config.txt"));
|
saveOptionsFile(Asset::get().get("config.txt"));
|
||||||
|
|
||||||
Notifier::destroy();
|
Notifier::destroy();
|
||||||
Input::destroy();
|
Input::destroy();
|
||||||
Resource::destroy();
|
Resource::destroy();
|
||||||
Audio::destroy();
|
|
||||||
Screen::destroy();
|
Screen::destroy();
|
||||||
Asset::destroy();
|
|
||||||
|
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
|
||||||
@@ -130,7 +133,7 @@ void Director::loadParams()
|
|||||||
#ifdef ANBERNIC
|
#ifdef ANBERNIC
|
||||||
const std::string paramFilePath = asset->get("param_320x240.txt");
|
const std::string paramFilePath = asset->get("param_320x240.txt");
|
||||||
#else
|
#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
|
#endif
|
||||||
loadParamsFromFile(paramFilePath);
|
loadParamsFromFile(paramFilePath);
|
||||||
}
|
}
|
||||||
@@ -145,7 +148,7 @@ void Director::loadScoreFile()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
manager->loadFromFile(Asset::get()->get("score.bin"));
|
manager->loadFromFile(Asset::get().get("score.bin"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,189 +267,189 @@ void Director::setFileList()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Ficheros de configuración
|
// Ficheros de configuración
|
||||||
Asset::get()->add(system_folder_ + "/config.txt", AssetType::DATA, false, true);
|
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(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_320x240.txt", AssetType::DATA);
|
||||||
Asset::get()->add(prefix + "/data/config/param_320x256.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/demo1.bin", AssetType::DATA);
|
||||||
Asset::get()->add(prefix + "/data/config/demo2.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(prefix + "/data/config/gamecontrollerdb.txt", AssetType::DATA);
|
||||||
|
|
||||||
// Musicas
|
// Musicas
|
||||||
Asset::get()->add(prefix + "/data/music/intro.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/playing.ogg", AssetType::MUSIC);
|
||||||
Asset::get()->add(prefix + "/data/music/title.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/credits.ogg", AssetType::MUSIC);
|
||||||
|
|
||||||
// Sonidos
|
// Sonidos
|
||||||
Asset::get()->add(prefix + "/data/sound/balloon.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/bubble1.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/bubble2.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/bubble3.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/bubble4.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/bullet.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/clock.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/coffee_out.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/continue_clock.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/game_start.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/hi_score_achieved.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_drop.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/item_pickup.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/logo.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/notify.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/player_collision.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/power_ball_explosion.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/stage_change.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/tabe.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/title.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/voice_coffee.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_get_ready.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/voice_no.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/voice_power_up.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/walk.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_drop.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/debian_pickup.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/tabe_hit.wav", AssetType::SOUND);
|
||||||
|
|
||||||
// Shaders
|
// Shaders
|
||||||
Asset::get()->add(prefix + "/data/shaders/crtpi_256.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);
|
Asset::get().add(prefix + "/data/shaders/crtpi_240.glsl", AssetType::DATA);
|
||||||
|
|
||||||
// Texturas
|
// Texturas
|
||||||
|
|
||||||
{ // Controllers
|
{ // Controllers
|
||||||
Asset::get()->add(prefix + "/data/gfx/controllers/controllers.png", AssetType::BITMAP);
|
Asset::get().add(prefix + "/data/gfx/controllers/controllers.png", AssetType::BITMAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Balloons
|
{ // Balloons
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/balloon1.png", AssetType::BITMAP);
|
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/balloon1.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/balloon2.png", AssetType::BITMAP);
|
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/balloon2.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/balloon3.png", AssetType::BITMAP);
|
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/balloon3.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/balloon4.png", AssetType::BITMAP);
|
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/balloon4.ani", AssetType::ANIMATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Explosions
|
{ // Explosions
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/explosion1.png", AssetType::BITMAP);
|
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/explosion1.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/explosion2.png", AssetType::BITMAP);
|
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/explosion2.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/explosion3.png", AssetType::BITMAP);
|
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/explosion3.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/explosion4.png", AssetType::BITMAP);
|
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/explosion4.ani", AssetType::ANIMATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Power Ball
|
{ // Power Ball
|
||||||
Asset::get()->add(prefix + "/data/gfx/balloon/powerball.png", AssetType::BITMAP);
|
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.ani", AssetType::ANIMATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Bala
|
{ // Bala
|
||||||
Asset::get()->add(prefix + "/data/gfx/bullet/bullet.png", AssetType::BITMAP);
|
Asset::get().add(prefix + "/data/gfx/bullet/bullet.png", AssetType::BITMAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Tabe
|
{ // Tabe
|
||||||
Asset::get()->add(prefix + "/data/gfx/tabe/tabe.png", AssetType::BITMAP);
|
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.ani", AssetType::ANIMATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Juego
|
{ // Juego
|
||||||
Asset::get()->add(prefix + "/data/gfx/game/game_buildings.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_clouds1.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/game/game_clouds2.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_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_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_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_sun.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/game/game_moon.png", AssetType::BITMAP);
|
Asset::get().add(prefix + "/data/gfx/game/game_moon.png", AssetType::BITMAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Intro
|
{ // Intro
|
||||||
Asset::get()->add(prefix + "/data/gfx/intro/intro1.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/intro2.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/intro/intro3.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/intro4.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/intro/intro5.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/intro6.png", AssetType::BITMAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Logo
|
{ // Logo
|
||||||
Asset::get()->add(prefix + "/data/gfx/logo/logo_jailgames.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_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_since_1998.png", AssetType::BITMAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Items
|
{ // Items
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_points1_disk.png", AssetType::BITMAP);
|
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_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.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_points2_gavina.ani", AssetType::ANIMATION);
|
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.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_points3_pacmar.ani", AssetType::ANIMATION);
|
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.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_clock.ani", AssetType::ANIMATION);
|
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.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_coffee.ani", AssetType::ANIMATION);
|
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.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_debian.ani", AssetType::ANIMATION);
|
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.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/item/item_coffee_machine.ani", AssetType::ANIMATION);
|
Asset::get().add(prefix + "/data/gfx/item/item_coffee_machine.ani", AssetType::ANIMATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Titulo
|
{ // Titulo
|
||||||
Asset::get()->add(prefix + "/data/gfx/title/title_bg_tile.png", AssetType::BITMAP);
|
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_coffee.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/title/title_crisis.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_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.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/gfx/title/title_dust.ani", AssetType::ANIMATION);
|
Asset::get().add(prefix + "/data/gfx/title/title_dust.ani", AssetType::ANIMATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Jugador 1
|
{ // Jugador 1
|
||||||
Asset::get()->add(prefix + "/data/gfx/player/player1.gif", 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_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_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_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_power.png", AssetType::BITMAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Jugador 2
|
{ // Jugador 2
|
||||||
Asset::get()->add(prefix + "/data/gfx/player/player2.gif", 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_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_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_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_power.png", AssetType::BITMAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Animaciones del jugador
|
{ // Animaciones del jugador
|
||||||
Asset::get()->add(prefix + "/data/gfx/player/player.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);
|
Asset::get().add(prefix + "/data/gfx/player/player_power.ani", AssetType::ANIMATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fuentes de texto
|
// Fuentes de texto
|
||||||
Asset::get()->add(prefix + "/data/font/8bithud.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/8bithud.txt", AssetType::FONT);
|
||||||
Asset::get()->add(prefix + "/data/font/smb2.gif", AssetType::BITMAP);
|
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_palette1.pal", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/font/smb2.txt", AssetType::FONT);
|
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.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/font/04b_25.txt", AssetType::FONT);
|
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.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/font/04b_25_2x.txt", AssetType::FONT);
|
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_metal.png", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/font/04b_25_grey.png", AssetType::BITMAP);
|
Asset::get().add(prefix + "/data/font/04b_25_grey.png", AssetType::BITMAP);
|
||||||
|
|
||||||
// Textos
|
// Textos
|
||||||
Asset::get()->add(prefix + "/data/lang/es_ES.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/en_UK.txt", AssetType::LANG);
|
||||||
Asset::get()->add(prefix + "/data/lang/ba_BA.txt", AssetType::LANG);
|
Asset::get().add(prefix + "/data/lang/ba_BA.txt", AssetType::LANG);
|
||||||
|
|
||||||
// Si falta algun fichero, sale del programa
|
// Si falta algun fichero, sale del programa
|
||||||
if (!Asset::get()->check())
|
if (!Asset::get().check())
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Falta algun fichero");
|
throw std::runtime_error("Falta algun fichero");
|
||||||
}
|
}
|
||||||
@@ -601,8 +604,8 @@ void Director::runDemoGame()
|
|||||||
// Ejecuta la sección init
|
// Ejecuta la sección init
|
||||||
void Director::runInit()
|
void Director::runInit()
|
||||||
{
|
{
|
||||||
Audio::get()->stopMusic();
|
Audio::get().stopMusic();
|
||||||
Audio::get()->stopAllSounds();
|
Audio::get().stopAllSounds();
|
||||||
if (section::options == section::Options::RELOAD || true)
|
if (section::options == section::Options::RELOAD || true)
|
||||||
{
|
{
|
||||||
Resource::get()->reload();
|
Resource::get()->reload();
|
||||||
@@ -674,19 +677,19 @@ std::string Director::getLangFile(lang::Code code)
|
|||||||
switch (code)
|
switch (code)
|
||||||
{
|
{
|
||||||
case lang::Code::ba_BA:
|
case lang::Code::ba_BA:
|
||||||
return Asset::get()->get("ba_BA.txt");
|
return Asset::get().get("ba_BA.txt");
|
||||||
break;
|
break;
|
||||||
case lang::Code::es_ES:
|
case lang::Code::es_ES:
|
||||||
return Asset::get()->get("es_ES.txt");
|
return Asset::get().get("es_ES.txt");
|
||||||
break;
|
break;
|
||||||
case lang::Code::en_UK:
|
case lang::Code::en_UK:
|
||||||
return Asset::get()->get("en_UK.txt");
|
return Asset::get().get("en_UK.txt");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Asset::get()->get("en_UK.txt");
|
return Asset::get().get("en_UK.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ARCADE
|
#ifdef ARCADE
|
||||||
|
|||||||
@@ -1,76 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string> // Para string
|
#include <string> // Para manejar cadenas de texto
|
||||||
namespace lang
|
namespace lang
|
||||||
{
|
{
|
||||||
enum class Code : int;
|
enum class Code : int;
|
||||||
} // lines 8-8
|
}
|
||||||
|
|
||||||
class Director
|
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:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Director(int argc, const char *argv[]);
|
Director(int argc, const char *argv[]);
|
||||||
@@ -78,6 +15,43 @@ public:
|
|||||||
// Destructor
|
// Destructor
|
||||||
~Director();
|
~Director();
|
||||||
|
|
||||||
// Bucle principal
|
// Bucle principal de la aplicación
|
||||||
int run();
|
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
|
||||||
};
|
};
|
||||||
@@ -133,7 +133,7 @@ void EnterName::decIndex()
|
|||||||
void EnterName::updateNameFromCharacterIndex()
|
void EnterName::updateNameFromCharacterIndex()
|
||||||
{
|
{
|
||||||
name_.clear();
|
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]]);
|
name_.push_back(character_list_[character_index_[i]]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class EnterName
|
|||||||
private:
|
private:
|
||||||
std::string character_list_; // Lista de todos los caracteres permitidos
|
std::string character_list_; // Lista de todos los caracteres permitidos
|
||||||
std::string name_; // Nombre introducido
|
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
|
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
|
std::array<int, NAME_SIZE> character_index_; // Indice de la lista para cada uno de los caracteres que forman el nombre
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,6 @@
|
|||||||
Game::Game(int player_id, int current_stage, bool demo)
|
Game::Game(int player_id, int current_stage, bool demo)
|
||||||
: renderer_(Screen::get()->getRenderer()),
|
: renderer_(Screen::get()->getRenderer()),
|
||||||
screen_(Screen::get()),
|
screen_(Screen::get()),
|
||||||
audio_(Audio::get()),
|
|
||||||
asset_(Asset::get()),
|
|
||||||
input_(Input::get()),
|
input_(Input::get()),
|
||||||
background_(std::make_unique<Background>()),
|
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)),
|
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
|
// [Modo DEMO] Vuelve a activar los sonidos
|
||||||
if (demo_.enabled)
|
if (demo_.enabled)
|
||||||
{
|
{
|
||||||
audio_->enableSound();
|
Audio::get().enableSound();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// [Modo JUEGO] Guarda puntuaciones y transita a modo título
|
// [Modo JUEGO] Guarda puntuaciones y transita a modo título
|
||||||
auto manager = std::make_unique<ManageHiScoreTable>(options.game.hi_score_table);
|
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;
|
section::attract_mode = section::AttractMode::TITLE_TO_DEMO;
|
||||||
audio_->stopMusic();
|
Audio::get().stopMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RECORDING
|
#ifdef RECORDING
|
||||||
saveDemoFile(Asset::get()->get("demo1.bin"), demo_.data.at(0));
|
saveDemoFile(Asset::get().get("demo1.bin"), demo_.data.at(0));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Scoreboard::destroy();
|
Scoreboard::destroy();
|
||||||
@@ -203,7 +201,7 @@ void Game::updateHiScore()
|
|||||||
if (hi_score_achieved_ == false)
|
if (hi_score_achieved_ == false)
|
||||||
{
|
{
|
||||||
hi_score_achieved_ = true;
|
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
|
// Cambio de fase
|
||||||
Stage::power = Stage::get(Stage::number).power_to_complete - Stage::power;
|
Stage::power = Stage::get(Stage::number).power_to_complete - Stage::power;
|
||||||
++Stage::number;
|
++Stage::number;
|
||||||
audio_->playSound("stage_change.wav");
|
Audio::get().playSound("stage_change.wav");
|
||||||
balloon_manager_->resetBalloonSpeed();
|
balloon_manager_->resetBalloonSpeed();
|
||||||
screen_->flash(FLASH_COLOR, 3);
|
screen_->flash(FLASH_COLOR, 3);
|
||||||
screen_->shake();
|
screen_->shake();
|
||||||
@@ -313,7 +311,7 @@ void Game::updateGameStateGameOver()
|
|||||||
if (game_over_counter_ == GAME_OVER_COUNTER_)
|
if (game_over_counter_ == GAME_OVER_COUNTER_)
|
||||||
{
|
{
|
||||||
createMessage({paths_.at(2), paths_.at(3)}, Resource::get()->getTexture("game_text_game_over"));
|
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);
|
balloon_manager_->setSounds(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,7 +328,7 @@ void Game::updateGameStateGameOver()
|
|||||||
if (options.audio.enabled)
|
if (options.audio.enabled)
|
||||||
{
|
{
|
||||||
const float VOL = static_cast<float>(64 * (100 - fade_out_->getValue())) / 100.0f;
|
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;
|
section::options = section::Options::HI_SCORE_AFTER_PLAYING;
|
||||||
if (options.audio.enabled)
|
if (options.audio.enabled)
|
||||||
{
|
{
|
||||||
audio_->stopAllSounds();
|
Audio::get().stopAllSounds();
|
||||||
audio_->setSoundVolume(options.audio.sound.volume);
|
Audio::get().setSoundVolume(options.audio.sound.volume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -483,7 +481,7 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
|||||||
player->addScore(1000);
|
player->addScore(1000);
|
||||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(0)->getWidth()) / 2;
|
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(0)->getWidth()) / 2;
|
||||||
createItemText(x, game_text_textures_.at(0));
|
createItemText(x, game_text_textures_.at(0));
|
||||||
audio_->playSound("item_pickup.wav");
|
Audio::get().playSound("item_pickup.wav");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ItemType::GAVINA:
|
case ItemType::GAVINA:
|
||||||
@@ -491,7 +489,7 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
|||||||
player->addScore(2500);
|
player->addScore(2500);
|
||||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(1)->getWidth()) / 2;
|
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(1)->getWidth()) / 2;
|
||||||
createItemText(x, game_text_textures_.at(1));
|
createItemText(x, game_text_textures_.at(1));
|
||||||
audio_->playSound("item_pickup.wav");
|
Audio::get().playSound("item_pickup.wav");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ItemType::PACMAR:
|
case ItemType::PACMAR:
|
||||||
@@ -499,7 +497,7 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
|||||||
player->addScore(5000);
|
player->addScore(5000);
|
||||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(2)->getWidth()) / 2;
|
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(2)->getWidth()) / 2;
|
||||||
createItemText(x, game_text_textures_.at(2));
|
createItemText(x, game_text_textures_.at(2));
|
||||||
audio_->playSound("item_pickup.wav");
|
Audio::get().playSound("item_pickup.wav");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ItemType::DEBIAN:
|
case ItemType::DEBIAN:
|
||||||
@@ -507,7 +505,7 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
|||||||
player->addScore(100000);
|
player->addScore(100000);
|
||||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(6)->getWidth()) / 2;
|
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(6)->getWidth()) / 2;
|
||||||
createItemText(x, game_text_textures_.at(6));
|
createItemText(x, game_text_textures_.at(6));
|
||||||
audio_->playSound("debian_pickup.wav");
|
Audio::get().playSound("debian_pickup.wav");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ItemType::CLOCK:
|
case ItemType::CLOCK:
|
||||||
@@ -515,7 +513,7 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
|||||||
enableTimeStopItem();
|
enableTimeStopItem();
|
||||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(5)->getWidth()) / 2;
|
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(5)->getWidth()) / 2;
|
||||||
createItemText(x, game_text_textures_.at(5));
|
createItemText(x, game_text_textures_.at(5));
|
||||||
audio_->playSound("item_pickup.wav");
|
Audio::get().playSound("item_pickup.wav");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ItemType::COFFEE:
|
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;
|
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(4)->getWidth()) / 2;
|
||||||
createItemText(x, game_text_textures_.at(4));
|
createItemText(x, game_text_textures_.at(4));
|
||||||
}
|
}
|
||||||
audio_->playSound("voice_coffee.wav");
|
Audio::get().playSound("voice_coffee.wav");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ItemType::COFFEE_MACHINE:
|
case ItemType::COFFEE_MACHINE:
|
||||||
@@ -541,7 +539,7 @@ void Game::checkPlayerItemCollision(std::shared_ptr<Player> &player)
|
|||||||
coffee_machine_enabled_ = false;
|
coffee_machine_enabled_ = false;
|
||||||
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(3)->getWidth()) / 2;
|
const auto x = item->getPosX() + (item->getWidth() - game_text_textures_.at(3)->getWidth()) / 2;
|
||||||
createItemText(x, game_text_textures_.at(3));
|
createItemText(x, game_text_textures_.at(3));
|
||||||
audio_->playSound("voice_power_up.wav");
|
Audio::get().playSound("voice_power_up.wav");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -570,7 +568,7 @@ void Game::checkBulletCollision()
|
|||||||
if (tabe_->tryToGetBonus())
|
if (tabe_->tryToGetBonus())
|
||||||
{
|
{
|
||||||
createItem(ItemType::DEBIAN, pos.x, pos.y);
|
createItem(ItemType::DEBIAN, pos.x, pos.y);
|
||||||
audio_->playSound("debian_drop.wav");
|
Audio::get().playSound("debian_drop.wav");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -578,7 +576,7 @@ void Game::checkBulletCollision()
|
|||||||
{
|
{
|
||||||
createItem(ItemType::COFFEE, pos.x, pos.y);
|
createItem(ItemType::COFFEE, pos.x, pos.y);
|
||||||
}
|
}
|
||||||
audio_->playSound("tabe_hit.wav");
|
Audio::get().playSound("tabe_hit.wav");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -600,7 +598,7 @@ void Game::checkBulletCollision()
|
|||||||
if (dropped_item != ItemType::COFFEE_MACHINE)
|
if (dropped_item != ItemType::COFFEE_MACHINE)
|
||||||
{
|
{
|
||||||
createItem(dropped_item, balloon->getPosX(), balloon->getPosY());
|
createItem(dropped_item, balloon->getPosX(), balloon->getPosY());
|
||||||
audio_->playSound("item_drop.wav");
|
Audio::get().playSound("item_drop.wav");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -622,7 +620,7 @@ void Game::checkBulletCollision()
|
|||||||
updateHiScore();
|
updateHiScore();
|
||||||
|
|
||||||
// Sonido de explosión
|
// Sonido de explosión
|
||||||
audio_->playSound("balloon.wav");
|
Audio::get().playSound("balloon.wav");
|
||||||
|
|
||||||
// Deshabilita la bala
|
// Deshabilita la bala
|
||||||
bullet->disable();
|
bullet->disable();
|
||||||
@@ -678,7 +676,7 @@ void Game::updateItems()
|
|||||||
item->update();
|
item->update();
|
||||||
if (item->isOnFloor())
|
if (item->isOnFloor())
|
||||||
{
|
{
|
||||||
audio_->playSound("title.wav");
|
Audio::get().playSound("title.wav");
|
||||||
screen_->shake();
|
screen_->shake();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -905,16 +903,16 @@ void Game::killPlayer(std::shared_ptr<Player> &player)
|
|||||||
// Lo pierde
|
// Lo pierde
|
||||||
player->removeExtraHit();
|
player->removeExtraHit();
|
||||||
throwCoffee(player->getPosX() + (player->getWidth() / 2), player->getPosY() + (player->getHeight() / 2));
|
throwCoffee(player->getPosX() + (player->getWidth() / 2), player->getPosY() + (player->getHeight() / 2));
|
||||||
audio_->playSound("coffee_out.wav");
|
Audio::get().playSound("coffee_out.wav");
|
||||||
screen_->shake();
|
screen_->shake();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Si no tiene cafes, muere
|
// Si no tiene cafes, muere
|
||||||
balloon_manager_->stopAllBalloons();
|
balloon_manager_->stopAllBalloons();
|
||||||
audio_->playSound("player_collision.wav");
|
Audio::get().playSound("player_collision.wav");
|
||||||
screen_->shake();
|
screen_->shake();
|
||||||
audio_->playSound("voice_no.wav");
|
Audio::get().playSound("voice_no.wav");
|
||||||
player->setPlayingState(PlayerState::DYING);
|
player->setPlayingState(PlayerState::DYING);
|
||||||
if (allPlayersAreNotPlaying())
|
if (allPlayersAreNotPlaying())
|
||||||
{
|
{
|
||||||
@@ -934,7 +932,7 @@ void Game::updateTimeStopped()
|
|||||||
{
|
{
|
||||||
if (time_stopped_counter_ % 30 == 0)
|
if (time_stopped_counter_ % 30 == 0)
|
||||||
{
|
{
|
||||||
audio_->playSound("clock.wav");
|
Audio::get().playSound("clock.wav");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -942,12 +940,12 @@ void Game::updateTimeStopped()
|
|||||||
if (time_stopped_counter_ % 30 == 0)
|
if (time_stopped_counter_ % 30 == 0)
|
||||||
{
|
{
|
||||||
balloon_manager_->normalColorsToAllBalloons();
|
balloon_manager_->normalColorsToAllBalloons();
|
||||||
audio_->playSound("clock.wav");
|
Audio::get().playSound("clock.wav");
|
||||||
}
|
}
|
||||||
else if (time_stopped_counter_ % 30 == 15)
|
else if (time_stopped_counter_ % 30 == 15)
|
||||||
{
|
{
|
||||||
balloon_manager_->reverseColorsToAllBalloons();
|
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());
|
const auto entry = HiScoreEntry(trim(player->getRecordName()), player->getScore(), player->get1CC());
|
||||||
auto manager = std::make_unique<ManageHiScoreTable>(options.game.hi_score_table);
|
auto manager = std::make_unique<ManageHiScoreTable>(options.game.hi_score_table);
|
||||||
options.game.last_hi_score_entry.at(player->getId() - 1) = manager->add(entry);
|
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;
|
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
|
player->setInput(bulletType == BulletType::UP ? InputAction::FIRE_CENTER : bulletType == BulletType::LEFT ? InputAction::FIRE_LEFT
|
||||||
: InputAction::FIRE_RIGHT);
|
: InputAction::FIRE_RIGHT);
|
||||||
createBullet(player->getPosX() + (player->getWidth() / 2) - 6, player->getPosY() + (player->getHeight() / 2), bulletType, player->isPowerUp(), player->getId());
|
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.
|
// Establece un tiempo de espera para el próximo disparo.
|
||||||
const int cooldown = player->isPowerUp() ? 5 : options.game.autofire ? 10
|
const int cooldown = player->isPowerUp() ? 5 : options.game.autofire ? 10
|
||||||
@@ -1631,7 +1629,7 @@ void Game::initDemo(int player_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Deshabilita los sonidos
|
// Deshabilita los sonidos
|
||||||
audio_->disableSound();
|
Audio::get().disableSound();
|
||||||
|
|
||||||
// Configura los marcadores
|
// Configura los marcadores
|
||||||
scoreboard_->setMode(SCOREBOARD_LEFT_PANEL, ScoreboardMode::DEMO);
|
scoreboard_->setMode(SCOREBOARD_LEFT_PANEL, ScoreboardMode::DEMO);
|
||||||
@@ -1733,7 +1731,7 @@ void Game::initPlayers(int player_id)
|
|||||||
// Hace sonar la música
|
// Hace sonar la música
|
||||||
void Game::playMusic()
|
void Game::playMusic()
|
||||||
{
|
{
|
||||||
audio_->playMusic("playing.ogg");
|
Audio::get().playMusic("playing.ogg");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detiene la música
|
// Detiene la música
|
||||||
@@ -1741,7 +1739,7 @@ void Game::stopMusic()
|
|||||||
{
|
{
|
||||||
if (!demo_.enabled)
|
if (!demo_.enabled)
|
||||||
{
|
{
|
||||||
audio_->stopMusic();
|
Audio::get().stopMusic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1825,7 +1823,7 @@ void Game::updateGameStateEnteringPlayer()
|
|||||||
{
|
{
|
||||||
setState(GameState::SHOWING_GET_READY_MESSAGE);
|
setState(GameState::SHOWING_GET_READY_MESSAGE);
|
||||||
createMessage({paths_.at(0), paths_.at(1)}, Resource::get()->getTexture("game_text_get_ready"));
|
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();
|
checkAndUpdateBalloonSpeed();
|
||||||
checkState();
|
checkState();
|
||||||
cleanVectors();
|
cleanVectors();
|
||||||
//playMusic();
|
// playMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vacía los vectores de elementos deshabilitados
|
// Vacía los vectores de elementos deshabilitados
|
||||||
|
|||||||
@@ -123,8 +123,6 @@ private:
|
|||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
SDL_Renderer *renderer_; // El renderizador de la ventana
|
SDL_Renderer *renderer_; // El renderizador de la ventana
|
||||||
Screen *screen_; // Objeto encargado de dibujar en pantalla
|
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
|
Input *input_; // Manejador de entrada
|
||||||
Scoreboard *scoreboard_; // Objeto para dibujar el marcador
|
Scoreboard *scoreboard_; // Objeto para dibujar el marcador
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ void GameLogo::update()
|
|||||||
coffee_crisis_status_ = Status::SHAKING;
|
coffee_crisis_status_ = Status::SHAKING;
|
||||||
|
|
||||||
// Reproduce el efecto sonoro
|
// 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()->flash(Color(0xFF, 0xFF, 0xFF), FLASH_LENGHT, FLASH_DELAY);
|
||||||
Screen::get()->shake();
|
Screen::get()->shake();
|
||||||
}
|
}
|
||||||
@@ -187,7 +187,7 @@ void GameLogo::update()
|
|||||||
zoom_ = 1.0f;
|
zoom_ = 1.0f;
|
||||||
arcade_edition_sprite_->setZoom(zoom_);
|
arcade_edition_sprite_->setZoom(zoom_);
|
||||||
shake_.init(1, 2, 8, arcade_edition_sprite_->getX());
|
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()->flash(Color(0xFF, 0xFF, 0xFF), FLASH_LENGHT, FLASH_DELAY);
|
||||||
Screen::get()->shake();
|
Screen::get()->shake();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ namespace globalInputs
|
|||||||
void toggleAudio()
|
void toggleAudio()
|
||||||
{
|
{
|
||||||
options.audio.enabled = !options.audio.enabled;
|
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)});
|
Notifier::get()->show({"Audio " + boolToOnOff(options.audio.enabled)});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,13 +91,13 @@ namespace globalInputs
|
|||||||
switch (code)
|
switch (code)
|
||||||
{
|
{
|
||||||
case lang::Code::ba_BA:
|
case lang::Code::ba_BA:
|
||||||
return Asset::get()->get("ba_BA.txt");
|
return Asset::get().get("ba_BA.txt");
|
||||||
break;
|
break;
|
||||||
case lang::Code::es_ES:
|
case lang::Code::es_ES:
|
||||||
return Asset::get()->get("es_ES.txt");
|
return Asset::get().get("es_ES.txt");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return Asset::get()->get("en_UK.txt");
|
return Asset::get().get("en_UK.txt");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ namespace globalInputs
|
|||||||
switch (section::name)
|
switch (section::name)
|
||||||
{
|
{
|
||||||
case section::Name::INTRO:
|
case section::Name::INTRO:
|
||||||
Audio::get()->stopMusic();
|
Audio::get().stopMusic();
|
||||||
/* Continua en el case de abajo */
|
/* Continua en el case de abajo */
|
||||||
case section::Name::LOGO:
|
case section::Name::LOGO:
|
||||||
case section::Name::HI_SCORE_TABLE:
|
case section::Name::HI_SCORE_TABLE:
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ void HiScoreTable::checkInput()
|
|||||||
// Bucle para la pantalla de instrucciones
|
// Bucle para la pantalla de instrucciones
|
||||||
void HiScoreTable::run()
|
void HiScoreTable::run()
|
||||||
{
|
{
|
||||||
Audio::get()->playMusic("title.ogg");
|
Audio::get().playMusic("title.ogg");
|
||||||
while (section::name == section::Name::HI_SCORE_TABLE)
|
while (section::name == section::Name::HI_SCORE_TABLE)
|
||||||
{
|
{
|
||||||
checkInput();
|
checkInput();
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ void Instructions::checkInput()
|
|||||||
// Bucle para la pantalla de instrucciones
|
// Bucle para la pantalla de instrucciones
|
||||||
void Instructions::run()
|
void Instructions::run()
|
||||||
{
|
{
|
||||||
Audio::get()->playMusic("title.ogg");
|
Audio::get().playMusic("title.ogg");
|
||||||
while (section::name == section::Name::INSTRUCTIONS)
|
while (section::name == section::Name::INSTRUCTIONS)
|
||||||
{
|
{
|
||||||
checkInput();
|
checkInput();
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ void Intro::render()
|
|||||||
// Bucle principal
|
// Bucle principal
|
||||||
void Intro::run()
|
void Intro::run()
|
||||||
{
|
{
|
||||||
Audio::get()->playMusic("intro.ogg", 0);
|
Audio::get().playMusic("intro.ogg", 0);
|
||||||
while (section::name == section::Name::INTRO)
|
while (section::name == section::Name::INTRO)
|
||||||
{
|
{
|
||||||
checkInput();
|
checkInput();
|
||||||
@@ -513,7 +513,7 @@ void Intro::updatePostState()
|
|||||||
// Finaliza la intro después de 1 segundo
|
// Finaliza la intro después de 1 segundo
|
||||||
if (ELAPSED_TIME >= 1000)
|
if (ELAPSED_TIME >= 1000)
|
||||||
{
|
{
|
||||||
Audio::get()->stopMusic();
|
Audio::get().stopMusic();
|
||||||
section::name = section::Name::TITLE;
|
section::name = section::Name::TITLE;
|
||||||
section::options = section::Options::TITLE_1;
|
section::options = section::Options::TITLE_1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,7 +165,11 @@ void JA_Init(const int freq, const SDL_AudioFormat format, const int channels)
|
|||||||
if (!sdlAudioDevice)
|
if (!sdlAudioDevice)
|
||||||
SDL_CloseAudioDevice(sdlAudioDevice);
|
SDL_CloseAudioDevice(sdlAudioDevice);
|
||||||
sdlAudioDevice = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &JA_audioSpec);
|
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);
|
// SDL_PauseAudioDevice(sdlAudioDevice);
|
||||||
JA_timerID = SDL_AddTimer(30, JA_UpdateCallback, nullptr);
|
JA_timerID = SDL_AddTimer(30, JA_UpdateCallback, nullptr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ Logo::~Logo()
|
|||||||
{
|
{
|
||||||
jail_texture_->setColor(255, 255, 255);
|
jail_texture_->setColor(255, 255, 255);
|
||||||
since_texture_->setColor(255, 255, 255);
|
since_texture_->setColor(255, 255, 255);
|
||||||
Audio::get()->stopAllSounds();
|
Audio::get().stopAllSounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
@@ -84,7 +84,7 @@ void Logo::updateJAILGAMES()
|
|||||||
{
|
{
|
||||||
if (counter_ == 30)
|
if (counter_ == 30)
|
||||||
{
|
{
|
||||||
Audio::get()->playSound("logo.wav");
|
Audio::get().playSound("logo.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (counter_ > 30)
|
if (counter_ > 30)
|
||||||
@@ -181,7 +181,7 @@ void Logo::render()
|
|||||||
// Bucle para el logo del juego
|
// Bucle para el logo del juego
|
||||||
void Logo::run()
|
void Logo::run()
|
||||||
{
|
{
|
||||||
Audio::get()->fadeOutMusic(300);
|
Audio::get().fadeOutMusic(300);
|
||||||
while (section::name == section::Name::LOGO)
|
while (section::name == section::Name::LOGO)
|
||||||
{
|
{
|
||||||
checkInput();
|
checkInput();
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ void Notifier::update()
|
|||||||
if (notifications_[i].state == NotificationStatus::RISING)
|
if (notifications_[i].state == NotificationStatus::RISING)
|
||||||
{
|
{
|
||||||
// Reproduce el sonido de la notificación
|
// Reproduce el sonido de la notificación
|
||||||
Audio::get()->playSound("notify.wav");
|
Audio::get().playSound("notify.wav");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ void Player::move()
|
|||||||
++step_counter_;
|
++step_counter_;
|
||||||
if (step_counter_ % 10 == 0)
|
if (step_counter_ % 10 == 0)
|
||||||
{
|
{
|
||||||
Audio::get()->playSound("walk.wav");
|
Audio::get().playSound("walk.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (id_)
|
switch (id_)
|
||||||
@@ -252,7 +252,7 @@ void Player::move()
|
|||||||
++step_counter_;
|
++step_counter_;
|
||||||
if (step_counter_ % 10 == 0)
|
if (step_counter_ % 10 == 0)
|
||||||
{
|
{
|
||||||
Audio::get()->playSound("walk.wav");
|
Audio::get().playSound("walk.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (id_)
|
switch (id_)
|
||||||
@@ -752,7 +752,7 @@ void Player::decContinueCounter()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Audio::get()->playSound("continue_clock.wav");
|
Audio::get().playSound("continue_clock.wav");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -798,5 +798,5 @@ void Player::shiftSprite()
|
|||||||
void Player::playRandomBubbleSound()
|
void Player::playRandomBubbleSound()
|
||||||
{
|
{
|
||||||
const std::vector<std::string> sounds = {"bubble1.wav", "bubble2.wav", "bubble3.wav", "bubble4.wav"};
|
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()));
|
||||||
}
|
}
|
||||||
@@ -180,7 +180,7 @@ DemoData &Resource::getDemoData(int index)
|
|||||||
void Resource::loadSounds()
|
void Resource::loadSounds()
|
||||||
{
|
{
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> SOUND FILES");
|
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();
|
sounds_.clear();
|
||||||
|
|
||||||
for (const auto &l : list)
|
for (const auto &l : list)
|
||||||
@@ -195,7 +195,7 @@ void Resource::loadSounds()
|
|||||||
void Resource::loadMusics()
|
void Resource::loadMusics()
|
||||||
{
|
{
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> MUSIC FILES");
|
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();
|
musics_.clear();
|
||||||
|
|
||||||
for (const auto &l : list)
|
for (const auto &l : list)
|
||||||
@@ -210,7 +210,7 @@ void Resource::loadMusics()
|
|||||||
void Resource::loadTextures()
|
void Resource::loadTextures()
|
||||||
{
|
{
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> TEXTURES");
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> TEXTURES");
|
||||||
auto list = Asset::get()->getListByType(AssetType::BITMAP);
|
auto list = Asset::get().getListByType(AssetType::BITMAP);
|
||||||
textures_.clear();
|
textures_.clear();
|
||||||
|
|
||||||
for (const auto &l : list)
|
for (const auto &l : list)
|
||||||
@@ -224,7 +224,7 @@ void Resource::loadTextures()
|
|||||||
void Resource::loadTextFiles()
|
void Resource::loadTextFiles()
|
||||||
{
|
{
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> TEXT FILES");
|
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();
|
text_files_.clear();
|
||||||
|
|
||||||
for (const auto &l : list)
|
for (const auto &l : list)
|
||||||
@@ -238,7 +238,7 @@ void Resource::loadTextFiles()
|
|||||||
void Resource::loadAnimations()
|
void Resource::loadAnimations()
|
||||||
{
|
{
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> ANIMATIONS");
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> ANIMATIONS");
|
||||||
auto list = Asset::get()->getListByType(AssetType::ANIMATION);
|
auto list = Asset::get().getListByType(AssetType::ANIMATION);
|
||||||
animations_.clear();
|
animations_.clear();
|
||||||
|
|
||||||
for (const auto &l : list)
|
for (const auto &l : list)
|
||||||
@@ -252,8 +252,8 @@ void Resource::loadAnimations()
|
|||||||
void Resource::loadDemoData()
|
void Resource::loadDemoData()
|
||||||
{
|
{
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> DEMO FILES");
|
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("demo1.bin")));
|
||||||
demos_.emplace_back(loadDemoDataFromFile(Asset::get()->get("demo2.bin")));
|
demos_.emplace_back(loadDemoDataFromFile(Asset::get().get("demo2.bin")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Añade paletas a las texturas
|
// Añade paletas a las texturas
|
||||||
@@ -262,17 +262,17 @@ void Resource::addPalettes()
|
|||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> PALETTES");
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> PALETTES");
|
||||||
|
|
||||||
// Jugador 1
|
// Jugador 1
|
||||||
getTexture("player1.gif")->addPaletteFromFile(Asset::get()->get("player1_1_coffee_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_2_coffee_palette.gif"));
|
||||||
getTexture("player1.gif")->addPaletteFromFile(Asset::get()->get("player1_invencible_palette.gif"));
|
getTexture("player1.gif")->addPaletteFromFile(Asset::get().get("player1_invencible_palette.gif"));
|
||||||
|
|
||||||
// Jugador 2
|
// Jugador 2
|
||||||
getTexture("player2.gif")->addPaletteFromFile(Asset::get()->get("player2_1_coffee_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_2_coffee_palette.gif"));
|
||||||
getTexture("player2.gif")->addPaletteFromFile(Asset::get()->get("player2_invencible_palette.gif"));
|
getTexture("player2.gif")->addPaletteFromFile(Asset::get().get("player2_invencible_palette.gif"));
|
||||||
|
|
||||||
// Fuentes
|
// Fuentes
|
||||||
getTexture("smb2.gif")->addPaletteFromFile(Asset::get()->get("smb2_palette1.pal"));
|
getTexture("smb2.gif")->addPaletteFromFile(Asset::get().get("smb2_palette1.pal"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crea texturas
|
// Crea texturas
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ void Screen::renderInfo()
|
|||||||
void Screen::loadShaders()
|
void Screen::loadShaders()
|
||||||
{
|
{
|
||||||
const std::string GLSL_FILE = param.game.game_area.rect.h == 256 ? "crtpi_256.glsl" : "crtpi_240.glsl";
|
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>());
|
shader_source_ = std::string((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
70
source/service_menu.cpp
Normal file
70
source/service_menu.cpp
Normal 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
31
source/service_menu.h
Normal 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;
|
||||||
|
};
|
||||||
@@ -131,7 +131,7 @@ void Tabe::setRandomFlyPath(TabeDirection direction, int lenght)
|
|||||||
direction_ = direction;
|
direction_ = direction;
|
||||||
fly_distance_ = lenght;
|
fly_distance_ = lenght;
|
||||||
waiting_counter_ = 5 + rand() % 15;
|
waiting_counter_ = 5 + rand() % 15;
|
||||||
Audio::get()->playSound("tabe.wav");
|
Audio::get().playSound("tabe.wav");
|
||||||
|
|
||||||
constexpr float SPEED = 2.0f;
|
constexpr float SPEED = 2.0f;
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ Title::Title()
|
|||||||
Title::~Title()
|
Title::~Title()
|
||||||
{
|
{
|
||||||
Resource::get()->getTexture("smb2.gif")->setPalette(0);
|
Resource::get()->getTexture("smb2.gif")->setPalette(0);
|
||||||
Audio::get()->stopAllSounds();
|
Audio::get().stopAllSounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las variables del objeto
|
// Actualiza las variables del objeto
|
||||||
@@ -200,8 +200,8 @@ void Title::checkInput()
|
|||||||
{
|
{
|
||||||
if ((state_ == TitleState::LOGO_FINISHED || ALLOW_TITLE_ANIMATION_SKIP) && !fade_->isEnabled())
|
if ((state_ == TitleState::LOGO_FINISHED || ALLOW_TITLE_ANIMATION_SKIP) && !fade_->isEnabled())
|
||||||
{
|
{
|
||||||
Audio::get()->playSound("game_start.wav");
|
Audio::get().playSound("game_start.wav");
|
||||||
Audio::get()->fadeOutMusic(1500);
|
Audio::get().fadeOutMusic(1500);
|
||||||
switch (CONTROLLER.player_id)
|
switch (CONTROLLER.player_id)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
@@ -322,7 +322,7 @@ void Title::updateFade()
|
|||||||
// Se ha pulsado para jugar
|
// Se ha pulsado para jugar
|
||||||
section::name = section::Name::GAME;
|
section::name = section::Name::GAME;
|
||||||
section::options = selection_;
|
section::options = selection_;
|
||||||
Audio::get()->stopMusic();
|
Audio::get().stopMusic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -339,7 +339,7 @@ void Title::updateState()
|
|||||||
if (game_logo_->hasFinished())
|
if (game_logo_->hasFinished())
|
||||||
{
|
{
|
||||||
state_ = TitleState::LOGO_FINISHED;
|
state_ = TitleState::LOGO_FINISHED;
|
||||||
Audio::get()->playMusic("title.ogg");
|
Audio::get().playMusic("title.ogg");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user