renomena tipus _t/_e a CamelCase (Circle, Color, Section, ...)

This commit is contained in:
2026-05-14 22:16:36 +02:00
parent 9a2da460cc
commit 0bc55f5732
37 changed files with 209 additions and 209 deletions
+1 -1
View File
@@ -380,7 +380,7 @@ void Input::setVerbose(bool value) {
}
// Deshabilita las entradas durante un periodo de tiempo
void Input::disableUntil(i_disable_e value) {
void Input::disableUntil(InputDisable value) {
disabledUntil = value;
enabled = false;
}
+4 -4
View File
@@ -15,7 +15,7 @@ constexpr int INPUT_USE_KEYBOARD = 0;
constexpr int INPUT_USE_GAMECONTROLLER = 1;
constexpr int INPUT_USE_ANY = 2;
enum inputs_e : std::uint8_t {
enum InputAction : std::uint8_t {
// Inputs obligatorios
input_null,
input_up,
@@ -44,7 +44,7 @@ enum inputs_e : std::uint8_t {
input_number_of_inputs
};
enum i_disable_e : std::uint8_t {
enum InputDisable : std::uint8_t {
d_notDisabled,
d_forever,
d_keyPressed
@@ -73,7 +73,7 @@ class Input {
int numGamepads{0}; // Numero de mandos conectados
std::string dbPath; // Ruta al archivo gamecontrollerdb.txt
bool verbose{true}; // Indica si ha de mostrar mensajes
i_disable_e disabledUntil{d_notDisabled}; // Tiempo que esta deshabilitado
InputDisable disabledUntil{d_notDisabled}; // Tiempo que esta deshabilitado
bool enabled{true}; // Indica si está habilitado
// Construye el nombre visible de un mando (name truncado + sufijo #N)
@@ -133,7 +133,7 @@ class Input {
void setVerbose(bool value);
// Deshabilita las entradas durante un periodo de tiempo
void disableUntil(i_disable_e value);
void disableUntil(InputDisable value);
// Hablita las entradas
void enable();
+10 -10
View File
@@ -8,8 +8,8 @@
#include "core/resources/resource_helper.h" // for loadFile (pack + filesystem fallback)
// Parser compartido: lee un istream con el formato .ani
static auto parseAnimationStream(std::istream &file, Texture *texture, const std::string &filename, bool verbose) -> animatedSprite_t {
animatedSprite_t as;
static auto parseAnimationStream(std::istream &file, Texture *texture, const std::string &filename, bool verbose) -> AnimatedSpriteData {
AnimatedSpriteData as;
as.texture = texture;
int framesPerRow = 0;
int frameWidth = 0;
@@ -32,7 +32,7 @@ static auto parseAnimationStream(std::istream &file, Texture *texture, const std
while (std::getline(file, line)) {
strip_cr(line);
if (line == "[animation]") {
animation_t buffer;
Animation buffer;
buffer.speed = 0;
buffer.loop = -1;
buffer.counter = 0;
@@ -98,14 +98,14 @@ static auto parseAnimationStream(std::istream &file, Texture *texture, const std
}
// Carga la animación desde un fichero (vía ResourceHelper: pack si està inicialitzat, filesystem si no)
auto loadAnimationFromFile(Texture *texture, const std::string &filePath, bool verbose) -> animatedSprite_t {
auto loadAnimationFromFile(Texture *texture, const std::string &filePath, bool verbose) -> AnimatedSpriteData {
const std::string filename = filePath.substr(filePath.find_last_of("\\/") + 1);
auto bytes = ResourceHelper::loadFile(filePath);
if (bytes.empty()) {
if (verbose) {
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << '\n';
}
animatedSprite_t as;
AnimatedSpriteData as;
as.texture = texture;
return as;
}
@@ -113,9 +113,9 @@ auto loadAnimationFromFile(Texture *texture, const std::string &filePath, bool v
}
// Carga la animación desde bytes en memoria
auto loadAnimationFromMemory(Texture *texture, const std::vector<uint8_t> &bytes, const std::string &nameForLogs, bool verbose) -> animatedSprite_t {
auto loadAnimationFromMemory(Texture *texture, const std::vector<uint8_t> &bytes, const std::string &nameForLogs, bool verbose) -> AnimatedSpriteData {
if (bytes.empty()) {
animatedSprite_t as;
AnimatedSpriteData as;
as.texture = texture;
return as;
}
@@ -133,7 +133,7 @@ AnimatedSprite::AnimatedSprite(Texture *texture, SDL_Renderer *renderer, const s
// Carga las animaciones
if (!file.empty()) {
animatedSprite_t as = loadAnimationFromFile(texture, file);
AnimatedSpriteData as = loadAnimationFromFile(texture, file);
// Copia los datos de las animaciones
animation.insert(animation.end(), as.animations.begin(), as.animations.end());
@@ -145,7 +145,7 @@ AnimatedSprite::AnimatedSprite(Texture *texture, SDL_Renderer *renderer, const s
}
// Constructor
AnimatedSprite::AnimatedSprite(SDL_Renderer *renderer, animatedSprite_t *animation)
AnimatedSprite::AnimatedSprite(SDL_Renderer *renderer, AnimatedSpriteData *animation)
: currentAnimation(0) {
// Copia los punteros
setTexture(animation->texture);
@@ -299,7 +299,7 @@ auto AnimatedSprite::loadFromVector(std::vector<std::string> *source) -> bool {
// Si la linea contiene el texto [animation] se realiza el proceso de carga de una animación
if (line == "[animation]") {
animation_t buffer;
Animation buffer;
buffer.speed = 0;
buffer.loop = -1;
buffer.counter = 0;
+7 -7
View File
@@ -9,7 +9,7 @@
#include "core/rendering/movingsprite.h" // for MovingSprite
class Texture;
struct animation_t {
struct Animation {
std::string name; // Nombre de la animacion
std::vector<SDL_Rect> frames; // Cada uno de los frames que componen la animación
int speed; // Velocidad de la animación
@@ -19,27 +19,27 @@ struct animation_t {
int counter; // Contador para las animaciones
};
struct animatedSprite_t {
std::vector<animation_t> animations; // Vector con las diferentes animaciones
struct AnimatedSpriteData {
std::vector<Animation> animations; // Vector con las diferentes animaciones
Texture *texture; // Textura con los graficos para el sprite
};
// Carga la animación desde un fichero
auto loadAnimationFromFile(Texture *texture, const std::string &filePath, bool verbose = false) -> animatedSprite_t;
auto loadAnimationFromFile(Texture *texture, const std::string &filePath, bool verbose = false) -> AnimatedSpriteData;
// Carga la animación desde bytes en memoria
auto loadAnimationFromMemory(Texture *texture, const std::vector<uint8_t> &bytes, const std::string &nameForLogs = "", bool verbose = false) -> animatedSprite_t;
auto loadAnimationFromMemory(Texture *texture, const std::vector<uint8_t> &bytes, const std::string &nameForLogs = "", bool verbose = false) -> AnimatedSpriteData;
class AnimatedSprite : public MovingSprite {
private:
// Variables
std::vector<animation_t> animation; // Vector con las diferentes animaciones
std::vector<Animation> animation; // Vector con las diferentes animaciones
int currentAnimation; // Animacion activa
public:
// Constructor
explicit AnimatedSprite(Texture *texture = nullptr, SDL_Renderer *renderer = nullptr, const std::string &file = "", std::vector<std::string> *buffer = nullptr);
AnimatedSprite(SDL_Renderer *renderer, animatedSprite_t *animation);
AnimatedSprite(SDL_Renderer *renderer, AnimatedSpriteData *animation);
// Destructor
~AnimatedSprite() override;
+11 -11
View File
@@ -157,7 +157,7 @@ Screen::~Screen() {
}
// Limpia la pantalla
void Screen::clean(color_t color) {
void Screen::clean(Color color) {
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
SDL_RenderClear(renderer);
}
@@ -327,7 +327,7 @@ void Screen::toggleVSync() {
}
// Cambia el color del borde
void Screen::setBorderColor(color_t color) {
void Screen::setBorderColor(Color color) {
borderColor = color;
}
@@ -420,7 +420,7 @@ void Screen::applyLogicalPresentation(bool fullscreen) {
// ============================================================================
// Muestra una notificación en la línea superior durante durationMs
void Screen::notify(const std::string &text, color_t textColor, color_t outlineColor, Uint32 durationMs) {
void Screen::notify(const std::string &text, Color textColor, Color outlineColor, Uint32 durationMs) {
notificationMessage = text;
notificationTextColor = textColor;
notificationOutlineColor = outlineColor;
@@ -570,8 +570,8 @@ void Screen::setShaderEnabled(bool enabled) {
// Si enabled=false, blit() forçarà POSTFX+zero per frame — no cal tocar
// res ara.
#endif
const color_t CYAN = {0x00, 0xFF, 0xFF};
const color_t BLACK = {0x00, 0x00, 0x00};
const Color CYAN = {0x00, 0xFF, 0xFF};
const Color BLACK = {0x00, 0x00, 0x00};
const Uint32 DUR_MS = 1500;
notify(enabled ? "Shader: ON" : "Shader: OFF", CYAN, BLACK, DUR_MS);
}
@@ -590,8 +590,8 @@ void Screen::setActiveShader(Rendering::ShaderType type) {
if (Options::video.shader.enabled) {
applyShaderParams();
}
const color_t MAGENTA = {0xFF, 0x00, 0xFF};
const color_t BLACK = {0x00, 0x00, 0x00};
const Color MAGENTA = {0xFF, 0x00, 0xFF};
const Color BLACK = {0x00, 0x00, 0x00};
const Uint32 DUR_MS = 1500;
notify(type == Rendering::ShaderType::CRTPI ? "Shader: CRTPI" : "Shader: POSTFX", MAGENTA, BLACK, DUR_MS);
}
@@ -703,8 +703,8 @@ auto Screen::nextPreset() -> bool {
applyCurrentCrtPiPreset();
}
const color_t GREEN = {0x00, 0xFF, 0x80};
const color_t BLACK = {0x00, 0x00, 0x00};
const Color GREEN = {0x00, 0xFF, 0x80};
const Color BLACK = {0x00, 0x00, 0x00};
const Uint32 DUR_MS = 1500;
notify(std::string("Preset: ") + getCurrentPresetName(), GREEN, BLACK, DUR_MS);
return true;
@@ -734,8 +734,8 @@ auto Screen::prevPreset() -> bool {
applyCurrentCrtPiPreset();
}
const color_t GREEN = {0x00, 0xFF, 0x80};
const color_t BLACK = {0x00, 0x00, 0x00};
const Color GREEN = {0x00, 0xFF, 0x80};
const Color BLACK = {0x00, 0x00, 0x00};
const Uint32 DUR_MS = 1500;
notify(std::string("Preset: ") + getCurrentPresetName(), GREEN, BLACK, DUR_MS);
return true;
+7 -7
View File
@@ -6,7 +6,7 @@
#include <string> // for string
#include <vector> // for vector
#include "utils/utils.h" // for color_t
#include "utils/utils.h" // for Color
#ifndef NO_SHADERS
#include "core/rendering/shader_backend.hpp" // for Rendering::ShaderType
@@ -38,7 +38,7 @@ class Screen {
~Screen();
// Render loop
void clean(color_t color = {0x00, 0x00, 0x00}); // Limpia la pantalla
void clean(Color color = {0x00, 0x00, 0x00}); // Limpia la pantalla
void start(); // Prepara para empezar a dibujar en la textura de juego
void blit(); // Vuelca el contenido del renderizador en pantalla
@@ -56,11 +56,11 @@ class Screen {
auto setWindowZoom(int zoom) -> bool; // Establece el zoom de la ventana (devuelve true si cambió)
// Borde
void setBorderColor(color_t color); // Cambia el color del borde
void setBorderColor(Color color); // Cambia el color del borde
// Notificaciones
void initNotifications(); // Enllaça el Text de notificacions amb `Resource`. A cridar després de `Resource::init(...)`.
void notify(const std::string &text, color_t textColor, color_t outlineColor, Uint32 durationMs); // Muestra una notificación en la línea superior del canvas durante durationMs. Sobrescribe cualquier notificación activa (sin apilación).
void notify(const std::string &text, Color textColor, Color outlineColor, Uint32 durationMs); // Muestra una notificación en la línea superior del canvas durante durationMs. Sobrescribe cualquier notificación activa (sin apilación).
void clearNotification(); // Limpia la notificación actual
// GPU / shaders (post-procesado). En builds con NO_SHADERS (Emscripten) son no-op.
@@ -121,13 +121,13 @@ class Screen {
int gameCanvasWidth; // Resolución interna del juego. Es el ancho de la textura donde se dibuja el juego
int gameCanvasHeight; // Resolución interna del juego. Es el alto de la textura donde se dibuja el juego
SDL_Rect dest; // Coordenadas donde se va a dibujar la textura del juego sobre la pantalla o ventana
color_t borderColor; // Color del borde añadido a la textura de juego para rellenar la pantalla
Color borderColor; // Color del borde añadido a la textura de juego para rellenar la pantalla
// Notificaciones - una sola activa, sin apilación ni animaciones
Text *notificationText; // Fuente 8bithud dedicada a las notificaciones
std::string notificationMessage; // Texto a mostrar
color_t notificationTextColor; // Color del texto
color_t notificationOutlineColor; // Color del outline
Color notificationTextColor; // Color del texto
Color notificationOutlineColor; // Color del outline
Uint32 notificationEndTime; // SDL_GetTicks() hasta el cual se muestra
int notificationY; // Fila vertical en el canvas virtual
+17 -17
View File
@@ -8,10 +8,10 @@
#include "core/rendering/sprite.h" // for Sprite
#include "core/rendering/texture.h" // for Texture
#include "core/resources/resource_helper.h" // for loadFile (pack + filesystem fallback)
#include "utils/utils.h" // for color_t
#include "utils/utils.h" // for Color
// Parser compartido: rellena un textFile_t desde cualquier istream
static void parseTextFileStream(std::istream &rfile, textFile_t &tf) {
// Parser compartido: rellena un TextFile desde cualquier istream
static void parseTextFileStream(std::istream &rfile, TextFile &tf) {
std::string buffer;
std::getline(rfile, buffer);
std::getline(rfile, buffer);
@@ -32,22 +32,22 @@ static void parseTextFileStream(std::istream &rfile, textFile_t &tf) {
}
}
static void computeTextFileOffsets(textFile_t &tf) {
static void computeTextFileOffsets(TextFile &tf) {
for (int i = 32; i < 128; ++i) {
tf.offset[i].x = ((i - 32) % 15) * tf.boxWidth;
tf.offset[i].y = ((i - 32) / 15) * tf.boxHeight;
}
}
// Llena una estructuta textFile_t desde un fichero (vía ResourceHelper: pack o filesystem)
auto LoadTextFile(const std::string &file, bool verbose) -> textFile_t {
// Llena una estructuta TextFile desde un fichero (vía ResourceHelper: pack o filesystem)
auto LoadTextFile(const std::string &file, bool verbose) -> TextFile {
const std::string filename = file.substr(file.find_last_of("\\/") + 1);
auto bytes = ResourceHelper::loadFile(file);
if (bytes.empty()) {
if (verbose) {
std::cout << "Warning: Unable to open " << filename.c_str() << " file" << '\n';
}
textFile_t tf;
TextFile tf;
tf.boxWidth = 0;
tf.boxHeight = 0;
for (auto &i : tf.offset) {
@@ -64,9 +64,9 @@ auto LoadTextFile(const std::string &file, bool verbose) -> textFile_t {
return LoadTextFileFromMemory(bytes, verbose);
}
// Llena una estructura textFile_t desde bytes en memoria
auto LoadTextFileFromMemory(const std::vector<uint8_t> &bytes, bool verbose) -> textFile_t {
textFile_t tf;
// Llena una estructura TextFile desde bytes en memoria
auto LoadTextFileFromMemory(const std::vector<uint8_t> &bytes, bool verbose) -> TextFile {
TextFile tf;
tf.boxWidth = 0;
tf.boxHeight = 0;
for (auto &i : tf.offset) {
@@ -89,7 +89,7 @@ auto LoadTextFileFromMemory(const std::vector<uint8_t> &bytes, bool verbose) ->
// Constructor
Text::Text(const std::string &bitmapFile, const std::string &textFile, SDL_Renderer *renderer) {
// Carga los offsets desde el fichero
textFile_t tf = LoadTextFile(textFile);
TextFile tf = LoadTextFile(textFile);
// Inicializa variables desde la estructura
boxHeight = tf.boxHeight;
@@ -111,7 +111,7 @@ Text::Text(const std::string &bitmapFile, const std::string &textFile, SDL_Rende
// Constructor
Text::Text(const std::string &textFile, Texture *texture, SDL_Renderer *renderer) {
// Carga los offsets desde el fichero
textFile_t tf = LoadTextFile(textFile);
TextFile tf = LoadTextFile(textFile);
// Inicializa variables desde la estructura
boxHeight = tf.boxHeight;
@@ -131,7 +131,7 @@ Text::Text(const std::string &textFile, Texture *texture, SDL_Renderer *renderer
}
// Constructor
Text::Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer) {
Text::Text(TextFile *textFile, Texture *texture, SDL_Renderer *renderer) {
// Inicializa variables desde la estructura
boxHeight = textFile->boxHeight;
boxWidth = textFile->boxWidth;
@@ -151,7 +151,7 @@ Text::Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer) {
// Constructor desde bytes
Text::Text(const std::vector<uint8_t> &pngBytes, const std::vector<uint8_t> &txtBytes, SDL_Renderer *renderer) {
textFile_t tf = LoadTextFileFromMemory(txtBytes);
TextFile tf = LoadTextFileFromMemory(txtBytes);
boxHeight = tf.boxHeight;
boxWidth = tf.boxWidth;
for (int i = 0; i < 128; ++i) {
@@ -195,14 +195,14 @@ void Text::write(int x, int y, const std::string &text, int kerning, int lenght)
}
// Escribe el texto con colores
void Text::writeColored(int x, int y, const std::string &text, color_t color, int kerning, int lenght) {
void Text::writeColored(int x, int y, const std::string &text, Color color, int kerning, int lenght) {
sprite->getTexture()->setColor(color.r, color.g, color.b);
write(x, y, text, kerning, lenght);
sprite->getTexture()->setColor(255, 255, 255);
}
// Escribe el texto con sombra
void Text::writeShadowed(int x, int y, const std::string &text, color_t color, Uint8 shadowDistance, int kerning, int lenght) {
void Text::writeShadowed(int x, int y, const std::string &text, Color color, Uint8 shadowDistance, int kerning, int lenght) {
sprite->getTexture()->setColor(color.r, color.g, color.b);
write(x + shadowDistance, y + shadowDistance, text, kerning, lenght);
sprite->getTexture()->setColor(255, 255, 255);
@@ -216,7 +216,7 @@ void Text::writeCentered(int x, int y, const std::string &text, int kerning, int
}
// Escribe texto con extras
void Text::writeDX(Uint8 flags, int x, int y, const std::string &text, int kerning, color_t textColor, Uint8 shadowDistance, color_t shadowColor, int lenght) {
void Text::writeDX(Uint8 flags, int x, int y, const std::string &text, int kerning, Color textColor, Uint8 shadowDistance, Color shadowColor, int lenght) {
const bool centered = ((flags & TXT_CENTER) == TXT_CENTER);
const bool shadowed = ((flags & TXT_SHADOW) == TXT_SHADOW);
const bool colored = ((flags & TXT_COLOR) == TXT_COLOR);
+12 -12
View File
@@ -15,23 +15,23 @@ constexpr int TXT_SHADOW = 2;
constexpr int TXT_CENTER = 4;
constexpr int TXT_STROKE = 8;
struct offset_t {
struct Offset {
int x;
int y;
int w;
};
struct textFile_t {
struct TextFile {
int boxWidth; // Anchura de la caja de cada caracter en el png
int boxHeight; // Altura de la caja de cada caracter en el png
offset_t offset[128]; // Vector con las posiciones y ancho de cada letra
Offset offset[128]; // Vector con las posiciones y ancho de cada letra
};
// Llena una estructuta textFile_t desde un fichero
auto LoadTextFile(const std::string &file, bool verbose = false) -> textFile_t;
// Llena una estructuta TextFile desde un fichero
auto LoadTextFile(const std::string &file, bool verbose = false) -> TextFile;
// Llena una estructura textFile_t desde bytes en memoria
auto LoadTextFileFromMemory(const std::vector<uint8_t> &bytes, bool verbose = false) -> textFile_t;
// Llena una estructura TextFile desde bytes en memoria
auto LoadTextFileFromMemory(const std::vector<uint8_t> &bytes, bool verbose = false) -> TextFile;
// Clase texto. Pinta texto en pantalla a partir de un bitmap
class Text {
@@ -44,13 +44,13 @@ class Text {
int boxWidth; // Anchura de la caja de cada caracter en el png
int boxHeight; // Altura de la caja de cada caracter en el png
bool fixedWidth; // Indica si el texto se ha de escribir con longitud fija en todas las letras
offset_t offset[128]; // Vector con las posiciones y ancho de cada letra
Offset offset[128]; // Vector con las posiciones y ancho de cada letra
public:
// Constructor
Text(const std::string &bitmapFile, const std::string &textFile, SDL_Renderer *renderer);
Text(const std::string &textFile, Texture *texture, SDL_Renderer *renderer);
Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer);
Text(TextFile *textFile, Texture *texture, SDL_Renderer *renderer);
// Constructor desde bytes en memoria: comparte ownership del texture (no lo libera)
Text(const std::vector<uint8_t> &pngBytes, const std::vector<uint8_t> &txtBytes, SDL_Renderer *renderer);
@@ -66,16 +66,16 @@ class Text {
void write(int x, int y, const std::string &text, int kerning = 1, int lenght = -1);
// Escribe el texto con colores
void writeColored(int x, int y, const std::string &text, color_t color, int kerning = 1, int lenght = -1);
void writeColored(int x, int y, const std::string &text, Color color, int kerning = 1, int lenght = -1);
// Escribe el texto con sombra
void writeShadowed(int x, int y, const std::string &text, color_t color, Uint8 shadowDistance = 1, int kerning = 1, int lenght = -1);
void writeShadowed(int x, int y, const std::string &text, Color color, Uint8 shadowDistance = 1, int kerning = 1, int lenght = -1);
// Escribe el texto centrado en un punto x
void writeCentered(int x, int y, const std::string &text, int kerning = 1, int lenght = -1);
// Escribe texto con extras
void writeDX(Uint8 flags, int x, int y, const std::string &text, int kerning = 1, color_t textColor = color_t(255, 255, 255), Uint8 shadowDistance = 1, color_t shadowColor = color_t(0, 0, 0), int lenght = -1);
void writeDX(Uint8 flags, int x, int y, const std::string &text, int kerning = 1, Color textColor = Color(255, 255, 255), Uint8 shadowDistance = 1, Color shadowColor = Color(0, 0, 0), int lenght = -1);
// Obtiene la longitud en pixels de una cadena
auto lenght(const std::string &text, int kerning = 1) -> int;
+1 -1
View File
@@ -30,7 +30,7 @@ Asset::Asset(const std::string &executablePath)
}
// Añade un elemento a la lista
void Asset::add(const std::string &file, enum assetType type, bool required, bool absolute) {
void Asset::add(const std::string &file, enum AssetType type, bool required, bool absolute) {
item_t temp;
temp.file = absolute ? file : executablePath + file;
temp.type = type;
+3 -3
View File
@@ -4,7 +4,7 @@
#include <string> // for string, basic_string
#include <vector> // for vector
enum assetType : std::uint8_t {
enum AssetType : std::uint8_t {
t_bitmap,
t_music,
t_sound,
@@ -23,7 +23,7 @@ class Asset {
// Estructura para definir un item
struct item_t {
std::string file; // Ruta del fichero desde la raiz del directorio
enum assetType type; // Indica el tipo de recurso
enum AssetType type; // Indica el tipo de recurso
bool required; // Indica si es un fichero que debe de existir
};
@@ -53,7 +53,7 @@ class Asset {
static auto get() -> Asset *; // Obtiene el puntero a la instancia
// Añade un elemento a la lista
void add(const std::string &file, enum assetType type, bool required = true, bool absolute = false);
void add(const std::string &file, enum AssetType type, bool required = true, bool absolute = false);
// Devuelve un elemento de la lista a partir de una cadena
auto get(const std::string &text) -> std::string;
+8 -8
View File
@@ -19,12 +19,12 @@
#include <vector> // for vector
#include "core/audio/audio.hpp" // for Audio::init, Audio::destroy
#include "core/input/input.h" // for Input, inputs_e, INPUT_USE_GAME...
#include "core/input/input.h" // for Input, InputAction, INPUT_USE_GAME...
#include "core/input/mouse.hpp" // for Mouse::handleEvent, Mouse::upda...
#include "core/locale/lang.h" // for Lang, MAX_LANGUAGES, ba_BA, en_UK
#include "core/rendering/screen.h" // for Screen
#include "core/rendering/texture.h" // for Texture
#include "core/resources/asset.h" // for Asset, assetType
#include "core/resources/asset.h" // for Asset, AssetType
#include "core/resources/resource.h"
#include "core/resources/resource_helper.h"
#include "game/defaults.hpp" // for SECTION_PROG_LOGO, GAMECANVAS_H...
@@ -33,7 +33,7 @@
#include "game/scenes/intro.h" // for Intro
#include "game/scenes/logo.h" // for Logo
#include "game/scenes/title.h" // for Title
#include "utils/utils.h" // for input_t, boolToString
#include "utils/utils.h" // for InputDevice, boolToString
#if !defined(_WIN32) && !defined(__EMSCRIPTEN__)
#include <pwd.h>
@@ -43,7 +43,7 @@
Director::Director(int argc, const char *argv[]) {
std::cout << "Game start" << '\n';
// Inicializa variables
section = new section_t();
section = new Section();
section->name = SECTION_PROG_LOGO;
// Inicializa las opciones del programa (defaults + dispositivos d'entrada)
@@ -630,16 +630,16 @@ auto Director::handleEvent(SDL_Event *event) -> SDL_AppResult {
std::string name;
if (Input::get()->handleGamepadAdded(event->gdevice.which, name)) {
Screen::get()->notify(name + " " + Lang::get()->getText(94),
color_t{0x40, 0xFF, 0x40},
color_t{0, 0, 0},
Color{0x40, 0xFF, 0x40},
Color{0, 0, 0},
2500);
}
} else if (event->type == SDL_EVENT_GAMEPAD_REMOVED) {
std::string name;
if (Input::get()->handleGamepadRemoved(event->gdevice.which, name)) {
Screen::get()->notify(name + " " + Lang::get()->getText(95),
color_t{0xFF, 0x50, 0x50},
color_t{0, 0, 0},
Color{0xFF, 0x50, 0x50},
Color{0, 0, 0},
2500);
}
}
+2 -2
View File
@@ -9,7 +9,7 @@ class Game;
class Intro;
class Logo;
class Title;
struct section_t;
struct Section;
// Secciones activas del Director
enum class ActiveSection : std::uint8_t { None,
@@ -23,7 +23,7 @@ class Director {
// Objetos y punteros
SDL_Window *window; // La ventana donde dibujamos
SDL_Renderer *renderer; // El renderizador de la ventana
section_t *section; // Sección y subsección actual del programa;
Section *section; // Sección y subsección actual del programa;
// Secciones del juego
ActiveSection activeSection;
+3 -3
View File
@@ -105,6 +105,6 @@ constexpr int SUBSECTION_TITLE_INSTRUCTIONS = 6;
constexpr int NO_KIND = 0;
// Colores
const color_t bgColor = {0x27, 0x27, 0x36};
const color_t noColor = {0xFF, 0xFF, 0xFF};
const color_t shdwTxtColor = {0x43, 0x43, 0x4F};
const Color bgColor = {0x27, 0x27, 0x36};
const Color noColor = {0xFF, 0xFF, 0xFF};
const Color shdwTxtColor = {0x43, 0x43, 0x4F};
+1 -1
View File
@@ -719,7 +719,7 @@ auto Balloon::getScore() const -> Uint16 {
}
// Obtiene el circulo de colisión
auto Balloon::getCollider() -> circle_t & {
auto Balloon::getCollider() -> Circle & {
return collider;
}
+3 -3
View File
@@ -5,7 +5,7 @@
#include <string> // for string
#include <vector> // for vector
#include "utils/utils.h" // for circle_t
#include "utils/utils.h" // for Circle
class AnimatedSprite;
class Texture;
@@ -104,7 +104,7 @@ class Balloon {
bool popping; // Indica si el globo está explotando
bool stopped; // Indica si el globo está parado
bool visible; // Indica si el globo es visible
circle_t collider; // Circulo de colisión del objeto
Circle collider; // Circulo de colisión del objeto
Uint16 creationCounter; // Temporizador para controlar el estado "creandose"
Uint16 creationCounterIni; // Valor inicial para el temporizador para controlar el estado "creandose"
Uint16 score; // Puntos que da el globo al ser destruido
@@ -243,7 +243,7 @@ class Balloon {
[[nodiscard]] auto getScore() const -> Uint16;
// Obtiene el circulo de colisión
auto getCollider() -> circle_t &;
auto getCollider() -> Circle &;
// Obtiene le valor de la variable
[[nodiscard]] auto getMenace() const -> Uint8;
+1 -1
View File
@@ -169,7 +169,7 @@ auto Bullet::getOwner() const -> int {
}
// Obtiene el circulo de colisión
auto Bullet::getCollider() -> circle_t & {
auto Bullet::getCollider() -> Circle & {
return collider;
}
+3 -3
View File
@@ -3,7 +3,7 @@
#include <SDL3/SDL.h>
#include <cstdint> // for uint8_t
#include "utils/utils.h" // for circle_t
#include "utils/utils.h" // for Circle
class Sprite;
class Texture;
@@ -35,7 +35,7 @@ class Bullet {
int velY; // Velocidad en el eje Y
BulletKind kind; // Tipo de objeto
int owner; // Identificador del dueño del objeto
circle_t collider; // Circulo de colisión del objeto
Circle collider; // Circulo de colisión del objeto
// Alinea el circulo de colisión con el objeto
void shiftColliders();
@@ -84,5 +84,5 @@ class Bullet {
[[nodiscard]] auto getOwner() const -> int;
// Obtiene el circulo de colisión
auto getCollider() -> circle_t &;
auto getCollider() -> Circle &;
};
+1 -1
View File
@@ -180,7 +180,7 @@ auto Item::isEnabled() const -> bool {
}
// Obtiene el circulo de colisión
auto Item::getCollider() -> circle_t & {
auto Item::getCollider() -> Circle & {
return collider;
}
+3 -3
View File
@@ -5,7 +5,7 @@
#include <string> // for string
#include <vector> // for vector
#include "utils/utils.h" // for circle_t
#include "utils/utils.h" // for Circle
class AnimatedSprite;
class Texture;
@@ -35,7 +35,7 @@ class Item {
bool floorCollision; // Indica si el objeto colisiona con el suelo
Uint8 kind; // Especifica el tipo de objeto que es
bool enabled; // Especifica si el objeto está habilitado
circle_t collider; // Circulo de colisión del objeto
Circle collider; // Circulo de colisión del objeto
// Alinea el circulo de colisión con la posición del objeto
void shiftColliders();
@@ -92,7 +92,7 @@ class Item {
[[nodiscard]] auto isEnabled() const -> bool;
// Obtiene el circulo de colisión
auto getCollider() -> circle_t &;
auto getCollider() -> Circle &;
// Informa si el objeto ha colisionado con el suelo
[[nodiscard]] auto isOnFloor() const -> bool;
+2 -2
View File
@@ -3,7 +3,7 @@
#include <algorithm>
#include <cstdlib> // for rand
#include "core/input/input.h" // for inputs_e
#include "core/input/input.h" // for InputAction
#include "core/rendering/animatedsprite.h" // for AnimatedSprite
#include "core/rendering/texture.h" // for Texture
#include "game/defaults.hpp" // for PLAY_AREA_LEFT, PLAY_AREA_RIGHT
@@ -469,7 +469,7 @@ auto Player::getCoffees() const -> Uint8 {
}
// Obtiene el circulo de colisión
auto Player::getCollider() -> circle_t & {
auto Player::getCollider() -> Circle & {
return collider;
}
+3 -3
View File
@@ -5,7 +5,7 @@
#include <string> // for string
#include <vector> // for vector
#include "utils/utils.h" // for circle_t
#include "utils/utils.h" // for Circle
class AnimatedSprite;
class Texture;
@@ -65,7 +65,7 @@ class Player {
bool powerUp; // Indica si el jugador tiene activo el modo PowerUp
Uint16 powerUpCounter; // Temporizador para el modo PowerUp
bool input; // Indica si puede recibir ordenes de entrada
circle_t collider; // Circulo de colisión del jugador
Circle collider; // Circulo de colisión del jugador
// Actualiza el circulo de colisión a la posición del jugador
void shiftColliders();
@@ -210,7 +210,7 @@ class Player {
[[nodiscard]] auto getCoffees() const -> Uint8;
// Obtiene el circulo de colisión
auto getCollider() -> circle_t &;
auto getCollider() -> Circle &;
// Obtiene el puntero a la textura con los gráficos de la animación de morir
auto getDeadTexture() -> Texture *;
+5 -5
View File
@@ -10,7 +10,7 @@
#include "core/audio/audio.hpp" // for Audio
#include "core/input/global_inputs.hpp" // for GlobalInputs::handle
#include "core/input/input.h" // for inputs_e, Input, REPEAT_TRUE, REPEAT_FALSE
#include "core/input/input.h" // for InputAction, Input, REPEAT_TRUE, REPEAT_FALSE
#include "core/locale/lang.h" // for Lang
#include "core/rendering/fade.h" // for Fade, FADE_CENTER
#include "core/rendering/movingsprite.h" // for MovingSprite
@@ -31,7 +31,7 @@
struct JA_Sound_t;
// Constructor
Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, bool demo, section_t *section)
Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, bool demo, Section *section)
: lastStageReached(currentStage) {
// Copia los punteros
this->renderer = renderer;
@@ -502,10 +502,10 @@ auto Game::loadScoreFile() -> bool {
auto Game::loadDemoFile() -> bool {
// Lee los datos de la demo desde Resource (precargados al arrancar).
const auto &bytes = Resource::get()->getDemoBytes();
const size_t expected = sizeof(demoKeys_t) * TOTAL_DEMO_DATA;
const size_t expected = sizeof(DemoKeys) * TOTAL_DEMO_DATA;
if (bytes.size() >= expected) {
for (int i = 0; i < TOTAL_DEMO_DATA; ++i) {
memcpy(&demo.dataFile[i], bytes.data() + (i * sizeof(demoKeys_t)), sizeof(demoKeys_t));
memcpy(&demo.dataFile[i], bytes.data() + (i * sizeof(DemoKeys)), sizeof(DemoKeys));
}
if (Options::settings.console) {
std::cout << "Demo data loaded (" << bytes.size() << " bytes)" << '\n';
@@ -564,7 +564,7 @@ auto Game::saveDemoFile() -> bool {
if (file != nullptr) {
// Guardamos los datos
for (auto &i : demo.dataFile) {
SDL_WriteIO(file, &i, sizeof(demoKeys_t));
SDL_WriteIO(file, &i, sizeof(DemoKeys));
}
if (Options::settings.console) {
+6 -6
View File
@@ -7,7 +7,7 @@
#include <vector> // for vector
#include "game/entities/bullet.h" // for BulletKind (signatura de createBullet)
#include "utils/utils.h" // for demoKeys_t, color_t
#include "utils/utils.h" // for DemoKeys, Color
class Balloon;
class Bullet;
class Fade;
@@ -123,13 +123,13 @@ class Game {
bool enabled; // Indica si está activo el modo demo
bool recording; // Indica si está activado el modo para grabar la demo
Uint16 counter; // Contador para el modo demo
demoKeys_t keys; // Variable con las pulsaciones de teclas del modo demo
demoKeys_t dataFile[TOTAL_DEMO_DATA]; // Datos del fichero con los movimientos para la demo
DemoKeys keys; // Variable con las pulsaciones de teclas del modo demo
DemoKeys dataFile[TOTAL_DEMO_DATA]; // Datos del fichero con los movimientos para la demo
};
// Objetos y punteros
SDL_Renderer *renderer; // El renderizador de la ventana
section_t *section; // Seccion actual dentro del juego
Section *section; // Seccion actual dentro del juego
std::vector<Player *> players; // Vector con los jugadores
std::vector<Balloon *> balloons; // Vector con los globos
@@ -238,7 +238,7 @@ class Game {
int gameCompletedCounter; // Contador para el tramo final, cuando se ha completado la partida y ya no aparecen más enemigos
Uint8 difficulty; // Dificultad del juego
float difficultyScoreMultiplier; // Multiplicador de puntos en función de la dificultad
color_t difficultyColor; // Color asociado a la dificultad
Color difficultyColor; // Color asociado a la dificultad
Uint8 onePlayerControl; // Variable para almacenar el valor de las opciones
enemyFormation_t enemyFormation[NUMBER_OF_ENEMY_FORMATIONS]; // Vector con todas las formaciones enemigas
enemyPool_t enemyPool[10]; // Variable con los diferentes conjuntos de formaciones enemigas
@@ -521,7 +521,7 @@ class Game {
public:
// Constructor
Game(int numPlayers, int currentStage, SDL_Renderer *renderer, bool demo, section_t *section);
Game(int numPlayers, int currentStage, SDL_Renderer *renderer, bool demo, Section *section);
// Destructor
~Game();
+3 -3
View File
@@ -20,7 +20,7 @@ namespace Options {
Audio audio;
Loading loading;
Settings settings;
std::vector<input_t> inputs;
std::vector<InputDevice> inputs;
std::vector<PostFXPreset> postfx_presets;
std::string postfx_file_path;
@@ -197,13 +197,13 @@ namespace Options {
// Dispositius d'entrada per defecte
inputs.clear();
input_t kb;
InputDevice kb;
kb.id = 0;
kb.name = "KEYBOARD";
kb.deviceType = INPUT_USE_KEYBOARD;
inputs.push_back(kb);
input_t gc;
InputDevice gc;
gc.id = 0;
gc.name = "GAME CONTROLLER";
gc.deviceType = INPUT_USE_GAMECONTROLLER;
+2 -2
View File
@@ -7,7 +7,7 @@
#include "core/rendering/shader_backend.hpp" // for Rendering::ShaderType
#include "game/defaults.hpp"
#include "utils/utils.h" // for input_t
#include "utils/utils.h" // for InputDevice
// =============================================================================
// Opciones del programa, alineades amb coffee_crisis_arcade_edition.
@@ -125,7 +125,7 @@ namespace Options {
extern Audio audio;
extern Loading loading;
extern Settings settings;
extern std::vector<input_t> inputs; // [0]=KEYBOARD, [1]=GAMECONTROLLER per defecte
extern std::vector<InputDevice> inputs; // [0]=KEYBOARD, [1]=GAMECONTROLLER per defecte
// Presets de shaders (carregats de postfx.yaml / crtpi.yaml al config folder)
extern std::vector<PostFXPreset> postfx_presets;
+6 -6
View File
@@ -8,7 +8,7 @@
#include "core/audio/audio.hpp" // for Audio::update
#include "core/input/global_inputs.hpp" // for GlobalInputs::handle
#include "core/input/input.h" // for Input, REPEAT_FALSE, inputs_e
#include "core/input/input.h" // for Input, REPEAT_FALSE, InputAction
#include "core/locale/lang.h" // for Lang
#include "core/rendering/screen.h" // for Screen
#include "core/rendering/sprite.h" // for Sprite
@@ -16,10 +16,10 @@
#include "core/rendering/texture.h" // for Texture
#include "core/resources/resource.h"
#include "game/defaults.hpp" // for shdwTxtColor, GAMECANVAS_CENTER_X, GAME...
#include "utils/utils.h" // for color_t, section_t
#include "utils/utils.h" // for Color, Section
// Constructor
Instructions::Instructions(SDL_Renderer *renderer, section_t *section) {
Instructions::Instructions(SDL_Renderer *renderer, Section *section) {
// Copia los punteros
this->renderer = renderer;
this->section = section;
@@ -103,7 +103,7 @@ void Instructions::render() {
SDL_Rect window = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT};
SDL_Rect srcRect = {0, 0, 16, 16};
const color_t orangeColor = {0xFF, 0x7A, 0x00};
const Color orangeColor = {0xFF, 0x7A, 0x00};
const SDL_Rect destRect1 = {60, 88 + (16 * 0), 16, 16}; // Disquito
const SDL_Rect destRect2 = {60, 88 + (16 * 1), 16, 16}; // Gavineixon
@@ -231,7 +231,7 @@ void Instructions::checkInput() {
}
// Bucle para la pantalla de instrucciones (compatibilidad)
void Instructions::run(mode_e mode) {
void Instructions::run(InstructionsMode mode) {
start(mode);
while (!finished) {
@@ -250,7 +250,7 @@ void Instructions::run(mode_e mode) {
}
// Inicia las instrucciones (sin bucle)
void Instructions::start(mode_e mode) {
void Instructions::start(InstructionsMode mode) {
this->mode = mode;
finished = false;
quitRequested = false;
+7 -7
View File
@@ -7,9 +7,9 @@
class Sprite;
class Text;
class Texture;
struct section_t;
struct Section;
enum mode_e : std::uint8_t {
enum InstructionsMode : std::uint8_t {
m_manual,
m_auto
};
@@ -24,7 +24,7 @@ class Instructions {
SDL_Texture *backbuffer; // Textura para usar como backbuffer
Sprite *sprite; // Sprite con la textura de las instrucciones
Text *text; // Objeto para escribir texto
section_t *section; // Estado del bucle principal para saber si continua o se sale
Section *section; // Estado del bucle principal para saber si continua o se sale
// Variables
Uint16 counter; // Contador
@@ -32,7 +32,7 @@ class Instructions {
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
bool manualQuit; // Indica si se quiere salir del modo manual
mode_e mode{m_auto}; // Modo en el que se van a ejecutar las instrucciones
InstructionsMode mode{m_auto}; // Modo en el que se van a ejecutar las instrucciones
bool finished; // Indica si las instrucciones han terminado
bool quitRequested; // Indica si se ha solicitado salir de la aplicación
@@ -41,7 +41,7 @@ class Instructions {
public:
// Constructor
Instructions(SDL_Renderer *renderer, section_t *section);
Instructions(SDL_Renderer *renderer, Section *section);
// Destructor
~Instructions();
@@ -50,10 +50,10 @@ class Instructions {
auto operator=(const Instructions &) -> Instructions & = delete;
// Bucle principal
void run(mode_e mode);
void run(InstructionsMode mode);
// Inicia las instrucciones (sin bucle)
void start(mode_e mode);
void start(InstructionsMode mode);
// Actualiza las variables
void update();
+3 -3
View File
@@ -6,7 +6,7 @@
#include "core/audio/audio.hpp" // for Audio::get, Audio::update
#include "core/input/global_inputs.hpp" // for GlobalInputs::handle
#include "core/input/input.h" // for Input, REPEAT_FALSE, inputs_e
#include "core/input/input.h" // for Input, REPEAT_FALSE, InputAction
#include "core/locale/lang.h" // for Lang
#include "core/rendering/screen.h" // for Screen
#include "core/rendering/smartsprite.h" // for SmartSprite
@@ -15,10 +15,10 @@
#include "core/rendering/writer.h" // for Writer
#include "core/resources/resource.h"
#include "game/defaults.hpp" // for GAMECANVAS_CENTER_X, GAMECANVAS_FIRST_QU...
#include "utils/utils.h" // for section_t, color_t
#include "utils/utils.h" // for Section, Color
// Constructor
Intro::Intro(SDL_Renderer *renderer, section_t *section) {
Intro::Intro(SDL_Renderer *renderer, Section *section) {
// Copia los punteros
this->renderer = renderer;
this->section = section;
+3 -3
View File
@@ -8,7 +8,7 @@ class Text;
class Texture;
class Writer;
struct JA_Music_t;
struct section_t;
struct Section;
// Clase Intro
class Intro {
@@ -20,7 +20,7 @@ class Intro {
std::vector<SmartSprite *> bitmaps; // Vector con los sprites inteligentes para los dibujos de la intro
std::vector<Writer *> texts; // Textos de la intro
Text *text; // Textos de la intro
section_t *section; // Estado del bucle principal para saber si continua o se sale
Section *section; // Estado del bucle principal para saber si continua o se sale
// Variables
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
@@ -42,7 +42,7 @@ class Intro {
public:
// Constructor
Intro(SDL_Renderer *renderer, section_t *section);
Intro(SDL_Renderer *renderer, Section *section);
// Destructor
~Intro();
+3 -3
View File
@@ -7,21 +7,21 @@
#include "core/audio/audio.hpp" // for Audio::get, Audio::update
#include "core/input/global_inputs.hpp" // for GlobalInputs::handle
#include "core/input/input.h" // for Input, REPEAT_FALSE, inputs_e
#include "core/input/input.h" // for Input, REPEAT_FALSE, InputAction
#include "core/rendering/screen.h" // for Screen
#include "core/rendering/sprite.h" // for Sprite
#include "core/rendering/texture.h" // for Texture
#include "core/resources/asset.h" // for Asset
#include "core/resources/resource.h"
#include "game/defaults.hpp" // for bgColor, SECTION_PROG_LOGO, SECTION_PROG...
#include "utils/utils.h" // for section_t, color_t
#include "utils/utils.h" // for Section, Color
// Valores de inicialización y fin
constexpr int INIT_FADE = 100;
constexpr int END_LOGO = 200;
// Constructor
Logo::Logo(SDL_Renderer *renderer, section_t *section) {
Logo::Logo(SDL_Renderer *renderer, Section *section) {
// Copia la dirección de los objetos
this->renderer = renderer;
this->section = section;
+3 -3
View File
@@ -3,7 +3,7 @@
#include <SDL3/SDL.h>
class Sprite;
class Texture;
struct section_t;
struct Section;
// Clase Logo
class Logo {
@@ -13,7 +13,7 @@ class Logo {
Texture *texture; // Textura con los graficos
SDL_Event *eventHandler; // Manejador de eventos
Sprite *sprite; // Sprite con la textura del logo
section_t *section; // Estado del bucle principal para saber si continua o se sale
Section *section; // Estado del bucle principal para saber si continua o se sale
// Variables
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
@@ -37,7 +37,7 @@ class Logo {
public:
// Constructor
Logo(SDL_Renderer *renderer, section_t *section);
Logo(SDL_Renderer *renderer, Section *section);
// Destructor
~Logo();
+4 -4
View File
@@ -25,7 +25,7 @@
#include "game/ui/menu.h" // for Menu
// Constructor
Title::Title(SDL_Renderer *renderer, section_t *section) {
Title::Title(SDL_Renderer *renderer, Section *section) {
// Copia las direcciones de los punteros
this->renderer = renderer;
this->section = section;
@@ -112,7 +112,7 @@ void Title::init() {
// Pone valores por defecto a las opciones de control
Options::inputs.clear();
input_t inp;
InputDevice inp;
inp.id = 0;
inp.name = "KEYBOARD";
inp.deviceType = INPUT_USE_KEYBOARD;
@@ -929,7 +929,7 @@ void Title::run() {
}
// Inicia la parte donde se muestran las instrucciones
void Title::runInstructions(mode_e mode) {
void Title::runInstructions(InstructionsMode mode) {
instructions = new Instructions(renderer, section);
instructions->start(mode);
instructionsActive = true;
@@ -1046,7 +1046,7 @@ void Title::checkInputDevices() {
}
const int numControllers = Input::get()->getNumControllers();
availableInputDevices.clear();
input_t temp;
InputDevice temp;
// Añade todos los mandos
if (numControllers > 0) {
+9 -9
View File
@@ -5,8 +5,8 @@
#include <vector> // for vector
#include "game/options.hpp" // for Options::Video, Options::Window (per snapshot cancel)
#include "game/scenes/instructions.h" // for mode_e
#include "utils/utils.h" // for input_t, section_t
#include "game/scenes/instructions.h" // for InstructionsMode
#include "utils/utils.h" // for InputDevice, Section
class AnimatedSprite;
class Fade;
class Game;
@@ -42,7 +42,7 @@ class Title {
Instructions *instructions{nullptr}; // Objeto para la sección de las instrucciones
Game *demoGame{nullptr}; // Objeto para lanzar la demo del juego
SDL_Event *eventHandler; // Manejador de eventos
section_t *section; // Indicador para el bucle del titulo
Section *section; // Indicador para el bucle del titulo
Texture *dustTexture; // Textura con los graficos del polvo
Texture *coffeeTexture; // Textura con los graficos de la palabra coffee
@@ -74,7 +74,7 @@ class Title {
float sin[360]; // Vector con los valores del seno precalculados
bool menuVisible; // Indicador para saber si se muestra el menu del titulo o la frase intermitente
bool demo; // Indica si el modo demo estará activo
section_t nextSection; // Indica cual es la siguiente sección a cargar cuando termine el contador del titulo
Section nextSection; // Indica cual es la siguiente sección a cargar cuando termine el contador del titulo
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
Uint8 postFade; // Opción a realizar cuando termina el fundido
menu_t menu; // Variable con todos los objetos menus y sus variables
@@ -82,8 +82,8 @@ class Title {
Options::Video prevVideo;
Options::Window prevWindow;
Options::Settings prevSettings;
std::vector<input_t> prevInputs;
std::vector<input_t> availableInputDevices; // Vector con todos los metodos de control disponibles
std::vector<InputDevice> prevInputs;
std::vector<InputDevice> availableInputDevices; // Vector con todos los metodos de control disponibles
std::vector<int> deviceIndex; // Indice para el jugador [i] del vector de dispositivos de entrada disponibles
// Variables para la vibración del título (SUBSECTION_TITLE_2)
@@ -95,7 +95,7 @@ class Title {
// Variables para sub-estados delegados (instrucciones y demo)
bool instructionsActive; // Indica si las instrucciones están activas
bool demoGameActive; // Indica si el juego demo está activo
mode_e instructionsMode{m_auto}; // Modo de las instrucciones activas
InstructionsMode instructionsMode{m_auto}; // Modo de las instrucciones activas
bool demoThenInstructions; // Indica si tras la demo hay que mostrar instrucciones
// Inicializa los valores
@@ -123,7 +123,7 @@ class Title {
void applyOptions();
// Ejecuta la parte donde se muestran las instrucciones
void runInstructions(mode_e mode);
void runInstructions(InstructionsMode mode);
// Ejecuta el juego en modo demo
void runDemoGame();
@@ -142,7 +142,7 @@ class Title {
public:
// Constructor
Title(SDL_Renderer *renderer, section_t *section);
Title(SDL_Renderer *renderer, Section *section);
// Destructor
~Title();
+10 -10
View File
@@ -7,7 +7,7 @@
#include "core/audio/audio.hpp" // for Audio::get (playSound)
#include "core/audio/jail_audio.hpp" // for JA_LoadSound, JA_DeleteSound (propietat local)
#include "core/input/input.h" // for Input, REPEAT_FALSE, inputs_e
#include "core/input/input.h" // for Input, REPEAT_FALSE, InputAction
#include "core/rendering/text.h" // for Text
#include "core/resources/asset.h" // for Asset
#include "core/resources/resource_helper.h"
@@ -581,7 +581,7 @@ void Menu::render() {
}
// Crea una linea por si hay que dibujarla entre los items
h_line_t line;
HorizontalLine line;
line.x1 = selector.rect.x + (selector.rect.w / 6);
line.x2 = line.x1 + ((selector.rect.w / 6) * 4);
@@ -601,12 +601,12 @@ void Menu::render() {
}
else if (i == selector.index) { // A continuación si tiene el indice
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
const Color color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, color);
}
else if (i == selector.previousIndex) { // O si lo ha tenido
const color_t color = {selector.previousItemColor.r, selector.previousItemColor.g, selector.previousItemColor.b};
const Color color = {selector.previousItemColor.r, selector.previousItemColor.g, selector.previousItemColor.b};
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, color);
}
@@ -616,7 +616,7 @@ void Menu::render() {
else { // Si no es seleccionable
if ((item[i].linkedUp) && (i == selector.index + 1)) { // Si el elemento está enlazado con el elemento superior se pinta del color del selector
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
const Color color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
text->writeColored(item[i].rect.x, item[i].rect.y, item[i].label, color);
} else { // Si no está enlazado con el elemento superior se pinta con el color normal
text->write(item[i].rect.x, item[i].rect.y, item[i].label);
@@ -662,19 +662,19 @@ void Menu::setRectSize(int w, int h) {
}
// Establece el color del rectangulo de fondo
void Menu::setBackgroundColor(color_t color, int alpha) {
void Menu::setBackgroundColor(Color color, int alpha) {
rectBG.color = color;
rectBG.a = alpha;
}
// Establece el color del rectangulo del selector
void Menu::setSelectorColor(color_t color, int alpha) {
void Menu::setSelectorColor(Color color, int alpha) {
selector.color = color;
selector.a = alpha;
}
// Establece el color del texto del selector
void Menu::setSelectorTextColor(color_t color) {
void Menu::setSelectorTextColor(Color color) {
selector.itemColor = color;
}
@@ -878,8 +878,8 @@ void Menu::setText(const std::string &font_png, const std::string &font_txt) {
// Calcula los colores del selector para el degradado
void Menu::setSelectorItemColors() {
const color_t colorFrom = {255, 255, 255};
const color_t colorTo = selector.itemColor;
const Color colorFrom = {255, 255, 255};
const Color colorTo = selector.itemColor;
for (int i = 0; i < selector.numJumps; ++i) {
const float step = ((float)i / (selector.numJumps - 1));
+10 -10
View File
@@ -6,7 +6,7 @@
#include <string> // for string, basic_string
#include <vector> // for vector
#include "utils/utils.h" // for color_t
#include "utils/utils.h" // for Color
class Text;
struct JA_Sound_t;
@@ -27,7 +27,7 @@ class Menu {
private:
struct rectangle_t {
SDL_Rect rect; // Rectangulo
color_t color; // Color
Color color; // Color
int a; // Transparencia
};
@@ -57,11 +57,11 @@ class Menu {
int numJumps; // Numero de pasos preestablecido para llegar al destino
int index; // Elemento del menu que tiene el foco
int previousIndex; // Elemento que tenia el foco previamente
color_t previousItemColor; // Color del item nque tenia el foco previamente
Color previousItemColor; // Color del item nque tenia el foco previamente
SDL_Rect rect; // Rectangulo del selector
color_t color; // Color del selector
color_t itemColor; // Color del item
color_t jumpItemColors[8]; // Transición de colores para el item seleccionado
Color color; // Color del selector
Color itemColor; // Color del item
Color jumpItemColors[8]; // Transición de colores para el item seleccionado
int itemColorIndex; // Indice del color de transición para el item seleccionado
int a; // Cantidad de transparencia para el rectangulo del selector
};
@@ -88,7 +88,7 @@ class Menu {
JA_Sound_t *soundAccept; // Sonido al aceptar o elegir una opción del menu
JA_Sound_t *soundCancel; // Sonido al cancelar el menu
JA_Sound_t *soundMove; // Sonido al mover el selector
color_t colorGreyed; // Color para los elementos agrisados
Color colorGreyed; // Color para los elementos agrisados
rectangle_t rectBG; // Rectangulo de fondo del menu
std::vector<item_t> item; // Estructura para cada elemento del menu
selector_t selector; // Variables para pintar el selector del menu
@@ -172,13 +172,13 @@ class Menu {
void render();
// Establece el color del rectangulo de fondo
void setBackgroundColor(color_t color, int alpha);
void setBackgroundColor(Color color, int alpha);
// Establece el color del rectangulo del selector
void setSelectorColor(color_t color, int alpha);
void setSelectorColor(Color color, int alpha);
// Establece el color del texto del selector
void setSelectorTextColor(color_t color);
void setSelectorTextColor(Color color);
// Centra el menu respecto a un punto en el eje X
void centerMenuOnX(int value = 0);
+12 -12
View File
@@ -13,7 +13,7 @@ auto distanceSquared(int x1, int y1, int x2, int y2) -> double {
}
// Detector de colisiones entre dos circulos
auto checkCollision(const circle_t &a, const circle_t &b) -> bool {
auto checkCollision(const Circle &a, const Circle &b) -> bool {
// Calcula el radio total al cuadrado
int totalRadiusSquared = a.r + b.r;
totalRadiusSquared = totalRadiusSquared * totalRadiusSquared;
@@ -23,7 +23,7 @@ auto checkCollision(const circle_t &a, const circle_t &b) -> bool {
}
// Detector de colisiones entre un circulo y un rectangulo
auto checkCollision(const circle_t &a, const SDL_Rect &b) -> bool {
auto checkCollision(const Circle &a, const SDL_Rect &b) -> bool {
// Closest point on collision box
int cX;
int cY;
@@ -46,9 +46,9 @@ auto checkCollision(const circle_t &a, const SDL_Rect &b) -> bool {
cY = a.y;
}
// If the closest point is inside the circle_t
// If the closest point is inside the Circle
if (distanceSquared(a.x, a.y, cX, cY) < a.r * a.r) {
// This box and the circle_t have collided
// This box and the Circle have collided
return true;
}
@@ -118,7 +118,7 @@ auto checkCollision(const SDL_Point &p, const SDL_Rect &r) -> bool {
}
// Detector de colisiones entre una linea horizontal y un rectangulo
auto checkCollision(const h_line_t &l, const SDL_Rect &r) -> bool {
auto checkCollision(const HorizontalLine &l, const SDL_Rect &r) -> bool {
// Comprueba si la linea esta por encima del rectangulo
if (l.y < r.y) {
return false;
@@ -144,7 +144,7 @@ auto checkCollision(const h_line_t &l, const SDL_Rect &r) -> bool {
}
// Detector de colisiones entre una linea vertical y un rectangulo
auto checkCollision(const v_line_t &l, const SDL_Rect &r) -> bool {
auto checkCollision(const VerticalLine &l, const SDL_Rect &r) -> bool {
// Comprueba si la linea esta por la izquierda del rectangulo
if (l.x < r.x) {
return false;
@@ -170,7 +170,7 @@ auto checkCollision(const v_line_t &l, const SDL_Rect &r) -> bool {
}
// Detector de colisiones entre una linea horizontal y un punto
auto checkCollision(const h_line_t &l, const SDL_Point &p) -> bool {
auto checkCollision(const HorizontalLine &l, const SDL_Point &p) -> bool {
// Comprueba si el punto esta sobre la linea
if (p.y > l.y) {
return false;
@@ -196,7 +196,7 @@ auto checkCollision(const h_line_t &l, const SDL_Point &p) -> bool {
}
// Detector de colisiones entre dos lineas
auto checkCollision(const line_t &l1, const line_t &l2) -> SDL_Point {
auto checkCollision(const Line &l1, const Line &l2) -> SDL_Point {
const float x1 = l1.x1;
const float y1 = l1.y1;
const float x2 = l1.x2;
@@ -223,7 +223,7 @@ auto checkCollision(const line_t &l1, const line_t &l2) -> SDL_Point {
}
// Detector de colisiones entre dos lineas
auto checkCollision(const d_line_t &l1, const v_line_t &l2) -> SDL_Point {
auto checkCollision(const DiagonalLine &l1, const VerticalLine &l2) -> SDL_Point {
const float x1 = l1.x1;
const float y1 = l1.y1;
const float x2 = l1.x2;
@@ -250,7 +250,7 @@ auto checkCollision(const d_line_t &l1, const v_line_t &l2) -> SDL_Point {
}
// Detector de colisiones entre una linea diagonal y una vertical
/*bool checkCollision(d_line_t &l1, v_line_t &l2)
/*bool checkCollision(DiagonalLine &l1, VerticalLine &l2)
{
// Normaliza la linea diagonal
normalizeLine(l1);
@@ -272,7 +272,7 @@ auto checkCollision(const d_line_t &l1, const v_line_t &l2) -> SDL_Point {
}*/
// Normaliza una linea diagonal
void normalizeLine(d_line_t &l) {
void normalizeLine(DiagonalLine &l) {
// Las lineas diagonales van de izquierda a derecha
// x2 mayor que x1
if (l.x2 < l.x1) {
@@ -286,7 +286,7 @@ void normalizeLine(d_line_t &l) {
}
// Detector de colisiones entre un punto y una linea diagonal
auto checkCollision(const SDL_Point &p, const d_line_t &l) -> bool {
auto checkCollision(const SDL_Point &p, const DiagonalLine &l) -> bool {
// Comprueba si el punto está en alineado con la linea
if (abs(p.x - l.x1) != abs(p.y - l.y1)) {
return false;
+20 -20
View File
@@ -11,56 +11,56 @@ constexpr int DIFFICULTY_NORMAL = 1;
constexpr int DIFFICULTY_HARD = 2;
// Estructura para definir un circulo
struct circle_t {
struct Circle {
int x;
int y;
int r;
};
// Estructura para definir una linea horizontal
struct h_line_t {
struct HorizontalLine {
int x1, x2, y;
};
// Estructura para definir una linea vertical
struct v_line_t {
struct VerticalLine {
int x, y1, y2;
};
// Estructura para definir una linea diagonal
struct d_line_t {
struct DiagonalLine {
int x1, y1, x2, y2;
};
// Estructura para definir una linea
struct line_t {
struct Line {
int x1, y1, x2, y2;
};
// Estructura para definir un color
struct color_t {
struct Color {
Uint8 r;
Uint8 g;
Uint8 b;
color_t()
Color()
: r(0),
g(0),
b(0) {} // Constructor por defecto
color_t(Uint8 red, Uint8 green, Uint8 blue)
Color(Uint8 red, Uint8 green, Uint8 blue)
: r(red),
g(green),
b(blue) {}
};
// Estructura para saber la seccion y subseccion del programa
struct section_t {
struct Section {
Uint8 name;
Uint8 subsection;
};
// Estructura para mapear el teclado usado en la demo
struct demoKeys_t {
struct DemoKeys {
Uint8 left;
Uint8 right;
Uint8 noInput;
@@ -70,7 +70,7 @@ struct demoKeys_t {
};
// Estructura para albergar métodos de control
struct input_t {
struct InputDevice {
int id; // Identificador en el vector de mandos
std::string name; // Nombre del dispositivo
Uint8 deviceType; // Tipo de dispositivo (teclado o mando)
@@ -80,10 +80,10 @@ struct input_t {
auto distanceSquared(int x1, int y1, int x2, int y2) -> double;
// Detector de colisiones entre dos circulos
auto checkCollision(const circle_t &a, const circle_t &b) -> bool;
auto checkCollision(const Circle &a, const Circle &b) -> bool;
// Detector de colisiones entre un circulo y un rectangulo
auto checkCollision(const circle_t &a, const SDL_Rect &b) -> bool;
auto checkCollision(const Circle &a, const SDL_Rect &b) -> bool;
// Detector de colisiones entre un dos rectangulos
auto checkCollision(const SDL_Rect &a, const SDL_Rect &b) -> bool;
@@ -92,25 +92,25 @@ auto checkCollision(const SDL_Rect &a, const SDL_Rect &b) -> bool;
auto checkCollision(const SDL_Point &p, const SDL_Rect &r) -> bool;
// Detector de colisiones entre una linea horizontal y un rectangulo
auto checkCollision(const h_line_t &l, const SDL_Rect &r) -> bool;
auto checkCollision(const HorizontalLine &l, const SDL_Rect &r) -> bool;
// Detector de colisiones entre una linea vertical y un rectangulo
auto checkCollision(const v_line_t &l, const SDL_Rect &r) -> bool;
auto checkCollision(const VerticalLine &l, const SDL_Rect &r) -> bool;
// Detector de colisiones entre una linea horizontal y un punto
auto checkCollision(const h_line_t &l, const SDL_Point &p) -> bool;
auto checkCollision(const HorizontalLine &l, const SDL_Point &p) -> bool;
// Detector de colisiones entre dos lineas
auto checkCollision(const line_t &l1, const line_t &l2) -> SDL_Point;
auto checkCollision(const Line &l1, const Line &l2) -> SDL_Point;
// Detector de colisiones entre dos lineas
auto checkCollision(const d_line_t &l1, const v_line_t &l2) -> SDL_Point;
auto checkCollision(const DiagonalLine &l1, const VerticalLine &l2) -> SDL_Point;
// Detector de colisiones entre un punto y una linea diagonal
auto checkCollision(const SDL_Point &p, const d_line_t &l) -> bool;
auto checkCollision(const SDL_Point &p, const DiagonalLine &l) -> bool;
// Normaliza una linea diagonal
void normalizeLine(d_line_t &l);
void normalizeLine(DiagonalLine &l);
// Convierte una cadena en un valor booleano
auto stringToBool(const std::string &str) -> bool;