clang-format
This commit is contained in:
2025-07-23 20:55:50 +02:00
parent d33c1f5dc5
commit ec008ef5dd
61 changed files with 308 additions and 253 deletions

View File

@@ -2,5 +2,7 @@
clang-tidy source/fitxer.cpp -p build/ --fix
# Per a varios fitxers, desde l'arrel:
find source/ \( -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) | xargs -P4 -I{} clang-tidy {} -p build/ --fix
find source/ \( -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) | \
xargs -P4 -I{} bash -c 'echo "Procesando: {}"; clang-tidy {} -p build/ --fix'

View File

@@ -1,15 +1,16 @@
#include "animated_sprite.h"
#include <SDL3/SDL.h> // Para SDL_LogWarn, SDL_LogCategory, SDL_LogError, SDL_FRect
#include <algorithm> // Para min, max
#include <cstddef> // Para size_t
#include <fstream> // Para basic_istream, basic_ifstream, basic_ios, ifstream, stringstream
#include <sstream> // Para basic_stringstream
#include <stdexcept> // Para runtime_error
#include <utility> // Para pair
#include "texture.h" // Para Texture
#include "utils.h" // Para printWithDots
#include <algorithm> // Para min, max
#include <cstddef> // Para size_t
#include <fstream> // Para basic_istream, basic_ifstream, basic_ios, ifstream, stringstream
#include <sstream> // Para basic_stringstream
#include <stdexcept> // Para runtime_error
#include <utility> // Para pair
#include "texture.h" // Para Texture
#include "utils.h" // Para printWithDots
// Carga las animaciones en un vector(Animations) desde un fichero
auto loadAnimationsFromFile(const std::string& file_path) -> AnimationsFileBuffer {

View File

@@ -1,6 +1,7 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_FRect
#include <algorithm> // Para max
#include <cstddef> // Para size_t
#include <memory> // Para allocator, shared_ptr

View File

@@ -1,13 +1,14 @@
#include "asset.h"
#include <SDL3/SDL.h> // Para SDL_LogInfo, SDL_LogCategory, SDL_LogError, SDL_LogWarn
#include <algorithm> // Para max
#include <fstream> // Para basic_ifstream, ifstream
#include <functional> // Para identity
#include <ranges> // Para __find_if_fn, find_if
#include <string> // Para allocator, string, operator==, operator+, char_traits, basic_string
#include "utils.h" // Para getFileName
#include "utils.h" // Para getFileName
// Singleton
Asset *Asset::instance = nullptr;

View File

@@ -2,6 +2,7 @@
#include "background.h"
#include <SDL3/SDL.h> // Para SDL_FRect, SDL_SetRenderTarget, SDL_CreateTexture, SDL_DestroyTexture, SDL_GetRenderTarget, SDL_RenderTexture, SDL_SetTextureAlphaMod, SDL_SetTextureBlendMode, SDL_BLENDMODE_BLEND, SDL_PixelFormat, SDL_RenderClear, SDL_SetRenderDrawColor, SDL_TextureAccess, SDL_FPoint
#include <algorithm> // Para clamp, max
#include <cmath> // Para M_PI, cos, sin

View File

@@ -1,12 +1,13 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_FRect, SDL_FPoint, SDL_Texture, SDL_Renderer
#include <array> // Para array
#include <cstddef> // Para size_t
#include <memory> // Para unique_ptr, shared_ptr
#include <vector> // Para vector
#include "color.h" // Para Color
#include <array> // Para array
#include <cstddef> // Para size_t
#include <memory> // Para unique_ptr, shared_ptr
#include <vector> // Para vector
#include "color.h" // Para Color
class MovingSprite;
class Sprite;

View File

@@ -171,13 +171,13 @@ void Balloon::handleVerticalMovement() {
handleBottomCollision();
}
bool Balloon::isOutOfHorizontalBounds(float minX, float maxX) const {
return x_ < minX || x_ > maxX;
auto Balloon::isOutOfHorizontalBounds(float min_x, float max_x) const -> bool {
return x_ < min_x || x_ > max_x;
}
void Balloon::handleHorizontalBounce(float minX, float maxX) {
void Balloon::handleHorizontalBounce(float min_x, float max_x) {
playBouncingSound();
x_ = std::clamp(x_, minX, maxX);
x_ = std::clamp(x_, min_x, max_x);
vx_ = -vx_;
if (type_ == BalloonType::POWERBALL) {
@@ -187,7 +187,7 @@ void Balloon::handleHorizontalBounce(float minX, float maxX) {
}
}
bool Balloon::shouldCheckTopCollision() const {
auto Balloon::shouldCheckTopCollision() const -> bool {
// Colisión en la parte superior solo si el globo va de subida
return vy_ < 0;
}

View File

@@ -184,16 +184,16 @@ class Balloon {
void applyGravity(); // Aplica la gravedad al objeto
// --- Rebote ---
void enableBounceEffect(); // Activa el efecto de rebote
void disableBounceEffect(); // Detiene el efecto de rebote
void updateBounceEffect(); // Actualiza el estado del rebote
void handleHorizontalBounce(float minX, float maxX); // Maneja el rebote horizontal dentro de límites
void enableBounceEffect(); // Activa el efecto de rebote
void disableBounceEffect(); // Detiene el efecto de rebote
void updateBounceEffect(); // Actualiza el estado del rebote
void handleHorizontalBounce(float min_x, float max_x); // Maneja el rebote horizontal dentro de límites
// --- Colisiones ---
bool isOutOfHorizontalBounds(float minX, float maxX) const; // Verifica si está fuera de los límites horizontales
bool shouldCheckTopCollision() const; // Determina si debe comprobarse la colisión superior
void handleTopCollision(); // Maneja la colisión superior
void handleBottomCollision(); // Maneja la colisión inferior
[[nodiscard]] auto isOutOfHorizontalBounds(float min_x, float max_x) const -> bool; // Verifica si está fuera de los límites horizontales
[[nodiscard]] auto shouldCheckTopCollision() const -> bool; // Determina si debe comprobarse la colisión superior
void handleTopCollision(); // Maneja la colisión superior
void handleBottomCollision(); // Maneja la colisión inferior
// --- Lógica de estado ---
void updateState(); // Actualiza los estados del globo

View File

@@ -1,11 +1,12 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_FRect
#include <algorithm> // Para max
#include <array> // Para array
#include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para string
#include <vector> // Para vector
#include <SDL3/SDL.h> // Para SDL_FRect
#include <algorithm> // Para max
#include <array> // Para array
#include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para string
#include <vector> // Para vector
#include "balloon.h" // Para BALLOON_SPEED, Balloon, BalloonSize (ptr only), BalloonType (ptr only)
#include "balloon_formations.h" // Para BalloonFormations

View File

@@ -1,8 +1,9 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint8
#include <memory> // Para unique_ptr
#include <string> // Para string
#include <SDL3/SDL.h> // Para Uint8
#include <memory> // Para unique_ptr
#include <string> // Para string
#include "animated_sprite.h" // Para AnimatedSprite
#include "utils.h" // Para Circle

View File

@@ -1,10 +1,12 @@
#define _USE_MATH_DEFINES
#include "color.h"
#include <algorithm> // Para min, clamp
#include <cmath> // Para fmaxf, fminf, M_PI, fmodf, roundf, sin, abs
#include <stdexcept> // Para invalid_argument
#include <string> // Para basic_string, string
#include <stdint.h> // Para uint8_t
#include <cctype> // Para isxdigit
#include <cmath> // Para sinf, fmaxf, fminf, M_PI, fmodf, roundf, fmod
#include <stdexcept> // Para invalid_argument
#include <string> // Para basic_string, stoi, string
// Método estático para crear Color desde string hexadecimal
auto Color::fromHex(const std::string &hex_str) -> Color {

View File

@@ -1,13 +1,12 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint8
#include <SDL3/SDL.h> // Para Uint8
#include <bits/std_abs.h> // Para abs
#include <algorithm> // Para max, min
#include <array> // Para array
#include <cctype> // Para isxdigit
#include <cstdlib> // Para abs
#include <stdexcept> // Para invalid_argument
#include <string> // Para string, basic_string, stoi
#include <cstdlib> // Para size_t, abs
#include <string> // Para string
#include <vector> // Para vector
// --- Constantes ---

View File

@@ -1,6 +1,7 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_GamepadButton, SDL_Event, SDL_GamepadButtonEvent
#include <cstddef> // Para size_t
#include <memory> // Para shared_ptr
#include <string> // Para basic_string, string

View File

@@ -1,6 +1,6 @@
#include "difficulty.h"
#include <vector> // Para vector
#include <vector> // Para vector
namespace Difficulty {
@@ -10,8 +10,7 @@ void init() {
difficulties_list = {
{Code::EASY, "Easy"},
{Code::NORMAL, "Normal"},
{Code::HARD, "Hard"}
};
{Code::HARD, "Hard"}};
}
auto getDifficulties() -> std::vector<Info>& {
@@ -36,4 +35,4 @@ auto getCodeFromName(const std::string& name) -> Code {
return !difficulties_list.empty() ? difficulties_list.front().code : Code::NORMAL;
}
} // namespace Difficulty
} // namespace Difficulty

View File

@@ -18,8 +18,8 @@ enum class Code {
* @brief Estructura que asocia un código de dificultad con su nombre traducible.
*/
struct Info {
Code code;
std::string name;
Code code;
std::string name;
};
// --- Interfaz Pública ---
@@ -49,4 +49,4 @@ auto getNameFromCode(Code code) -> std::string;
*/
auto getCodeFromName(const std::string& name) -> Code;
} // namespace Difficulty
} // namespace Difficulty

View File

@@ -4,7 +4,7 @@
#include <cstdlib> // Para rand
#include <string_view> // Para basic_string_view, string_view
#include "utils.h" // Para trim
#include "utils.h" // Para trim
// Constructor
EnterName::EnterName()

View File

@@ -1,7 +1,8 @@
#include "game_logo.h"
#include <SDL3/SDL.h> // Para SDL_SetTextureScaleMode, SDL_FlipMode, SDL_ScaleMode
#include <algorithm> // Para max
#include <SDL3/SDL.h> // Para SDL_SetTextureScaleMode, SDL_FlipMode, SDL_ScaleMode
#include <algorithm> // Para max
#include "animated_sprite.h" // Para AnimatedSprite
#include "audio.h" // Para Audio
@@ -192,10 +193,10 @@ void GameLogo::processShakeEffect(SmartSprite* primary_sprite, SmartSprite* seco
shake_.counter--;
} else {
shake_.counter = shake_.delay;
const auto displacement = calculateShakeDisplacement();
primary_sprite->setPosX(shake_.origin + displacement);
if (secondary_sprite) {
secondary_sprite->setPosX(shake_.origin + displacement + 15);
const auto DISPLACEMENT = calculateShakeDisplacement();
primary_sprite->setPosX(shake_.origin + DISPLACEMENT);
if (secondary_sprite != nullptr) {
secondary_sprite->setPosX(shake_.origin + DISPLACEMENT + 15);
}
shake_.remaining--;
}
@@ -206,13 +207,13 @@ void GameLogo::processArcadeEditionShake() {
shake_.counter--;
} else {
shake_.counter = shake_.delay;
const auto displacement = calculateShakeDisplacement();
arcade_edition_sprite_->setX(shake_.origin + displacement);
const auto DISPLACEMENT = calculateShakeDisplacement();
arcade_edition_sprite_->setX(shake_.origin + DISPLACEMENT);
shake_.remaining--;
}
}
int GameLogo::calculateShakeDisplacement() const {
auto GameLogo::calculateShakeDisplacement() const -> int {
return shake_.remaining % 2 == 0 ? shake_.desp * (-1) : shake_.desp;
}

View File

@@ -86,13 +86,13 @@ class GameLogo {
void updatePostFinishedCounter(); // Actualiza el contador tras finalizar una animación
// --- Efectos visuales: movimiento y sacudidas ---
void handleCoffeeCrisisMoving(); // Maneja el movimiento de "Coffee Crisis"
void handleCoffeeCrisisShaking(); // Maneja la sacudida de "Coffee Crisis"
void handleArcadeEditionMoving(); // Maneja el movimiento de "Arcade Edition"
void handleArcadeEditionShaking(); // Maneja la sacudida de "Arcade Edition"
void handleCoffeeCrisisMoving(); // Maneja el movimiento de "Coffee Crisis"
void handleCoffeeCrisisShaking(); // Maneja la sacudida de "Coffee Crisis"
void handleArcadeEditionMoving(); // Maneja el movimiento de "Arcade Edition"
void handleArcadeEditionShaking(); // Maneja la sacudida de "Arcade Edition"
void processShakeEffect(SmartSprite* primary_sprite, SmartSprite* secondary_sprite = nullptr); // Procesa el efecto de sacudida en sprites
void processArcadeEditionShake(); // Procesa la sacudida específica de "Arcade Edition"
int calculateShakeDisplacement() const; // Calcula el desplazamiento de la sacudida
void processArcadeEditionShake(); // Procesa la sacudida específica de "Arcade Edition"
[[nodiscard]] auto calculateShakeDisplacement() const -> int; // Calcula el desplazamiento de la sacudida
// --- Gestión de finalización de efectos ---
void handleCoffeeCrisisFinished(); // Maneja el final de la animación "Coffee Crisis"
@@ -100,6 +100,6 @@ class GameLogo {
void finishArcadeEditionMoving(); // Finaliza el movimiento de "Arcade Edition"
// --- Utilidades ---
void playTitleEffects(); // Reproduce efectos visuales/sonoros del título
void updateDustSprites(); // Actualiza los sprites de polvo
static void playTitleEffects(); // Reproduce efectos visuales/sonoros del título
void updateDustSprites(); // Actualiza los sprites de polvo
};

View File

@@ -1,6 +1,7 @@
#include "input.h"
#include <SDL3/SDL.h> // Para SDL_LogInfo, SDL_LogCategory, SDL_GetGamepa...
#include <algorithm> // Para find
#include <cstddef> // Para size_t
#include <iterator> // Para distance

View File

@@ -1,6 +1,7 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_GamepadButton, Uint8, SDL_Gamepad, SDL_Joystick, SDL_JoystickID, SDL_Scancode, Sint16
#include <string> // Para basic_string, string
#include <vector> // Para vector

View File

@@ -1,9 +1,10 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_FRect, Uint16
#include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para string
#include <vector> // Para vector
#include <SDL3/SDL.h> // Para SDL_FRect, Uint16
#include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para string
#include <vector> // Para vector
#include "animated_sprite.h" // Para AnimatedSprite
#include "utils.h" // Para Circle

View File

@@ -1,10 +1,11 @@
#include "manage_hiscore_table.h"
#include <SDL3/SDL.h> // Para SDL_ReadIO, SDL_WriteIO, SDL_CloseIO, SDL_GetError, SDL_IOFromFile, SDL_LogCategory, SDL_LogError, SDL_LogInfo
#include <algorithm> // Para find_if, sort
#include <iterator> // Para distance
#include "utils.h" // Para getFileName
#include <algorithm> // Para find_if, sort
#include <iterator> // Para distance
#include "utils.h" // Para getFileName
// Resetea la tabla a los valores por defecto
void ManageHiScoreTable::clear() {

View File

@@ -1,20 +1,21 @@
#include "options.h"
#include <SDL3/SDL.h> // Para SDL_GamepadButton, SDL_ScaleMode, SDL_LogCategory, SDL_LogInfo, SDL_LogError, SDL_LogWarn
#include <SDL3/SDL.h> // Para SDL_ScaleMode, SDL_GamepadButton, SDL_LogCategory, SDL_LogInfo, SDL_LogError, SDL_LogWarn
#include <stddef.h> // Para size_t
#include <algorithm> // Para clamp, max
#include <fstream> // Para basic_ostream, operator<<, basic_ostream::operator<<, basic_ofstream, basic_istream, basic_ifstream, ifstream, ofstream
#include <functional>
#include <map>
#include <stdexcept> // Para excepciones de std::stoi
#include <string>
#include <utility> // Para swap
#include <vector> // Para vector
#include <algorithm> // Para clamp, max
#include <fstream> // Para basic_ostream, operator<<, basic_ostream::operator<<, basic_ofstream, basic_istream, basic_ifstream, ifstream, ofstream
#include <functional> // Para function
#include <map> // Para map, operator==, _Rb_tree_const_iterator
#include <stdexcept> // Para invalid_argument, out_of_range
#include <string> // Para char_traits, stoi, operator==, operator<<, allocator, string, basic_string, operator<=>, getline
#include <utility> // Para swap, pair
#include <vector> // Para vector
#include "difficulty.h" // Para Difficulty
#include "input.h" // Para InputDevice
#include "lang.h" // Para Code
#include "utils.h" // Para boolToString, stringToBool, getFileName
#include "difficulty.h" // Para Code, init
#include "input.h" // Para InputDevice
#include "lang.h" // Para Code
#include "utils.h" // Para boolToString, stringToBool, getFileName
namespace Options {
// --- Variables globales ---
@@ -209,7 +210,7 @@ auto set(const std::string& var, const std::string& value) -> bool {
}
// Un mapa estático asegura que se inicializa solo una vez
static const std::map<std::string, std::function<void(const std::string&)>> settings_map = {
static const std::map<std::string, std::function<void(const std::string&)>> SETTINGS_MAP = {
// Ventana
{"window.zoom", [](const auto& val) { window.zoom = std::stoi(val); }},
// Vídeo
@@ -252,7 +253,7 @@ auto set(const std::string& var, const std::string& value) -> bool {
}
// Busca el nombre de la variable en el mapa
if (auto it = settings_map.find(var); it != settings_map.end()) {
if (auto it = SETTINGS_MAP.find(var); it != SETTINGS_MAP.end()) {
try {
// Ejecuta la función lambda asociada
it->second(value);

View File

@@ -4,10 +4,9 @@
#include <algorithm> // Para copy
#include <string> // Para allocator, string
#include <utility> // Para move
#include <vector> // Para vector
#include "difficulty.h" //Para Difficulty
#include "difficulty.h" // Para Code
#include "input.h" // Para InputAction, InputDevice
#include "lang.h" // Para Code
#include "manage_hiscore_table.h" // Para HiScoreEntry
@@ -71,12 +70,12 @@ struct AudioOptions {
// --- Opciones de configuración ---
struct SettingsOptions {
Difficulty::Code difficulty{Difficulty::Code::NORMAL}; // Dificultad del juego
Lang::Code language{Lang::Code::VALENCIAN}; // Idioma usado en el juego
bool autofire{true}; // Indicador de autofire
bool shutdown_enabled{false}; // Especifica si se puede apagar el sistema
std::vector<HiScoreEntry> hi_score_table; // Tabla de mejores puntuaciones
std::vector<int> last_hi_score_entry; // Últimas posiciones de entrada en la tabla
std::string config_file; // Ruta al fichero donde guardar la configuración y las opciones del juego
Lang::Code language{Lang::Code::VALENCIAN}; // Idioma usado en el juego
bool autofire{true}; // Indicador de autofire
bool shutdown_enabled{false}; // Especifica si se puede apagar el sistema
std::vector<HiScoreEntry> hi_score_table; // Tabla de mejores puntuaciones
std::vector<int> last_hi_score_entry; // Últimas posiciones de entrada en la tabla
std::string config_file; // Ruta al fichero donde guardar la configuración y las opciones del juego
// Constructor por defecto con valores iniciales
SettingsOptions()
@@ -119,9 +118,9 @@ struct GamepadOptions {
// --- Opciones pendientes de aplicar ---
struct PendingChanges {
Lang::Code new_language{Lang::Code::VALENCIAN}; // Idioma en espera de aplicar
Lang::Code new_language{Lang::Code::VALENCIAN}; // Idioma en espera de aplicar
Difficulty::Code new_difficulty{Difficulty::Code::NORMAL}; // Dificultad en espera de aplicar
bool has_pending_changes{false}; // Indica si hay cambios pendientes
bool has_pending_changes{false}; // Indica si hay cambios pendientes
// Constructor por defecto con valores iniciales
PendingChanges() = default;

View File

@@ -1,6 +1,7 @@
#include "param.h"
#include <SDL3/SDL.h> // Para SDL_LogCategory, SDL_LogError, SDL_LogInfo
#include <fstream> // Para basic_istream, basic_ifstream, ifstream
#include <functional>
#include <sstream> // Para basic_istringstream

View File

@@ -1,6 +1,7 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint32, SDL_FRect
#include <array> // Para array
#include <string> // Para basic_string, string

View File

@@ -1,6 +1,7 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_FPoint
#include <functional> // Para std::function
#include <memory> // Para shared_ptr
#include <vector> // Para vector

View File

@@ -1,6 +1,7 @@
#include "player.h"
#include <SDL3/SDL.h> // Para SDL_GetTicks, SDL_FlipMode, SDL_FRect
#include <algorithm> // Para clamp, max, min
#include <cstdlib> // Para rand

View File

@@ -1,9 +1,10 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint32, SDL_FRect
#include <memory> // Para allocator, unique_ptr, shared_ptr
#include <string> // Para string
#include <vector> // Para vector
#include <SDL3/SDL.h> // Para Uint32, SDL_FRect
#include <memory> // Para allocator, unique_ptr, shared_ptr
#include <string> // Para string
#include <vector> // Para vector
#include "animated_sprite.h" // Para AnimatedSprite
#include "enter_name.h" // Para EnterName

View File

@@ -1,11 +1,12 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_FRect
#include <cstddef> // Para size_t
#include <memory> // Para shared_ptr
#include <string> // Para string
#include <utility> // Para move
#include <vector> // Para vector
#include <SDL3/SDL.h> // Para SDL_FRect
#include <cstddef> // Para size_t
#include <memory> // Para shared_ptr
#include <string> // Para string
#include <utility> // Para move
#include <vector> // Para vector
#include "animated_sprite.h" // Para AnimationsFileBuffer
#include "text.h" // Para Text, TextFile

View File

@@ -1,6 +1,7 @@
#include "scoreboard.h"
#include <SDL3/SDL.h> // Para SDL_DestroyTexture, SDL_SetRenderDrawColor, SDL_SetRenderTarget, SDL_CreateTexture, SDL_GetRenderTarget, SDL_GetTicks, SDL_RenderClear, SDL_RenderLine, SDL_RenderTexture, SDL_SetTextureBlendMode, SDL_FRect, SDL_BLENDMODE_BLEND, SDL_PixelFormat, SDL_Texture, SDL_TextureAccess
#include <algorithm> // Para max
#include <cmath> // Para roundf
#include <iomanip> // Para operator<<, setfill, setw

View File

@@ -1,13 +1,14 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_FPoint, SDL_GetTicks, SDL_FRect, SDL_Texture, SDL_Renderer, Uint64
#include <array> // Para array
#include <cstddef> // Para size_t
#include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para string, basic_string
#include <vector> // Para vector
#include "color.h" // Para Color
#include <array> // Para array
#include <cstddef> // Para size_t
#include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para string, basic_string
#include <vector> // Para vector
#include "color.h" // Para Color
class Sprite;
class Text;

View File

@@ -2,6 +2,7 @@
#include "credits.h"
#include <SDL3/SDL.h> // Para SDL_RenderFillRect, SDL_RenderTexture, SDL_SetRenderTarget, SDL_SetRenderDrawColor, SDL_CreateTexture, SDL_DestroyTexture, SDL_GetTicks, SDL_GetRenderTarget, SDL_PixelFormat, SDL_PollEvent, SDL_RenderClear, SDL_RenderRect, SDL_SetTextureBlendMode, SDL_TextureAccess, SDL_BLENDMODE_BLEND, SDL_Event
#include <algorithm> // Para max, min, clamp
#include <array> // Para array
#include <stdexcept> // Para runtime_error

View File

@@ -1,6 +1,7 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_FRect, Uint32, SDL_Texture, Uint64
#include <memory> // Para unique_ptr, shared_ptr
#include <vector> // Para vector
@@ -17,7 +18,7 @@ class TiledBG;
class Credits {
public:
// --- Constructores y destructor ---
// --- Constructor y destructor ---
Credits();
~Credits();

View File

@@ -15,6 +15,7 @@
#include "balloon_manager.h" // Para BalloonManager
#include "bullet.h" // Para Bullet, BulletType, BulletMoveStatus
#include "color.h" // Para Color, FLASH_COLOR
#include "difficulty.h" // Para Code
#include "fade.h" // Para Fade, FadeType, FadeMode
#include "global_events.h" // Para check
#include "global_inputs.h" // Para check

View File

@@ -1,15 +1,14 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_Event, SDL_Renderer, SDL_Texture, Uint64
#include <SDL3/SDL.h> // Para SDL_Event, SDL_Renderer, SDL_Texture, Uint64, Uint8
#include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para string
#include <vector> // Para vector
#include "difficulty.h" // Para Difficulty
#include "item.h" // Para Item, ItemType
#include "manage_hiscore_table.h" // Para HiScoreEntry
#include "options.h" // Para SettingsOptions, settings, DifficultyCode (ptr only)
#include "options.h" // Para SettingsOptions, settings
#include "path_sprite.h" // Para PathSprite, Path
#include "player.h" // Para Player
#include "smart_sprite.h" // Para SmartSprite
@@ -26,6 +25,9 @@ class Screen;
class Tabe;
class Texture;
enum class BulletType : Uint8;
namespace Difficulty {
enum class Code;
} // namespace Difficulty
// Modo demo
constexpr bool GAME_MODE_DEMO_OFF = false;
@@ -37,13 +39,11 @@ constexpr int TOTAL_SCORE_DATA = 3;
// Clase Game
class Game {
public:
// Constructor
// --- Constructor y destructor ---
Game(int player_id, int current_stage, bool demo);
// Destructor
~Game();
// Bucle principal del juego
// --- Bucle principal ---
void run();
private:
@@ -129,13 +129,13 @@ class Game {
Options::settings.hi_score_table[0].name,
Options::settings.hi_score_table[0].score); // Máxima puntuación y nombre de quien la ostenta
Demo demo_; // Variable con todas las variables relacionadas con el modo demo
Demo demo_; // Variable con todas las variables relacionadas con el modo demo
Difficulty::Code difficulty_ = Options::settings.difficulty; // Dificultad del juego
Helper helper_; // Variable para gestionar las ayudas
Uint64 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa
bool coffee_machine_enabled_ = false; // Indica si hay una máquina de café en el terreno de juego
bool hi_score_achieved_ = false; // Indica si se ha superado la puntuación máxima
bool paused_ = false; // Indica si el juego está pausado (no se deberia de poder utilizar en el modo arcade)
Helper helper_; // Variable para gestionar las ayudas
Uint64 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa
bool coffee_machine_enabled_ = false; // Indica si hay una máquina de café en el terreno de juego
bool hi_score_achieved_ = false; // Indica si se ha superado la puntuación máxima
bool paused_ = false; // Indica si el juego está pausado (no se deberia de poder utilizar en el modo arcade)
// bool paused_by_service_menu_ = false;
float difficulty_score_multiplier_; // Multiplicador de puntos en función de la dificultad
int counter_ = 0; // Contador para el juego

View File

@@ -1,6 +1,7 @@
#include "hiscore_table.h"
#include <SDL3/SDL.h> // Para SDL_GetTicks, SDL_SetRenderTarget
#include <algorithm> // Para max
#include <cstdlib> // Para rand, size_t
#include <functional> // Para function

View File

@@ -1,9 +1,10 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint16, SDL_FRect, SDL_Renderer, SDL_Texture, Uint64, Uint8
#include <memory> // Para unique_ptr, shared_ptr
#include <string> // Para string
#include <vector> // Para vector
#include <SDL3/SDL.h> // Para Uint16, SDL_FRect, SDL_Renderer, SDL_Texture, Uint64, Uint8
#include <memory> // Para unique_ptr, shared_ptr
#include <string> // Para string
#include <vector> // Para vector
#include "color.h" // Para Color
#include "path_sprite.h" // Para Path, PathSprite (ptr only)
@@ -26,13 +27,11 @@ enum class FadeMode : Uint8;
// Clase HiScoreTable
class HiScoreTable {
public:
// Constructor
// --- Constructor y destructor ---
HiScoreTable();
// Destructor
~HiScoreTable();
// Bucle principal
// --- Bucle principal ---
void run();
private:

View File

@@ -1,6 +1,7 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_Texture, Uint32, SDL_Renderer, SDL_FPoint, SDL_FRect, Uint64
#include <memory> // Para unique_ptr, shared_ptr
#include <vector> // Para vector
@@ -39,13 +40,11 @@ struct Line {
// Clase Instructions
class Instructions {
public:
// Constructor
// --- Constructor y destructor ---
Instructions();
// Destructor
~Instructions();
// Bucle principal
// --- Bucle principal ---
void run();
private:

View File

@@ -20,13 +20,11 @@
// Clase Intro
class Intro {
public:
// Constructor
// --- Constructor y destructor ---
Intro();
// Destructor
~Intro() = default;
// Bucle principal
// --- Bucle principal ---
void run();
private:
@@ -72,8 +70,8 @@ class Intro {
void updatePostState(); // Actualiza el estado POST
#ifdef _DEBUG
static void adjustColorComponent(uint8_t& component, bool increase);
void adjustAllColorComponents(Color& color, bool increase);
void handleDebugColorKeys(SDL_Keycode key, Color& color);
static void adjustAllColorComponents(Color& color, bool increase);
static void handleDebugColorKeys(SDL_Keycode key, Color& color);
static void printColorDebugInfo(const Color& color);
#endif

View File

@@ -1,6 +1,7 @@
#include "logo.h"
#include <SDL3/SDL.h> // Para SDL_GetTicks, SDL_PollEvent, SDL_Event, SDL_FRect
#include <algorithm> // Para max
#include <utility> // Para move

View File

@@ -1,11 +1,12 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_FPoint, Uint64
#include <memory> // Para unique_ptr, shared_ptr
#include <vector> // Para vector
#include "color.h" // Para Color
#include "sprite.h" // Para Sprite
#include <memory> // Para unique_ptr, shared_ptr
#include <vector> // Para vector
#include "color.h" // Para Color
#include "sprite.h" // Para Sprite
class Texture;
@@ -20,13 +21,11 @@ class Texture;
// --- Clase Logo ---
class Logo {
public:
// Constructor
// --- Constructor y destructor ---
Logo();
// Destructor
~Logo();
// Bucle principal
// --- Bucle principal ---
void run();
private:

View File

@@ -118,13 +118,13 @@ void Title::checkEvents() {
}
void Title::handleKeyDownEvent(const SDL_Event& event) {
bool isFirstPress = static_cast<int>(event.key.repeat) == 0;
if (isFirstPress) {
bool is_first_press = static_cast<int>(event.key.repeat) == 0;
if (is_first_press) {
handleControlKeys(event.key.key);
}
#ifdef _DEBUG
bool isRepeat = static_cast<int>(event.key.repeat) == 1;
if (isRepeat) {
bool is_repeat = static_cast<int>(event.key.repeat) == 1;
if (is_repeat) {
handleDebugColorKeys(event.key.key);
}
#endif
@@ -143,15 +143,32 @@ void Title::handleDebugColorKeys(SDL_Keycode key) {
void Title::adjustColorComponent(SDL_Keycode key, Color& color) {
switch (key) {
case SDLK_A: incrementColorComponent(color.r); break;
case SDLK_Z: decrementColorComponent(color.r); break;
case SDLK_S: incrementColorComponent(color.g); break;
case SDLK_X: decrementColorComponent(color.g); break;
case SDLK_D: incrementColorComponent(color.b); break;
case SDLK_C: decrementColorComponent(color.b); break;
case SDLK_F: incrementAllComponents(color); break;
case SDLK_V: decrementAllComponents(color); break;
default: break;
case SDLK_A:
incrementColorComponent(color.r);
break;
case SDLK_Z:
decrementColorComponent(color.r);
break;
case SDLK_S:
incrementColorComponent(color.g);
break;
case SDLK_X:
decrementColorComponent(color.g);
break;
case SDLK_D:
incrementColorComponent(color.b);
break;
case SDLK_C:
decrementColorComponent(color.b);
break;
case SDLK_F:
incrementAllComponents(color);
break;
case SDLK_V:
decrementAllComponents(color);
break;
default:
break;
}
}
@@ -235,28 +252,27 @@ void Title::checkInput() {
GlobalInputs::check();
}
bool Title::shouldSkipInputCheck() const {
auto Title::shouldSkipInputCheck() const -> bool {
return define_buttons_->isEnabled();
}
void Title::processControllerInputs() {
for (const auto &controller : Options::controllers) {
for (const auto& controller : Options::controllers) {
if (isStartButtonPressed(controller)) {
handleStartButtonPress(controller);
}
}
}
bool Title::isStartButtonPressed(const Options::GamepadOptions &controller) const {
auto Title::isStartButtonPressed(const Options::GamepadOptions& controller) -> bool {
return Input::get()->checkInput(
InputAction::START,
INPUT_DO_NOT_ALLOW_REPEAT,
controller.type,
controller.index
);
controller.index);
}
void Title::handleStartButtonPress(const Options::GamepadOptions &controller) {
void Title::handleStartButtonPress(const Options::GamepadOptions& controller) {
if (!canProcessStartButton()) {
return;
}
@@ -268,7 +284,7 @@ void Title::handleStartButtonPress(const Options::GamepadOptions &controller) {
}
}
bool Title::canProcessStartButton() const {
auto Title::canProcessStartButton() const -> bool {
return (state_ != TitleState::LOGO_ANIMATING || ALLOW_TITLE_ANIMATION_SKIP);
}
@@ -546,21 +562,21 @@ void Title::initPlayers() {
// Actualza los jugadores
void Title::updatePlayers() {
for (auto &player : players_) {
for (auto& player : players_) {
player->update();
}
}
// Renderiza los jugadores
void Title::renderPlayers() {
for (auto const &player : players_) {
for (auto const& player : players_) {
player->render();
}
}
// Obtiene un jugador a partir de su "id"
auto Title::getPlayer(int id) -> std::shared_ptr<Player> {
auto it = std::find_if(players_.begin(), players_.end(), [id](const auto &player) { return player->getId() == id; });
auto it = std::find_if(players_.begin(), players_.end(), [id](const auto& player) { return player->getId() == id; });
if (it != players_.end()) {
return *it;

View File

@@ -1,14 +1,13 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint32
#include <SDL3/SDL.h> // Para SDL_Keycode, SDL_Event, Uint64
#include <stdint.h> // Para uint8_t
#include <memory> // Para unique_ptr, shared_ptr
#include <string_view>
#include <vector>
#include <memory> // Para unique_ptr, shared_ptr
#include <string_view> // Para string_view
#include <vector> // Para vector
#include "color.h" // Para Color
#include "options.h" // Para Options
#include "section.hpp" // Para Options
#include "section.hpp" // Para Options, Name (ptr only)
class DefineButtons;
class Fade;
@@ -17,6 +16,10 @@ class Player;
class Sprite;
class Text;
class TiledBG;
namespace Options {
struct GamepadOptions;
} // namespace Options
struct Color;
// Textos
constexpr std::string_view TEXT_COPYRIGHT = "@2020,2025 JailDesigner";
@@ -33,12 +36,12 @@ constexpr bool ALLOW_TITLE_ANIMATION_SKIP = false;
// Clase Title
class Title {
public:
// --- Constructores y destructor ---
// --- Constructor y destructor ---
Title();
~Title();
// --- Método principal ---
void run(); // Bucle para el título del juego
// --- Bucle principal ---
void run();
private:
// --- Enumeraciones ---
@@ -84,18 +87,18 @@ class Title {
void resetCounter(); // Reinicia el contador interno
// --- Entrada de usuario ---
void checkEvents(); // Comprueba los eventos
void checkInput(); // Comprueba las entradas
void handleKeyDownEvent(const SDL_Event& event); // Maneja el evento de tecla presionada
void handleControlKeys(SDL_Keycode key); // Maneja las teclas de control específicas
bool shouldSkipInputCheck() const; // Determina si se debe omitir la comprobación de entrada
void processControllerInputs(); // Procesa las entradas de los mandos
bool isStartButtonPressed(const Options::GamepadOptions& controller) const; // Comprueba si se ha pulsado el botón Start
void handleStartButtonPress(const Options::GamepadOptions& controller); // Maneja la pulsación del botón Start
bool canProcessStartButton() const; // Verifica si se puede procesar la pulsación del botón Start
void processPlayer1Start(); // Procesa el inicio del jugador 1
void processPlayer2Start(); // Procesa el inicio del jugador 2
void activatePlayerAndSetState(int player_id); // Activa al jugador y cambia el estado del título
void checkEvents(); // Comprueba los eventos
void checkInput(); // Comprueba las entradas
void handleKeyDownEvent(const SDL_Event& event); // Maneja el evento de tecla presionada
void handleControlKeys(SDL_Keycode key); // Maneja las teclas de control específicas
[[nodiscard]] auto shouldSkipInputCheck() const -> bool; // Determina si se debe omitir la comprobación de entrada
void processControllerInputs(); // Procesa las entradas de los mandos
[[nodiscard]] static auto isStartButtonPressed(const Options::GamepadOptions& controller) -> bool; // Comprueba si se ha pulsado el botón Start
void handleStartButtonPress(const Options::GamepadOptions& controller); // Maneja la pulsación del botón Start
[[nodiscard]] auto canProcessStartButton() const -> bool; // Verifica si se puede procesar la pulsación del botón Start
void processPlayer1Start(); // Procesa el inicio del jugador 1
void processPlayer2Start(); // Procesa el inicio del jugador 2
void activatePlayerAndSetState(int player_id); // Activa al jugador y cambia el estado del título
// --- Gestión de jugadores ---
void initPlayers(); // Inicializa los jugadores
@@ -117,12 +120,12 @@ class Title {
// --- Depuración (solo en modo DEBUG) ---
#ifdef _DEBUG
void handleDebugColorKeys(SDL_Keycode key); // Maneja las teclas de depuración para colores
void adjustColorComponent(SDL_Keycode key, Color& color); // Ajusta un componente del color según la tecla
void incrementColorComponent(uint8_t& component); // Incrementa un componente de color
void decrementColorComponent(uint8_t& component); // Decrementa un componente de color
void incrementAllComponents(Color& color); // Incrementa todos los componentes del color
void decrementAllComponents(Color& color); // Decrementa todos los componentes del color
void printColorValue(const Color& color); // Imprime el valor actual del color en consola
void handleDebugColorKeys(SDL_Keycode key); // Maneja las teclas de depuración para colores
static void adjustColorComponent(SDL_Keycode key, Color& color); // Ajusta un componente del color según la tecla
static void incrementColorComponent(uint8_t& component); // Incrementa un componente de color
static void decrementColorComponent(uint8_t& component); // Decrementa un componente de color
static void incrementAllComponents(Color& color); // Incrementa todos los componentes del color
static void decrementAllComponents(Color& color); // Decrementa todos los componentes del color
static void printColorValue(const Color& color); // Imprime el valor actual del color en consola
#endif
};

View File

@@ -1,6 +1,7 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_FRect, SDL_FPoint
#include <memory> // Para shared_ptr
class Texture;

View File

@@ -2,9 +2,10 @@
#include "tabe.h"
#include <SDL3/SDL.h> // Para SDL_FlipMode, SDL_GetTicks
#include <algorithm> // Para max
#include <array> // Para array
#include <cstdlib> // Para rand, abs
#include <algorithm> // Para max
#include <array> // Para array
#include <cstdlib> // Para rand, abs
#include "audio.h" // Para Audio
#include "param.h" // Para Param, ParamGame, param

View File

@@ -1,6 +1,7 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint32, SDL_GetTicks, SDL_FRect
#include <cstdlib> // Para rand
#include <memory> // Para unique_ptr

View File

@@ -1,6 +1,7 @@
#include "text.h"
#include <SDL3/SDL.h> // Para SDL_SetRenderTarget, SDL_GetRenderTarget, Uint8
#include <cstddef> // Para size_t
#include <fstream> // Para basic_ifstream, basic_istream, basic_ostream
#include <iostream> // Para cerr
@@ -232,11 +233,10 @@ void Text::writeDX(Uint8 flags, int x, int y, const std::string &text, int kerni
}
// Escribe texto a partir de un TextStyle
void Text::writeDX(Uint8 flags, int x, int y, const std::string& text, const TextStyle& style, int length) {
void Text::writeDX(Uint8 flags, int x, int y, const std::string &text, const TextStyle &style, int length) {
writeDX(flags, x, y, text, style.kerning, style.text_color, style.shadow_distance, style.shadow_color);
}
// Obtiene la longitud en pixels de una cadena
auto Text::lenght(const std::string &text, int kerning) const -> int {
int shift = 0;

View File

@@ -1,12 +1,13 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint8
#include <array> // Para array
#include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para string
#include "color.h" // Para Color
#include "sprite.h" // Para Sprite
#include <array> // Para array
#include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para string
#include "color.h" // Para Color
#include "sprite.h" // Para Sprite
class Texture;

View File

@@ -2,6 +2,7 @@
#include "texture.h"
#include <SDL3/SDL.h> // Para SDL_LogError, SDL_LogCategory, Uint8, SDL_...
#include <cstdint> // Para uint32_t
#include <cstring> // Para memcpy
#include <fstream> // Para basic_ifstream, basic_istream, basic_ios

View File

@@ -1,6 +1,7 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint8, SDL_Renderer, Uint16, SDL_FlipMode, SDL_PixelFormat, SDL_TextureAccess, SDL_Texture, Uint32, SDL_BlendMode, SDL_FPoint, SDL_FRect
#include <array> // Para array
#include <cstddef> // Para size_t
#include <memory> // Para shared_ptr

View File

@@ -1,6 +1,7 @@
#include "tiled_bg.h"
#include <SDL3/SDL.h> // Para SDL_SetRenderTarget, SDL_CreateTexture, SDL_DestroyTexture, SDL_FRect, SDL_GetRenderTarget, SDL_RenderTexture, SDL_PixelFormat, SDL_TextureAccess
#include <cmath> // Para sin
#include <cstdlib> // Para rand
#include <memory> // Para allocator, unique_ptr, make_unique

View File

@@ -1,9 +1,10 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_FRect, SDL_SetTextureColorMod, SDL_Renderer, SDL_Texture
#include <array> // Para array
#include "color.h" // Para Color
#include <array> // Para array
#include "color.h" // Para Color
// Modos de funcionamiento para el tileado de fondo
enum class TiledBGMode : int {

View File

@@ -1,7 +1,7 @@
#include "menu_renderer.h"
#include <algorithm> // Para max
#include <utility> // Para pair, move
#include <algorithm> // Para max
#include <utility> // Para pair, move
#include "color.h" // Para Color, generateMirroredCycle, ColorCycleStyle
#include "menu_option.h" // Para MenuOption

View File

@@ -1,10 +1,11 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_FRect, Uint32
#include <array> // Para array
#include <cstddef> // Para size_t
#include <memory> // Para shared_ptr, unique_ptr
#include <vector> // Para vector
#include <SDL3/SDL.h> // Para SDL_FRect, Uint32
#include <array> // Para array
#include <cstddef> // Para size_t
#include <memory> // Para shared_ptr, unique_ptr
#include <vector> // Para vector
#include "color.h" // Para Color
#include "ui/service_menu.h" // Para ServiceMenu

View File

@@ -1,6 +1,7 @@
#include "notifier.h"
#include <SDL3/SDL.h> // Para SDL_RenderFillRect, SDL_FRect, SDL_RenderClear
#include <algorithm> // Para remove_if
#include <string> // Para basic_string, string
#include <utility>

View File

@@ -1,6 +1,7 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_FRect, SDL_Renderer
#include <memory> // Para shared_ptr
#include <string> // Para basic_string, string
#include <vector> // Para vector

View File

@@ -3,7 +3,7 @@
#include <algorithm> // Para max
#include "audio.h" // Para Audio
#include "difficulty.h" // Para Difficulty
#include "difficulty.h" // Para Difficulty
#include "lang.h" // Para getText, getCodeFromName, getNameFromCode
#include "menu_option.h" // Para MenuOption, BoolOption, ActionOption, IntOption, FolderOption, ListOption
#include "menu_renderer.h" // Para MenuRenderer

View File

@@ -1,7 +1,7 @@
#pragma once
#include <memory> // Para shared_ptr
#include <string> // Para string
#include <memory> // Para shared_ptr
#include <string> // Para string
#include "color.h" // Para Color

View File

@@ -2,6 +2,7 @@
#include "utils.h"
#include <SDL3/SDL.h> // Para SDL_RenderPoint, SDL_FRect, SDL_CloseIO, SDL_IOFromFile, SDL_LogCategory, SDL_LogError, SDL_LogInfo, SDL_ReadIO, SDL_FPoint, SDL_Renderer
#include <algorithm> // Para clamp, find_if_not, find, transform
#include <cctype> // Para tolower, isspace
#include <cmath> // Para pow, sin, M_PI, cos
@@ -11,7 +12,7 @@
#include <stdexcept> // Para runtime_error
#include <string> // Para basic_string, allocator, string, operator==, operator+, char_traits
#include "lang.h" // Para getText
#include "lang.h" // Para getText
// Variables
Overrides overrides = Overrides();

View File

@@ -2,9 +2,10 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint8, SDL_FRect, SDL_FPoint, SDL_Renderer
#include <cstdint> // Para int32_t
#include <string> // Para string
#include <vector> // Para vector
#include <cstdint> // Para int32_t
#include <string> // Para string
#include <vector> // Para vector
// --- Constantes ---
constexpr int BLOCK = 8;