From 8b7b667c608007e181cf6710ca33db5385fa7269 Mon Sep 17 00:00:00 2001 From: Sergio Date: Mon, 21 Jul 2025 14:43:35 +0200 Subject: [PATCH] creat color.h i color.cpp i llevat de utils.h i utils.cpp --- CMakeLists.txt | 35 +++--- source/animated_sprite.cpp | 19 ++-- source/animated_sprite.h | 1 - source/asset.cpp | 3 +- source/audio.cpp | 1 - source/background.cpp | 1 - source/background.h | 11 +- source/balloon.h | 11 +- source/balloon_manager.cpp | 3 +- source/balloon_manager.h | 13 +-- source/bullet.h | 7 +- source/color.cpp | 181 ++++++++++++++++++++++++++++++ source/color.h | 116 +++++++++++++++++++ source/define_buttons.h | 1 - source/director.cpp | 35 +++--- source/enter_name.cpp | 2 +- source/enter_name.h | 2 +- source/fade.cpp | 13 +-- source/fade.h | 1 - source/game_logo.cpp | 7 +- source/global_inputs.cpp | 12 +- source/input.cpp | 1 - source/input.h | 1 - source/item.h | 9 +- source/manage_hiscore_table.cpp | 9 +- source/moving_sprite.h | 1 - source/options.cpp | 19 ++-- source/options.h | 1 - source/param.cpp | 4 +- source/param.h | 4 +- source/path_sprite.h | 1 - source/player.cpp | 1 - source/player.h | 9 +- source/resource.cpp | 18 +-- source/resource.h | 13 +-- source/scoreboard.cpp | 2 +- source/scoreboard.h | 13 +-- source/screen.cpp | 16 +-- source/screen.h | 9 +- source/sections/credits.cpp | 4 +- source/sections/credits.h | 4 +- source/sections/game.cpp | 28 ++--- source/sections/game.h | 14 +-- source/sections/hiscore_table.cpp | 4 +- source/sections/hiscore_table.h | 11 +- source/sections/instructions.cpp | 4 +- source/sections/instructions.h | 1 - source/sections/intro.cpp | 8 +- source/sections/intro.h | 10 +- source/sections/logo.cpp | 4 +- source/sections/logo.h | 9 +- source/sections/title.cpp | 4 +- source/sections/title.h | 1 - source/sprite.h | 1 - source/tabe.cpp | 7 +- source/tabe.h | 1 - source/text.cpp | 1 - source/text.h | 12 +- source/texture.cpp | 4 +- source/texture.h | 1 - source/tiled_bg.cpp | 1 - source/tiled_bg.h | 5 +- source/ui/menu_renderer.cpp | 6 +- source/ui/menu_renderer.h | 13 +-- source/ui/notifier.cpp | 1 - source/ui/notifier.h | 4 +- source/ui/service_menu.cpp | 2 +- source/ui/ui_message.h | 6 +- source/utils.cpp | 173 ++-------------------------- source/utils.h | 149 +----------------------- 70 files changed, 529 insertions(+), 570 deletions(-) create mode 100644 source/color.cpp create mode 100644 source/color.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c6d9bc..323398d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,24 +18,24 @@ set(OpenGL_GL_PREFERENCE GLVND) # --- 1. LISTA EXPLÍCITA DE FUENTES --- set(APP_SOURCES # --- Archivos Principales del Sistema --- - source/main.cpp - source/director.cpp - source/screen.cpp - source/resource.cpp source/asset.cpp source/audio.cpp - source/input.cpp - source/options.cpp - source/lang.cpp - source/param.cpp - source/utils.cpp + source/director.cpp source/global_events.cpp source/global_inputs.cpp + source/input.cpp + source/lang.cpp + source/main.cpp + source/param.cpp + source/resource.cpp + source/screen.cpp + source/text.cpp + source/writer.cpp # --- UI (User Interface) --- - source/ui/service_menu.cpp source/ui/menu_renderer.cpp source/ui/notifier.cpp + source/ui/service_menu.cpp source/ui/ui_message.cpp # --- Lógica del Juego --- @@ -50,6 +50,7 @@ set(APP_SOURCES source/manage_hiscore_table.cpp source/player.cpp source/scoreboard.cpp + source/tabe.cpp # --- Escenas --- source/sections/credits.cpp @@ -61,23 +62,23 @@ set(APP_SOURCES source/sections/title.cpp # --- Sprites y Gráficos --- - source/sprite.cpp source/animated_sprite.cpp + source/background.cpp + source/fade.cpp source/moving_sprite.cpp source/path_sprite.cpp source/smart_sprite.cpp - source/background.cpp - source/tiled_bg.cpp - source/fade.cpp + source/sprite.cpp source/texture.cpp + source/tiled_bg.cpp # --- Otros --- + source/color.cpp source/define_buttons.cpp source/mouse.cpp + source/options.cpp source/stage.cpp - source/tabe.cpp - source/text.cpp - source/writer.cpp + source/utils.cpp ) # Fuentes de librerías de terceros diff --git a/source/animated_sprite.cpp b/source/animated_sprite.cpp index 0fdb88d..e8c54c1 100644 --- a/source/animated_sprite.cpp +++ b/source/animated_sprite.cpp @@ -1,16 +1,15 @@ #include "animated_sprite.h" -#include // Para SDL_LogWarn, SDL_LogCategory, SDL_LogError +#include // Para SDL_LogWarn, SDL_LogCategory, SDL_LogError, SDL_FRect +#include // Para min, max +#include // Para size_t +#include // Para basic_istream, basic_ifstream, basic_ios, ifstream, stringstream +#include // Para basic_stringstream +#include // Para runtime_error +#include // Para pair -#include // Para min -#include // Para size_t -#include // Para basic_istream, basic_ifstream, basic_ios, ifst... -#include // Para basic_stringstream -#include // Para runtime_error -#include // Para pair - -#include "texture.h" // Para Texture -#include "utils.h" // Para printWithDots +#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 { diff --git a/source/animated_sprite.h b/source/animated_sprite.h index 1a4fa4c..4257c1f 100644 --- a/source/animated_sprite.h +++ b/source/animated_sprite.h @@ -1,7 +1,6 @@ #pragma once #include // Para SDL_FRect - #include // Para max #include // Para size_t #include // Para allocator, shared_ptr diff --git a/source/asset.cpp b/source/asset.cpp index 4cb274e..529c6b2 100644 --- a/source/asset.cpp +++ b/source/asset.cpp @@ -1,14 +1,13 @@ #include "asset.h" #include // Para SDL_LogInfo, SDL_LogCategory, SDL_LogError, SDL_LogWarn - #include // Para max #include // Para basic_ifstream, ifstream #include // Para identity #include // Para __find_if_fn, find_if #include // Para allocator, string, operator==, operator+, char_traits, basic_string -#include "utils.h" // Para getFileName +#include "utils.h" // Para getFileName // Singleton Asset *Asset::instance = nullptr; diff --git a/source/audio.cpp b/source/audio.cpp index 0cad257..9ef8ce8 100644 --- a/source/audio.cpp +++ b/source/audio.cpp @@ -1,7 +1,6 @@ #include "audio.h" #include // Para SDL_LogInfo, SDL_LogCategory, SDL_G... - #include // Para clamp #include "external/jail_audio.h" // Para JA_FadeOutMusic, JA_Init, JA_PauseM... diff --git a/source/background.cpp b/source/background.cpp index 4dc0f23..b1b00e2 100644 --- a/source/background.cpp +++ b/source/background.cpp @@ -2,7 +2,6 @@ #include "background.h" #include // 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 // Para clamp, max #include // Para M_PI, cos, sin diff --git a/source/background.h b/source/background.h index 24d1720..1d17c28 100644 --- a/source/background.h +++ b/source/background.h @@ -1,13 +1,12 @@ #pragma once #include // Para SDL_FRect, SDL_FPoint, SDL_Texture, SDL_Renderer +#include // Para array +#include // Para size_t +#include // Para unique_ptr, shared_ptr +#include // Para vector -#include -#include // Para size_t -#include // Para unique_ptr, shared_ptr -#include // Para vector - -#include "utils.h" // Para Color +#include "color.h" // Para Color class MovingSprite; class Sprite; diff --git a/source/balloon.h b/source/balloon.h index bcbb834..8a1777f 100644 --- a/source/balloon.h +++ b/source/balloon.h @@ -1,11 +1,10 @@ #pragma once -#include // Para Uint8, Uint16, SDL_FRect, Uint32 - -#include -#include // Para shared_ptr, unique_ptr -#include // Para basic_string, string -#include // Para vector +#include // Para Uint8, Uint16, SDL_FRect, Uint32 +#include // Para array +#include // Para allocator, shared_ptr, unique_ptr +#include // Para basic_string, string +#include // Para vector #include "animated_sprite.h" // Para AnimatedSprite #include "utils.h" // Para Circle diff --git a/source/balloon_manager.cpp b/source/balloon_manager.cpp index 876303f..2280e63 100644 --- a/source/balloon_manager.cpp +++ b/source/balloon_manager.cpp @@ -7,12 +7,13 @@ #include "balloon.h" // Para Balloon, BALLOON_SCORE, BALLOON_VELX... #include "balloon_formations.h" // Para BalloonFormationParams, BalloonForma... +#include "color.h" // Para Zone, Color, flash_color #include "explosions.h" // Para Explosions #include "param.h" // Para Param, ParamGame, param #include "resource.h" // Para Resource #include "screen.h" // Para Screen #include "stage.h" // Para addPower -#include "utils.h" // Para Zone, Color, flash_color +#include "utils.h" // Constructor BalloonManager::BalloonManager() diff --git a/source/balloon_manager.h b/source/balloon_manager.h index 5022b3e..7fe1454 100644 --- a/source/balloon_manager.h +++ b/source/balloon_manager.h @@ -1,12 +1,11 @@ #pragma once -#include // Para SDL_FRect - -#include // Para max -#include // Para array -#include // Para shared_ptr, unique_ptr -#include // Para string -#include // Para vector +#include // Para SDL_FRect +#include // Para max +#include // Para array +#include // Para shared_ptr, unique_ptr +#include // Para string +#include // Para vector #include "balloon.h" // Para BALLOON_SPEED, Balloon, BalloonSize (ptr only), BalloonType (ptr only) #include "balloon_formations.h" // Para BalloonFormations diff --git a/source/bullet.h b/source/bullet.h index 988ab84..92e7ec2 100644 --- a/source/bullet.h +++ b/source/bullet.h @@ -1,9 +1,8 @@ #pragma once -#include // Para Uint8 - -#include // Para unique_ptr -#include // Para string +#include // Para Uint8 +#include // Para unique_ptr +#include // Para string #include "animated_sprite.h" // Para AnimatedSprite #include "utils.h" // Para Circle diff --git a/source/color.cpp b/source/color.cpp new file mode 100644 index 0000000..d1b0b77 --- /dev/null +++ b/source/color.cpp @@ -0,0 +1,181 @@ +#define _USE_MATH_DEFINES +#include "color.h" + +#include // Para min, clamp +#include // Para fmaxf, fminf, M_PI, fmodf, roundf, sin, abs +#include // Para invalid_argument +#include // Para basic_string, string + +// Método estático para crear Color desde string hexadecimal +auto Color::fromHex(const std::string &hex_str) -> Color { + std::string hex = hex_str; + + // Quitar '#' si existe + if (!hex.empty() && hex[0] == '#') { + hex = hex.substr(1); + } + + // Verificar longitud válida (6 para RGB o 8 para RGBA) + if (hex.length() != HEX_RGB_LENGTH && hex.length() != HEX_RGBA_LENGTH) { + throw std::invalid_argument("String hexadecimal debe tener 6 o 8 caracteres"); + } + + // Verificar que todos los caracteres sean hexadecimales válidos + for (char c : hex) { + if (std::isxdigit(c) == 0) { + throw std::invalid_argument("String contiene caracteres no hexadecimales"); + } + } + + // Convertir cada par de caracteres a valores RGB(A) + Uint8 r = static_cast(std::stoi(hex.substr(0, HEX_COMPONENT_LENGTH), nullptr, HEX_BASE)); + Uint8 g = static_cast(std::stoi(hex.substr(HEX_COMPONENT_LENGTH, HEX_COMPONENT_LENGTH), nullptr, HEX_BASE)); + Uint8 b = static_cast(std::stoi(hex.substr(HEX_COMPONENT_LENGTH * 2, HEX_COMPONENT_LENGTH), nullptr, HEX_BASE)); + Uint8 a = DEFAULT_ALPHA; // Alpha por defecto + + // Si tiene 8 caracteres, extraer el alpha + if (hex.length() == HEX_RGBA_LENGTH) { + a = static_cast(std::stoi(hex.substr(HEX_COMPONENT_LENGTH * 3, HEX_COMPONENT_LENGTH), nullptr, HEX_BASE)); + } + + return Color(r, g, b, a); +} + +// Obtiene un color del vector de colores imitando al Coche Fantástico +auto getColorLikeKnightRider(const std::vector &colors, int counter) -> Color { + int cycle_length = colors.size() * 2 - 2; + size_t n = counter % cycle_length; + + size_t index; + if (n < colors.size()) { + index = n; // Avanza: 0,1,2,3 + } else { + index = 2 * (colors.size() - 1) - n; // Retrocede: 2,1 + } + + return colors[index]; +} + +constexpr auto rgbToHsv(Color color) -> HSV { + float r = color.r / 255.0F; + float g = color.g / 255.0F; + float b = color.b / 255.0F; + + float max = fmaxf(fmaxf(r, g), b); + float min = fminf(fminf(r, g), b); + float delta = max - min; + + float h = 0.0F; + if (delta > 0.00001F) { + if (max == r) { + h = fmodf((g - b) / delta, 6.0F); + } else if (max == g) { + h = ((b - r) / delta) + 2.0F; + } else { + h = ((r - g) / delta) + 4.0F; + } + h *= 60.0F; + if (h < 0.0F) { + h += 360.0F; + } + } + + float s = (max <= 0.0F) ? 0.0F : delta / max; + float v = max; + + return {h, s, v}; +} + +constexpr auto hsvToRgb(HSV hsv) -> Color { + float c = hsv.v * hsv.s; + float x = c * (1 - std::abs(std::fmod(hsv.h / 60.0F, 2) - 1)); + float m = hsv.v - c; + + float r = 0; + float g = 0; + float b = 0; + + if (hsv.h < 60) { + r = c; + g = x; + b = 0; + } else if (hsv.h < 120) { + r = x; + g = c; + b = 0; + } else if (hsv.h < 180) { + r = 0; + g = c; + b = x; + } else if (hsv.h < 240) { + r = 0; + g = x; + b = c; + } else if (hsv.h < 300) { + r = x; + g = 0; + b = c; + } else { + r = c; + g = 0; + b = x; + } + + return Color( + static_cast(roundf((r + m) * 255)), + static_cast(roundf((g + m) * 255)), + static_cast(roundf((b + m) * 255))); +} + +auto generateMirroredCycle(Color base, ColorCycleStyle style) -> ColorCycle { + ColorCycle result{}; + HSV base_hsv = rgbToHsv(base); + + for (size_t i = 0; i < COLOR_CYCLE_SIZE; ++i) { + float t = static_cast(i) / (COLOR_CYCLE_SIZE - 1); // 0 → 1 + float hue_shift = 0.0F; + float sat_shift = 0.0F; + float val_shift = 0.0F; + + switch (style) { + case ColorCycleStyle::SUBTLE_PULSE: + // Solo brillo suave + val_shift = 0.07F * sinf(t * M_PI); + break; + + case ColorCycleStyle::HUE_WAVE: + // Oscilación leve de tono + hue_shift = 15.0F * (t - 0.5F) * 2.0F; + val_shift = 0.05F * sinf(t * M_PI); + break; + + case ColorCycleStyle::VIBRANT: + // Cambios fuertes en tono y brillo + hue_shift = 35.0F * sinf(t * M_PI); + val_shift = 0.2F * sinf(t * M_PI); + sat_shift = -0.2F * sinf(t * M_PI); + break; + + case ColorCycleStyle::DARKEN_GLOW: + // Se oscurece al centro + val_shift = -0.15F * sinf(t * M_PI); + break; + + case ColorCycleStyle::LIGHT_FLASH: + // Se ilumina al centro + val_shift = 0.25F * sinf(t * M_PI); + break; + } + + HSV adjusted = { + fmodf(base_hsv.h + hue_shift + 360.0F, 360.0F), + fminf(1.0F, fmaxf(0.0F, base_hsv.s + sat_shift)), + fminf(1.0F, fmaxf(0.0F, base_hsv.v + val_shift))}; + + Color c = hsvToRgb(adjusted); + result[i] = c; + result[2 * COLOR_CYCLE_SIZE - 1 - i] = c; // espejo + } + + return result; +} \ No newline at end of file diff --git a/source/color.h b/source/color.h new file mode 100644 index 0000000..eea6974 --- /dev/null +++ b/source/color.h @@ -0,0 +1,116 @@ +#pragma once + +#include // Para Uint8 + +#include // Para max, min +#include // Para array +#include // Para isxdigit +#include // Para abs +#include // Para invalid_argument +#include // Para string, basic_string, stoi +#include // Para vector + +// --- Constantes --- +constexpr size_t COLOR_CYCLE_SIZE = 6; // Mitad del ciclo espejado + +// --- Estructuras y tipos --- + +// Estructura para definir un color RGBA +struct Color { + private: + static constexpr Uint8 MAX_COLOR_VALUE = 255; + static constexpr Uint8 MIN_COLOR_VALUE = 0; + static constexpr Uint8 DEFAULT_ALPHA = 255; + static constexpr int DEFAULT_LIGHTEN_AMOUNT = 50; + static constexpr int DEFAULT_DARKEN_AMOUNT = 50; + static constexpr int DEFAULT_APPROACH_STEP = 1; + static constexpr size_t HEX_RGB_LENGTH = 6; + static constexpr size_t HEX_RGBA_LENGTH = 8; + static constexpr int HEX_BASE = 16; + static constexpr size_t HEX_COMPONENT_LENGTH = 2; + + public: + Uint8 r, g, b, a; + + constexpr Color() : r(MIN_COLOR_VALUE), g(MIN_COLOR_VALUE), b(MIN_COLOR_VALUE), a(DEFAULT_ALPHA) {} + + explicit constexpr Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha = DEFAULT_ALPHA) + : r(red), g(green), b(blue), a(alpha) {} + + [[nodiscard]] constexpr auto INVERSE() const -> Color { + return Color(MAX_COLOR_VALUE - r, MAX_COLOR_VALUE - g, MAX_COLOR_VALUE - b, a); + } + + [[nodiscard]] constexpr auto LIGHTEN(int amount = DEFAULT_LIGHTEN_AMOUNT) const -> Color { + return Color( + std::min(static_cast(MAX_COLOR_VALUE), r + amount), + std::min(static_cast(MAX_COLOR_VALUE), g + amount), + std::min(static_cast(MAX_COLOR_VALUE), b + amount), + a); + } + + [[nodiscard]] constexpr auto DARKEN(int amount = DEFAULT_DARKEN_AMOUNT) const -> Color { + return Color( + std::max(static_cast(MIN_COLOR_VALUE), r - amount), + std::max(static_cast(MIN_COLOR_VALUE), g - amount), + std::max(static_cast(MIN_COLOR_VALUE), b - amount), + a); + } + + // Método estático para crear Color desde string hexadecimal + static auto fromHex(const std::string &hex_str) -> Color; + + [[nodiscard]] constexpr auto IS_EQUAL_TO(const Color &other) const -> bool { + return r == other.r && g == other.g && b == other.b && a == other.a; + } + + [[nodiscard]] constexpr auto APPROACH_TO(const Color &target, int step = DEFAULT_APPROACH_STEP) const -> Color { + auto approach_component = [step](Uint8 current, Uint8 target_val) -> Uint8 { + if (std::abs(current - target_val) <= step) { + return target_val; + } + return (current < target_val) ? current + step : current - step; + }; + + Uint8 new_r = approach_component(r, target.r); + Uint8 new_g = approach_component(g, target.g); + Uint8 new_b = approach_component(b, target.b); + Uint8 new_a = approach_component(a, target.a); + + return Color(new_r, new_g, new_b, new_a); + } +}; + +// Estructura para definir un color HSV +struct HSV { + float h, s, v; +}; + +// Estructura para definir el ciclo de color +enum class ColorCycleStyle { + SUBTLE_PULSE, // Variación leve en brillo (por defecto) + HUE_WAVE, // Variación suave en tono (sin verde) + VIBRANT, // Cambios agresivos en tono y brillo + DARKEN_GLOW, // Oscurece hacia el centro y regresa + LIGHT_FLASH // Ilumina hacia el centro y regresa +}; + +// --- Alias --- +using ColorCycle = std::array; + +// --- Colores predefinidos --- +constexpr Color NO_TEXT_COLOR = Color(0XFF, 0XFF, 0XFF); +constexpr Color SHADOW_TEXT_COLOR = Color(0X43, 0X43, 0X4F); +constexpr Color TITLE_SHADOW_TEXT_COLOR = Color(0x14, 0x87, 0xc4); + +constexpr Color FLASH_COLOR = Color(0XFF, 0XFF, 0XFF); + +constexpr Color BLUE_SKY_COLOR = Color(0X02, 0X88, 0XD1); +constexpr Color PINK_SKY_COLOR = Color(0XFF, 0X6B, 0X97); +constexpr Color GREEN_SKY_COLOR = Color(0X00, 0X79, 0X6B); + +// --- Funciones --- +auto getColorLikeKnightRider(const std::vector &colors, int counter) -> Color; +constexpr auto rgbToHsv(Color color) -> HSV; +constexpr auto hsvToRgb(HSV hsv) -> Color; +auto generateMirroredCycle(Color base, ColorCycleStyle style = ColorCycleStyle::SUBTLE_PULSE) -> ColorCycle; \ No newline at end of file diff --git a/source/define_buttons.h b/source/define_buttons.h index e876238..1ac0d6e 100644 --- a/source/define_buttons.h +++ b/source/define_buttons.h @@ -1,7 +1,6 @@ #pragma once #include // Para SDL_GamepadButton, SDL_Event, SDL_GamepadButtonEvent - #include // Para size_t #include // Para shared_ptr #include // Para basic_string, string diff --git a/source/director.cpp b/source/director.cpp index 13464f3..8e26fd4 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -1,33 +1,32 @@ // IWYU pragma: no_include #include "director.h" -#include // Para SDL_Scancode, SDL_GamepadButton -#include // Para mkdir, stat, S_IRWXU -#include // Para getuid - -#include // Para min -#include // Para errno, EEXIST, EACCES, ENAMETOOLONG -#include // Para printf, perror -#include // Para exit, EXIT_FAILURE, size_t, srand -#include // Para time -#include // Para make_unique, unique_ptr -#include -#include // Para runtime_error -#include // Para operator+, basic_string, allocator -#include // Para vector +#include // Para SDL_Scancode, SDL_GamepadButton, SDL_LogCategory, SDL_LogInfo, SDL_SetLogPriority, SDL_LogPriority, SDL_Quit +#include // Para mkdir, stat, S_IRWXU +#include // Para getuid +#include // Para min +#include // Para errno, EEXIST, EACCES, ENAMETOOLONG +#include // Para printf, perror +#include // Para exit, EXIT_FAILURE, size_t, srand, rand, system +#include // Para time +#include // Para make_unique, unique_ptr +#include // Para span +#include // Para runtime_error +#include // Para operator+, allocator, char_traits, operator==, string, basic_string +#include // Para vector #include "asset.h" // Para Asset, AssetType #include "audio.h" // Para Audio #include "input.h" // Para Input, InputAction #include "lang.h" // Para setLanguage #include "manage_hiscore_table.h" // Para ManageHiScoreTable -#include "options.h" // Para GamepadOptions, controllers, loa... +#include "options.h" // Para GamepadOptions, controllers, loadFromFile, saveToFile, SettingsOptions, settings, getPlayerWhoUsesKeyboard, setKeyboardToPlayer #include "param.h" // Para loadParamsFromFile #include "resource.h" // Para Resource #include "screen.h" // Para Screen -#include "section.hpp" // Para Name, Options, name, options +#include "section.hpp" // Para Name, Options, name, options, AttractMode, attract_mode #include "sections/credits.h" // Para Credits -#include "sections/game.h" // Para Game, GAME_MODE_DEMO_OFF, GAME_M... +#include "sections/game.h" // Para Game, GAME_MODE_DEMO_OFF, GAME_MODE_DEMO_ON #include "sections/hiscore_table.h" // Para HiScoreTable #include "sections/instructions.h" // Para Instructions #include "sections/intro.h" // Para Intro @@ -38,7 +37,7 @@ #include "utils.h" // Para Overrides, overrides, getPath #ifndef _WIN32 -#include // Para getpwuid, passwd +#include // Para getpwuid, passwd #endif // Constructor diff --git a/source/enter_name.cpp b/source/enter_name.cpp index 8206643..dc53c8e 100644 --- a/source/enter_name.cpp +++ b/source/enter_name.cpp @@ -4,7 +4,7 @@ #include // Para rand #include // Para basic_string_view, string_view -#include "utils.h" // Para trim +#include "utils.h" // Para trim // Constructor EnterName::EnterName() diff --git a/source/enter_name.h b/source/enter_name.h index 92fec67..56f9aee 100644 --- a/source/enter_name.h +++ b/source/enter_name.h @@ -2,7 +2,7 @@ #include // Para array #include // Para size_t -#include // Para string, basic_string +#include // Para allocator, string #include "utils.h" // Para trim diff --git a/source/fade.cpp b/source/fade.cpp index 916a32f..802b763 100644 --- a/source/fade.cpp +++ b/source/fade.cpp @@ -1,13 +1,12 @@ #include "fade.h" -#include // Para SDL_SetRenderTarget, SDL_FRect, SDL_GetRenderT... +#include // Para SDL_SetRenderTarget, SDL_FRect, SDL_GetRenderTarget, SDL_RenderFillRect, SDL_SetRenderDrawBlendMode, SDL_SetRenderDrawColor, Uint8, SDL_GetRenderDrawBlendMode, SDL_BLENDMODE_NONE, SDL_BlendMode, SDL_CreateTexture, SDL_DestroyTexture, SDL_RenderClear, SDL_RenderTexture, SDL_SetTextureAlphaMod, SDL_SetTextureBlendMode, SDL_BLENDMODE_BLEND, SDL_PixelFormat, SDL_TextureAccess +#include // Para min, max +#include // Para rand, size_t -#include // Para min, max -#include // Para rand, size_t - -#include "param.h" // Para Param, param, ParamGame, ParamFade -#include "screen.h" // Para Screen -#include "utils.h" // Para Color +#include "color.h" // Para Color +#include "param.h" // Para Param, param, ParamGame, ParamFade +#include "screen.h" // Para Screen // Constructor Fade::Fade() diff --git a/source/fade.h b/source/fade.h index 20f2ffb..aa84561 100644 --- a/source/fade.h +++ b/source/fade.h @@ -1,7 +1,6 @@ #pragma once #include // Para Uint8, SDL_FRect, SDL_Renderer, SDL_Texture, Uint16 - #include // Para vector struct Color; diff --git a/source/game_logo.cpp b/source/game_logo.cpp index c4f9d66..0335572 100644 --- a/source/game_logo.cpp +++ b/source/game_logo.cpp @@ -1,18 +1,17 @@ #include "game_logo.h" -#include // Para SDL_SetTextureScaleMode, SDL_FlipMode, SDL_ScaleMode - -#include // Para max +#include // Para SDL_SetTextureScaleMode, SDL_FlipMode, SDL_ScaleMode +#include // Para max #include "animated_sprite.h" // Para AnimatedSprite #include "audio.h" // Para Audio +#include "color.h" // Para Color #include "param.h" // Para Param, param, ParamGame, ParamTitle #include "resource.h" // Para Resource #include "screen.h" // Para Screen #include "smart_sprite.h" // Para SmartSprite #include "sprite.h" // Para Sprite #include "texture.h" // Para Texture -#include "utils.h" // Para Color constexpr int ZOOM_FACTOR = 5; constexpr int FLASH_DELAY = 3; diff --git a/source/global_inputs.cpp b/source/global_inputs.cpp index b24639d..5decde5 100644 --- a/source/global_inputs.cpp +++ b/source/global_inputs.cpp @@ -1,15 +1,15 @@ #include "global_inputs.h" -#include // Para basic_string, operator+, allocator, cha... -#include // Para vector +#include // Para operator+, allocator, char_traits, to_string, string +#include // Para vector #include "asset.h" // Para Asset #include "audio.h" // Para Audio -#include "input.h" // Para Input, INPUT_DO_NOT_ALLOW_REPEAT, Input... -#include "lang.h" // Para getText, Code, getNextLangCode, loadFro... -#include "options.h" // Para SettingsOptions, settings, VideoOptions +#include "input.h" // Para Input, INPUT_DO_NOT_ALLOW_REPEAT, InputAction, InputDevice +#include "lang.h" // Para getText, Code, getNextLangCode, loadFromFile +#include "options.h" // Para SettingsOptions, settings, VideoOptions, WindowOptions, video, window, AudioOptions, audio #include "screen.h" // Para Screen -#include "section.hpp" // Para Name, name, Options, options, AttractMode +#include "section.hpp" // Para Name, name, Options, options, AttractMode, attract_mode #include "ui/notifier.h" // Para Notifier #include "ui/service_menu.h" // Para ServiceMenu #include "utils.h" // Para boolToOnOff diff --git a/source/input.cpp b/source/input.cpp index 7f56436..29209a5 100644 --- a/source/input.cpp +++ b/source/input.cpp @@ -1,7 +1,6 @@ #include "input.h" #include // Para SDL_LogInfo, SDL_LogCategory, SDL_GetGamepa... - #include // Para find #include // Para size_t #include // Para distance diff --git a/source/input.h b/source/input.h index 417a87e..21ac2a5 100644 --- a/source/input.h +++ b/source/input.h @@ -1,7 +1,6 @@ #pragma once #include // Para SDL_GamepadButton, Uint8, SDL_Gamepad, SDL_Joystick, SDL_JoystickID, SDL_Scancode, Sint16 - #include // Para basic_string, string #include // Para vector diff --git a/source/item.h b/source/item.h index d9ff5f6..0df7a30 100644 --- a/source/item.h +++ b/source/item.h @@ -1,10 +1,9 @@ #pragma once -#include // Para SDL_FRect, Uint16 - -#include // Para shared_ptr, unique_ptr -#include // Para string -#include // Para vector +#include // Para SDL_FRect, Uint16 +#include // Para shared_ptr, unique_ptr +#include // Para string +#include // Para vector #include "animated_sprite.h" // Para AnimatedSprite #include "utils.h" // Para Circle diff --git a/source/manage_hiscore_table.cpp b/source/manage_hiscore_table.cpp index 48a6879..c0de93a 100644 --- a/source/manage_hiscore_table.cpp +++ b/source/manage_hiscore_table.cpp @@ -1,11 +1,10 @@ #include "manage_hiscore_table.h" -#include // Para SDL_ReadIO, SDL_WriteIO, SDL_CloseIO, SDL_GetE... +#include // Para SDL_ReadIO, SDL_WriteIO, SDL_CloseIO, SDL_GetError, SDL_IOFromFile, SDL_LogCategory, SDL_LogError, SDL_LogInfo +#include // Para find_if, sort +#include // Para distance -#include // Para find_if, sort -#include // Para distance - -#include "utils.h" // Para getFileName +#include "utils.h" // Para getFileName // Resetea la tabla a los valores por defecto void ManageHiScoreTable::clear() { diff --git a/source/moving_sprite.h b/source/moving_sprite.h index 436aee9..7dd8a05 100644 --- a/source/moving_sprite.h +++ b/source/moving_sprite.h @@ -1,7 +1,6 @@ #pragma once #include // Para SDL_FlipMode, SDL_FPoint, SDL_FRect - #include // Para max #include // Para shared_ptr diff --git a/source/options.cpp b/source/options.cpp index f6a2451..f5467cd 100644 --- a/source/options.cpp +++ b/source/options.cpp @@ -1,16 +1,15 @@ #include "options.h" -#include // Para SDL_LogCategory, SDL_LogInfo, SDL_LogError +#include // Para SDL_GamepadButton, SDL_ScaleMode, SDL_LogCategory, SDL_LogInfo, SDL_LogError, SDL_LogWarn +#include // Para clamp, max +#include // Para basic_ostream, operator<<, basic_ostream::operator<<, basic_ofstream, basic_istream, basic_ifstream, ifstream, ofstream +#include // Para swap +#include // Para vector -#include // Para clamp -#include // Para basic_ostream, operator<<, basic_ostream::... -#include // Para swap -#include // Para vector - -#include "asset.h" -#include "input.h" // Para InputDeviceToUse -#include "lang.h" // Para Code -#include "utils.h" // Para boolToString, stringToBool, getFileName +#include "asset.h" // Para Asset +#include "input.h" // Para InputDevice +#include "lang.h" // Para Code +#include "utils.h" // Para boolToString, stringToBool, getFileName namespace Options { // --- Variables globales --- diff --git a/source/options.h b/source/options.h index 636a1a7..3ba885a 100644 --- a/source/options.h +++ b/source/options.h @@ -1,7 +1,6 @@ #pragma once #include // Para SDL_GamepadButton, SDL_ScaleMode - #include // Para copy #include // Para allocator, string #include // Para move diff --git a/source/param.cpp b/source/param.cpp index d9b4f7b..0012459 100644 --- a/source/param.cpp +++ b/source/param.cpp @@ -1,7 +1,6 @@ #include "param.h" #include // Para SDL_LogCategory, SDL_LogError, SDL_LogInfo - #include // Para basic_istream, basic_ifstream, ifstream #include #include // Para basic_istringstream @@ -9,7 +8,8 @@ #include // Para operator==, stoi, char_traits, string, ope... #include -#include "utils.h" // Para Zone, Color, NotifyPosition, getFileName +#include "color.h" +#include "utils.h" Param param; diff --git a/source/param.h b/source/param.h index a4d6a78..09ca5a9 100644 --- a/source/param.h +++ b/source/param.h @@ -1,11 +1,11 @@ #pragma once #include // Para Uint32, SDL_FRect - #include // Para array #include // Para basic_string, string -#include "utils.h" // Para Color, NotifyPosition (ptr only), Zone +#include "color.h" // Para Color, NotifyPosition (ptr only), Zone +#include "utils.h" // --- Parámetros del juego --- struct ParamGame { diff --git a/source/path_sprite.h b/source/path_sprite.h index 76d2e67..5e6f9a1 100644 --- a/source/path_sprite.h +++ b/source/path_sprite.h @@ -1,7 +1,6 @@ #pragma once #include // Para SDL_FPoint - #include // Para std::function #include // Para shared_ptr #include // Para vector diff --git a/source/player.cpp b/source/player.cpp index d1fc46b..341b395 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -1,7 +1,6 @@ #include "player.h" #include // Para SDL_GetTicks, SDL_FlipMode, SDL_FRect - #include // Para clamp, max, min #include // Para rand diff --git a/source/player.h b/source/player.h index 1c70a8b..3c690d8 100644 --- a/source/player.h +++ b/source/player.h @@ -1,10 +1,9 @@ #pragma once -#include // Para Uint32, SDL_FRect - -#include // Para unique_ptr, shared_ptr -#include // Para basic_string, string -#include // Para vector +#include // Para Uint32, SDL_FRect +#include // Para allocator, unique_ptr, shared_ptr +#include // Para string +#include // Para vector #include "animated_sprite.h" // Para AnimatedSprite #include "enter_name.h" // Para EnterName diff --git a/source/resource.cpp b/source/resource.cpp index cf1f702..2b25628 100644 --- a/source/resource.cpp +++ b/source/resource.cpp @@ -1,19 +1,19 @@ #include "resource.h" -#include // Para SDL_LogInfo, SDL_LogCategory, SDL_L... - -#include // Para find_if -#include // Para array -#include // Para exit -#include // Para runtime_error -#include +#include // Para SDL_LogInfo, SDL_LogCategory, SDL_LogError, SDL_SetRenderDrawColor, SDL_EventType, SDL_PollEvent, SDL_RenderFillRect, SDL_RenderRect, SDLK_ESCAPE, SDL_Event +#include // Para find_if, max +#include // Para array +#include // Para exit +#include // Para runtime_error +#include // Para move #include "asset.h" // Para Asset, AssetType -#include "external/jail_audio.h" // Para JA_DeleteMusic, JA_DeleteSound, JA_... +#include "color.h" // Para Color +#include "external/jail_audio.h" // Para JA_DeleteMusic, JA_DeleteSound, JA_LoadMusic, JA_LoadSound #include "lang.h" // Para getText #include "param.h" // Para Param, param, ParamResource, ParamGame #include "screen.h" // Para Screen -#include "text.h" // Para Text, loadTextFile, TextFile (ptr o... +#include "text.h" // Para Text, loadTextFile, TextFile (ptr only) struct JA_Music_t; // lines 11-11 struct JA_Sound_t; // lines 12-12 diff --git a/source/resource.h b/source/resource.h index 76e0e0f..0e7b2ee 100644 --- a/source/resource.h +++ b/source/resource.h @@ -1,12 +1,11 @@ #pragma once -#include // Para SDL_FRect - -#include // Para size_t -#include // Para shared_ptr -#include // Para basic_string, string -#include -#include // Para vector +#include // Para SDL_FRect +#include // Para size_t +#include // Para shared_ptr +#include // Para string +#include // Para move +#include // Para vector #include "animated_sprite.h" // Para AnimationsFileBuffer #include "text.h" // Para Text, TextFile diff --git a/source/scoreboard.cpp b/source/scoreboard.cpp index 4101c58..6367f1b 100644 --- a/source/scoreboard.cpp +++ b/source/scoreboard.cpp @@ -1,12 +1,12 @@ #include "scoreboard.h" #include // 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 // Para max #include // Para roundf #include // Para operator<<, setfill, setw #include // Para basic_ostream, basic_ostringstream, basic_ostream::operator<<, ostringstream +#include "color.h" #include "enter_name.h" // Para NAME_SIZE #include "lang.h" // Para getText #include "param.h" // Para Param, ParamScoreboard, param diff --git a/source/scoreboard.h b/source/scoreboard.h index 9b7ded2..bdd5d32 100644 --- a/source/scoreboard.h +++ b/source/scoreboard.h @@ -1,14 +1,13 @@ #pragma once #include // Para SDL_FPoint, SDL_GetTicks, SDL_FRect, SDL_Texture, SDL_Renderer, Uint64 +#include // Para array +#include // Para size_t +#include // Para shared_ptr, unique_ptr +#include // Para string, basic_string +#include // Para vector -#include -#include // Para size_t -#include // Para shared_ptr, unique_ptr -#include // Para basic_string, string -#include // Para vector - -#include "utils.h" // Para Color +#include "color.h" // Para Color class Sprite; class Text; diff --git a/source/screen.cpp b/source/screen.cpp index 110aa53..7825838 100644 --- a/source/screen.cpp +++ b/source/screen.cpp @@ -1,22 +1,22 @@ #include "screen.h" -#include // Para SDL_SetRenderTarget, SDL_LogCategory - -#include // Para min, max -#include // Para basic_ifstream, ifstream -#include // Para istreambuf_iterator, operator== -#include // Para allocator, shared_ptr, __shared_pt... -#include // Para basic_string, char_traits, operator+ +#include // Para SDL_SetRenderTarget, SDL_LogCategory, SDL_LogInfo, SDL_RenderTexture, SDL_SetRenderDrawColor, SDL_SetRenderVSync, SDL_GetError, SDL_LogError, SDL_RendererLogicalPresentation, SDL_SetRenderLogicalPresentation, SDL_CreateTexture, SDL_DestroyTexture, SDL_DestroyWindow, SDL_GetTicks, SDL_Quit, SDL_RENDERER_VSYNC_DISABLED, SDL_RenderClear, SDL_CreateRenderer, SDL_CreateWindow, SDL_DestroyRenderer, SDL_DisplayID, SDL_FRect, SDL_GetCurrentDisplayMode, SDL_GetDisplayName, SDL_GetDisplays, SDL_GetRenderTarget, SDL_GetWindowPosition, SDL_GetWindowSize, SDL_Init, SDL_LogWarn, SDL_PixelFormat, SDL_RenderFillRect, SDL_RenderPresent, SDL_SetHint, SDL_SetRenderDrawBlendMode, SDL_SetTextureScaleMode, SDL_SetWindowFullscreen, SDL_SetWindowPosition, SDL_SetWindowSize, SDL_TextureAccess, SDL_free, SDL_BLENDMODE_BLEND, SDL_HINT_RENDER_DRIVER, SDL_INIT_VIDEO, SDL_PRIu32, SDL_ScaleMode, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_OPENGL, SDL_WindowFlags +#include // Para min, max +#include // Para basic_ifstream, ifstream +#include // Para istreambuf_iterator, operator== +#include // Para allocator, shared_ptr, make_shared, __shared_ptr_access +#include // Para operator+, char_traits, to_string, string #include "asset.h" // Para Asset #include "external/jail_shader.h" // Para init, render #include "mouse.h" // Para updateCursorVisibility -#include "options.h" // Para VideoOptions, video, WindowOptions +#include "options.h" // Para VideoOptions, video, WindowOptions, window #include "param.h" // Para Param, param, ParamGame, ParamDebug #include "text.h" // Para Text, TEXT_COLOR, TEXT_STROKE #include "texture.h" // Para Texture #include "ui/notifier.h" // Para Notifier #include "ui/service_menu.h" // Para ServiceMenu +#include "utils.h" // Para Zone // Singleton Screen *Screen::instance = nullptr; diff --git a/source/screen.h b/source/screen.h index cab9e23..6cb1a4d 100644 --- a/source/screen.h +++ b/source/screen.h @@ -1,12 +1,11 @@ #pragma once #include // Para SDL_FRect, SDL_HideWindow, SDL_Renderer, SDL_ShowWindow, Uint32, SDL_Texture, SDL_Window +#include // Para shared_ptr +#include // Para string -#include // Para shared_ptr -#include // Para basic_string, string - -#include "options.h" // Para VideoOptions, video -#include "utils.h" // Para Color +#include "color.h" // Para Color +#include "options.h" // Para VideoOptions, video class Notifier; class ServiceMenu; diff --git a/source/sections/credits.cpp b/source/sections/credits.cpp index 1415f29..0483b5f 100644 --- a/source/sections/credits.cpp +++ b/source/sections/credits.cpp @@ -2,7 +2,6 @@ #include "credits.h" #include // 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 // Para max, min, clamp #include // Para array #include // Para runtime_error @@ -12,6 +11,7 @@ #include "audio.h" // Para Audio #include "balloon_manager.h" // Para BalloonManager +#include "color.h" // Para Zone, SHADOW_TEXT_COLOR, NO_TEXT_COLOR, Color #include "fade.h" // Para Fade, FadeType, FadeMode #include "global_events.h" // Para check #include "global_inputs.h" // Para check @@ -27,7 +27,7 @@ #include "texture.h" // Para Texture #include "tiled_bg.h" // Para TiledBG, TiledBGMode #include "ui/service_menu.h" // Para ServiceMenu -#include "utils.h" // Para Zone, SHADOW_TEXT_COLOR, NO_TEXT_COLOR, Color +#include "utils.h" // Textos constexpr std::string_view TEXT_COPYRIGHT = "@2020,2025 JailDesigner"; diff --git a/source/sections/credits.h b/source/sections/credits.h index cf64677..6cdafb1 100644 --- a/source/sections/credits.h +++ b/source/sections/credits.h @@ -1,13 +1,13 @@ #pragma once #include // Para SDL_FRect, Uint32, SDL_Texture, Uint64 - #include // Para unique_ptr, shared_ptr #include // Para vector +#include "color.h" // Para Zone, Color #include "options.h" // Para AudioOptions, MusicOptions, audio #include "param.h" // Para Param, ParamGame, param -#include "utils.h" // Para Zone, Color +#include "utils.h" // Declaraciones adelantadas class BalloonManager; diff --git a/source/sections/game.cpp b/source/sections/game.cpp index 6192d37..d632c28 100644 --- a/source/sections/game.cpp +++ b/source/sections/game.cpp @@ -1,12 +1,11 @@ #include "game.h" -#include // Para SDL_GetTicks, SDL_SetRenderTarget - -#include // Para find_if, clamp, find, min -#include -#include // Para rand, size_t -#include // Para function -#include // Para distance, size +#include // Para SDL_GetTicks, SDL_SetRenderTarget, SDL_EventType, SDL_CreateTexture, SDL_Delay, SDL_DestroyTexture, SDL_Event, SDL_GetRenderTarget, SDL_PollEvent, SDL_RenderTexture, SDL_SetTextureBlendMode, SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6, SDLK_7, SDLK_8, SDLK_9, SDL_BLENDMODE_BLEND, SDL_PixelFormat, SDL_Point, SDL_TextureAccess +#include // Para max, find_if, clamp, find, min +#include // Para array +#include // Para rand, size_t +#include // Para function +#include // Para distance, size #include "asset.h" // Para Asset #include "audio.h" // Para Audio @@ -14,22 +13,23 @@ #include "balloon.h" // Para Balloon, BALLOON_SPEED #include "balloon_manager.h" // Para BalloonManager #include "bullet.h" // Para Bullet, BulletType, BulletMoveStatus +#include "color.h" // Para Color, FLASH_COLOR #include "fade.h" // Para Fade, FadeType, FadeMode #include "global_events.h" // Para check #include "global_inputs.h" // Para check -#include "input.h" // Para InputAction, Input, INPUT_DO_NOT_A... +#include "input.h" // Para InputAction, Input, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_ALLOW_REPEAT, InputDevice #include "item.h" // Para Item, ItemType #include "lang.h" // Para getText -#include "manage_hiscore_table.h" // Para HiScoreEntry, ManageHiScoreTable -#include "param.h" // Para Param, param, ParamGame, ParamScor... -#include "path_sprite.h" // Para Path, PathSprite, createPath, Path... +#include "manage_hiscore_table.h" // Para ManageHiScoreTable, HiScoreEntry +#include "param.h" // Para Param, param, ParamGame, ParamScoreboard, ParamFade, ParamBalloon +#include "path_sprite.h" // Para Path, PathSprite, createPath, PathType #include "player.h" // Para Player, PlayerState #include "resource.h" // Para Resource -#include "scoreboard.h" // Para Scoreboard, ScoreboardMode, SCOREB... +#include "scoreboard.h" // Para Scoreboard, ScoreboardMode, SCOREBOARD_LEFT_PANEL, SCOREBOARD_RIGHT_PANEL, SCOREBOARD_CENTER_PANEL #include "screen.h" // Para Screen -#include "section.hpp" // Para Name, name, AttractMode, Options +#include "section.hpp" // Para Name, name, AttractMode, Options, attract_mode, options #include "smart_sprite.h" // Para SmartSprite -#include "stage.h" // Para number, get, Stage, total_power +#include "stage.h" // Para number, Stage, get, total_power, power, addPower, init, power_can_be_added, stages #include "tabe.h" // Para Tabe, TabeState #include "text.h" // Para Text #include "texture.h" // Para Texture diff --git a/source/sections/game.h b/source/sections/game.h index 24155a5..dbfb2f0 100644 --- a/source/sections/game.h +++ b/source/sections/game.h @@ -1,13 +1,11 @@ #pragma once -#include // Para SDL_Event, SDL_Renderer, SDL_Texture, Uint64, Uint8 +#include // Para SDL_Event, SDL_Renderer, SDL_Texture, Uint64 +#include // Para shared_ptr, unique_ptr +#include // Para string +#include // Para vector -#include // Para shared_ptr, unique_ptr -#include // Para string -#include // Para vector - -#include "bullet.h" // Para Bullet, BulletType (ptr only) -#include "item.h" // Para Item, ItemType (ptr only) +#include "item.h" // Para Item, ItemType #include "manage_hiscore_table.h" // Para HiScoreEntry #include "options.h" // Para SettingsOptions, settings, DifficultyCode (ptr only) #include "path_sprite.h" // Para PathSprite, Path @@ -18,12 +16,14 @@ class Background; class Balloon; class BalloonManager; +class Bullet; class Fade; class Input; class Scoreboard; class Screen; class Tabe; class Texture; +enum class BulletType : Uint8; // Modo demo constexpr bool GAME_MODE_DEMO_OFF = false; diff --git a/source/sections/hiscore_table.cpp b/source/sections/hiscore_table.cpp index 41f0eed..b38cb13 100644 --- a/source/sections/hiscore_table.cpp +++ b/source/sections/hiscore_table.cpp @@ -1,7 +1,6 @@ #include "hiscore_table.h" #include // Para SDL_GetTicks, SDL_SetRenderTarget - #include // Para max #include // Para rand, size_t #include // Para function @@ -9,6 +8,7 @@ #include "audio.h" // Para Audio #include "background.h" // Para Background +#include "color.h" // Para Color, easeOutQuint, NO_TEXT_COLOR #include "fade.h" // Para Fade, FadeMode, FadeType #include "global_events.h" // Para check #include "global_inputs.h" // Para check @@ -24,7 +24,7 @@ #include "sprite.h" // Para Sprite #include "text.h" // Para Text, TEXT_SHADOW, TEXT_COLOR #include "texture.h" // Para Texture -#include "utils.h" // Para Color, easeOutQuint, NO_TEXT_COLOR +#include "utils.h" // Constructor HiScoreTable::HiScoreTable() diff --git a/source/sections/hiscore_table.h b/source/sections/hiscore_table.h index 547f8ac..d247652 100644 --- a/source/sections/hiscore_table.h +++ b/source/sections/hiscore_table.h @@ -1,13 +1,12 @@ #pragma once -#include // Para Uint16, SDL_FRect, SDL_Renderer, SDL_Texture, Uint64, Uint8 - -#include // Para unique_ptr, shared_ptr -#include // Para string -#include // Para vector +#include // Para Uint16, SDL_FRect, SDL_Renderer, SDL_Texture, Uint64, Uint8 +#include // Para unique_ptr, shared_ptr +#include // Para string +#include // Para vector +#include "color.h" // Para Color #include "path_sprite.h" // Para Path, PathSprite (ptr only) -#include "utils.h" // Para Color class Background; class Fade; diff --git a/source/sections/instructions.cpp b/source/sections/instructions.cpp index 141c099..8eab74d 100644 --- a/source/sections/instructions.cpp +++ b/source/sections/instructions.cpp @@ -1,7 +1,6 @@ #include "instructions.h" #include // Para SDL_GetTicks, SDL_SetRenderTarget, SDL_Re... - #include // Para max #include // Para array #include // Para basic_string, string @@ -9,6 +8,7 @@ #include // Para vector #include "audio.h" // Para Audio +#include "color.h" // Para Color, SHADOW_TEXT_COLOR, Zone, NO_TEXT_C... #include "fade.h" // Para Fade, FadeMode, FadeType #include "global_events.h" // Para check #include "global_inputs.h" // Para check @@ -21,7 +21,7 @@ #include "sprite.h" // Para Sprite #include "text.h" // Para Text, TEXT_CENTER, TEXT_COLOR, TEXT_SHADOW #include "tiled_bg.h" // Para TiledBG, TiledBGMode -#include "utils.h" // Para Color, SHADOW_TEXT_COLOR, Zone, NO_TEXT_C... +#include "utils.h" // Constructor Instructions::Instructions() diff --git a/source/sections/instructions.h b/source/sections/instructions.h index 80de33e..89ad64c 100644 --- a/source/sections/instructions.h +++ b/source/sections/instructions.h @@ -1,7 +1,6 @@ #pragma once #include // Para SDL_Texture, Uint32, SDL_Renderer, SDL_FPoint, SDL_FRect, Uint64 - #include // Para unique_ptr, shared_ptr #include // Para vector diff --git a/source/sections/intro.cpp b/source/sections/intro.cpp index f8bdde2..46c6e1e 100644 --- a/source/sections/intro.cpp +++ b/source/sections/intro.cpp @@ -1,7 +1,6 @@ #include "intro.h" #include // Para SDL_GetTicks, SDL_SetRenderDrawColor, SDL_FRect, SDL_RenderFillRect, SDL_GetRenderTarget, SDL_RenderClear, SDL_RenderRect, SDL_SetRenderTarget, SDL_BLENDMODE_BLEND, SDL_PixelFormat, SDL_PollEvent, SDL_RenderTexture, SDL_TextureAccess, SDLK_A, SDLK_C, SDLK_D, SDLK_F, SDLK_S, SDLK_V, SDLK_X, SDLK_Z, SDL_Event, SDL_EventType, Uint32 - #include // Para max #include // Para array #include // Para function @@ -10,6 +9,7 @@ #include // Para move #include "audio.h" // Para Audio +#include "color.h" // Para Color, Zone, easeInOutExpo, easeInElastic, easeOutBounce, easeOutElastic, easeOutQuad, easeOutQuint #include "global_events.h" // Para check #include "global_inputs.h" // Para check #include "input.h" // Para Input @@ -22,8 +22,8 @@ #include "text.h" // Para Text #include "texture.h" // Para Texture #include "tiled_bg.h" // Para TiledBG, TiledBGMode -#include "utils.h" // Para Color, Zone, easeInOutExpo, easeInElastic, easeOutBounce, easeOutElastic, easeOutQuad, easeOutQuint -#include "writer.h" // Para Writer +#include "utils.h" +#include "writer.h" // Para Writer #ifdef DEBUG #include // Para operator<<, setfill, setw @@ -98,7 +98,7 @@ void Intro::updateScenes() { void Intro::updateScene0() { // Primera imagen - UPV enableCardAndShadow(0); - + // Primer texto de la primera imagen if (card_sprites_.at(0)->hasFinished() && !texts_.at(0)->hasFinished()) { texts_.at(0)->setEnabled(true); diff --git a/source/sections/intro.h b/source/sections/intro.h index a15c465..eb802c3 100644 --- a/source/sections/intro.h +++ b/source/sections/intro.h @@ -1,14 +1,14 @@ #pragma once -#include // Para Uint32, Uint64 - -#include // Para unique_ptr -#include // Para vector +#include // Para SDL_Keycode, Uint32, Uint64 +#include // Para uint8_t +#include // Para unique_ptr +#include // Para vector +#include "color.h" // Para Color #include "param.h" // Para Param, ParamIntro, param #include "path_sprite.h" // Para PathSprite #include "tiled_bg.h" // Para TiledBG -#include "utils.h" // Para Color #include "writer.h" // Para Writer /* diff --git a/source/sections/logo.cpp b/source/sections/logo.cpp index c1b5998..9c3ba41 100644 --- a/source/sections/logo.cpp +++ b/source/sections/logo.cpp @@ -1,11 +1,11 @@ #include "logo.h" #include // Para SDL_GetTicks, SDL_PollEvent, SDL_Event, SDL_FRect - #include // Para max #include // Para move #include "audio.h" // Para Audio +#include "color.h" // Para Color, Zone #include "global_events.h" // Para check #include "global_inputs.h" // Para check #include "input.h" // Para Input @@ -15,7 +15,7 @@ #include "section.hpp" // Para Name, name #include "sprite.h" // Para Sprite #include "texture.h" // Para Texture -#include "utils.h" // Para Color, Zone +#include "utils.h" // Constructor Logo::Logo() diff --git a/source/sections/logo.h b/source/sections/logo.h index 379aa7c..1d49832 100644 --- a/source/sections/logo.h +++ b/source/sections/logo.h @@ -1,12 +1,11 @@ #pragma once #include // Para SDL_FPoint, Uint64 +#include // Para unique_ptr, shared_ptr +#include // Para vector -#include // Para unique_ptr, shared_ptr -#include // Para vector - -#include "sprite.h" // Para Sprite -#include "utils.h" // Para Color +#include "color.h" // Para Color +#include "sprite.h" // Para Sprite class Texture; diff --git a/source/sections/title.cpp b/source/sections/title.cpp index b891439..28e9693 100644 --- a/source/sections/title.cpp +++ b/source/sections/title.cpp @@ -1,7 +1,6 @@ #include "title.h" #include // Para SDL_GetTicks, Uint32, SDL_EventType - #include // Para find_if #include // Para size_t #include // Para basic_ostream, basic_ostream::operator<< @@ -9,6 +8,7 @@ #include // Para vector #include "audio.h" // Para Audio +#include "color.h" // Para Color, Zone, NO_TEXT_COLOR, TITLE_SHADO... #include "define_buttons.h" // Para DefineButtons #include "fade.h" // Para Fade, FadeType #include "game_logo.h" // Para GameLogo @@ -27,7 +27,7 @@ #include "tiled_bg.h" // Para TiledBG, TiledBGMode #include "ui/notifier.h" // Para Notifier #include "ui/service_menu.h" // Para ServiceMenu -#include "utils.h" // Para Color, Zone, NO_TEXT_COLOR, TITLE_SHADO... +#include "utils.h" class Texture; diff --git a/source/sections/title.h b/source/sections/title.h index 68e3411..82763d2 100644 --- a/source/sections/title.h +++ b/source/sections/title.h @@ -1,7 +1,6 @@ #pragma once #include // Para Uint32 - #include // Para unique_ptr, shared_ptr #include #include diff --git a/source/sprite.h b/source/sprite.h index 34c0b25..f312dea 100644 --- a/source/sprite.h +++ b/source/sprite.h @@ -1,7 +1,6 @@ #pragma once #include // Para SDL_FRect, SDL_FPoint - #include // Para shared_ptr class Texture; diff --git a/source/tabe.cpp b/source/tabe.cpp index f8a35c6..bce069e 100644 --- a/source/tabe.cpp +++ b/source/tabe.cpp @@ -2,10 +2,9 @@ #include "tabe.h" #include // Para SDL_FlipMode, SDL_GetTicks - -#include // Para max -#include // Para array -#include // Para rand, abs +#include // Para max +#include // Para array +#include // Para rand, abs #include "audio.h" // Para Audio #include "param.h" // Para Param, ParamGame, param diff --git a/source/tabe.h b/source/tabe.h index 269d8b6..5c54737 100644 --- a/source/tabe.h +++ b/source/tabe.h @@ -1,7 +1,6 @@ #pragma once #include // Para Uint32, SDL_GetTicks, SDL_FRect - #include // Para rand #include // Para unique_ptr diff --git a/source/text.cpp b/source/text.cpp index 112a93c..67a4b27 100644 --- a/source/text.cpp +++ b/source/text.cpp @@ -1,7 +1,6 @@ #include "text.h" #include // Para SDL_SetRenderTarget, SDL_GetRenderTarget, Uint8 - #include // Para size_t #include // Para basic_ifstream, basic_istream, basic_ostream #include // Para cerr diff --git a/source/text.h b/source/text.h index 49362e4..259055b 100644 --- a/source/text.h +++ b/source/text.h @@ -1,14 +1,12 @@ #pragma once #include // Para Uint8 +#include // Para array +#include // Para shared_ptr, unique_ptr +#include // Para string -#include -#include // Para unique_ptr, shared_ptr -#include // Para string - -#include "color.h" // Para Color -#include "sprite.h" // Para Sprite -#include "utils.h" +#include "color.h" // Para Color +#include "sprite.h" // Para Sprite class Texture; diff --git a/source/texture.cpp b/source/texture.cpp index 433f900..fde4c87 100644 --- a/source/texture.cpp +++ b/source/texture.cpp @@ -2,7 +2,6 @@ #include "texture.h" #include // Para SDL_LogError, SDL_LogCategory, Uint8, SDL_... - #include // Para uint32_t #include // Para memcpy #include // Para basic_ifstream, basic_istream, basic_ios @@ -12,9 +11,10 @@ #include #include // Para vector +#include "color.h" // Para getFileName, Color, printWithDots #include "external/gif.h" // Para Gif #include "stb_image.h" // Para stbi_image_free, stbi_load, STBI_rgb_alpha -#include "utils.h" // Para getFileName, Color, printWithDots +#include "utils.h" // Constructor Texture::Texture(SDL_Renderer *renderer, std::string path) diff --git a/source/texture.h b/source/texture.h index b62f2a6..a9524f6 100644 --- a/source/texture.h +++ b/source/texture.h @@ -1,7 +1,6 @@ #pragma once #include // Para Uint8, SDL_Renderer, Uint16, SDL_FlipMode, SDL_PixelFormat, SDL_TextureAccess, SDL_Texture, Uint32, SDL_BlendMode, SDL_FPoint, SDL_FRect - #include // Para array #include // Para size_t #include // Para shared_ptr diff --git a/source/tiled_bg.cpp b/source/tiled_bg.cpp index b904b56..3a41b7e 100644 --- a/source/tiled_bg.cpp +++ b/source/tiled_bg.cpp @@ -1,7 +1,6 @@ #include "tiled_bg.h" #include // Para SDL_SetRenderTarget, SDL_CreateTexture, SDL_DestroyTexture, SDL_FRect, SDL_GetRenderTarget, SDL_RenderTexture, SDL_PixelFormat, SDL_TextureAccess - #include // Para sin #include // Para rand #include // Para allocator, unique_ptr, make_unique diff --git a/source/tiled_bg.h b/source/tiled_bg.h index ff67a36..52d93ad 100644 --- a/source/tiled_bg.h +++ b/source/tiled_bg.h @@ -1,10 +1,9 @@ #pragma once #include // Para SDL_FRect, SDL_SetTextureColorMod, SDL_Renderer, SDL_Texture +#include // Para array -#include - -#include "utils.h" // Para Color +#include "color.h" // Para Color // Modos de funcionamiento para el tileado de fondo enum class TiledBGMode : int { diff --git a/source/ui/menu_renderer.cpp b/source/ui/menu_renderer.cpp index 3de965f..17fc880 100644 --- a/source/ui/menu_renderer.cpp +++ b/source/ui/menu_renderer.cpp @@ -1,12 +1,14 @@ #include "menu_renderer.h" -#include // Para max -#include // Para pair, move +#include // Para max +#include // Para pair, move +#include "color.h" // Para Color, generateMirroredCycle, ColorCycleStyle #include "menu_option.h" // Para MenuOption #include "param.h" // Para Param, param, ParamServiceMenu, ParamGame #include "screen.h" // Para Screen #include "text.h" // Para Text, TEXT_CENTER, TEXT_COLOR +#include "utils.h" // Para Zone MenuRenderer::MenuRenderer(const ServiceMenu *menu_state, std::shared_ptr element_text, std::shared_ptr title_text) : element_text_(std::move(element_text)), title_text_(std::move(title_text)) {} diff --git a/source/ui/menu_renderer.h b/source/ui/menu_renderer.h index a9c7ef2..84d7631 100644 --- a/source/ui/menu_renderer.h +++ b/source/ui/menu_renderer.h @@ -1,14 +1,13 @@ #pragma once -#include // Para SDL_FRect, Uint32 - -#include -#include // Para size_t -#include // Para shared_ptr, unique_ptr -#include // Para vector +#include // Para SDL_FRect, Uint32 +#include // Para array +#include // Para size_t +#include // Para shared_ptr, unique_ptr +#include // Para vector +#include "color.h" // Para Color #include "ui/service_menu.h" // Para ServiceMenu -#include "utils.h" // Para Color class MenuOption; // Forward declarations diff --git a/source/ui/notifier.cpp b/source/ui/notifier.cpp index bcf6e95..be37842 100644 --- a/source/ui/notifier.cpp +++ b/source/ui/notifier.cpp @@ -1,7 +1,6 @@ #include "notifier.h" #include // Para SDL_RenderFillRect, SDL_FRect, SDL_RenderClear - #include // Para remove_if #include // Para basic_string, string #include diff --git a/source/ui/notifier.h b/source/ui/notifier.h index 3fc5669..3e1c711 100644 --- a/source/ui/notifier.h +++ b/source/ui/notifier.h @@ -1,12 +1,12 @@ #pragma once #include // Para SDL_FRect, SDL_Renderer - #include // Para shared_ptr #include // Para basic_string, string #include // Para vector -#include "utils.h" // Para stringInVector, Color +#include "color.h" // Para stringInVector, Color +#include "utils.h" class Sprite; class Text; diff --git a/source/ui/service_menu.cpp b/source/ui/service_menu.cpp index ec09a13..5d35955 100644 --- a/source/ui/service_menu.cpp +++ b/source/ui/service_menu.cpp @@ -1,6 +1,6 @@ #include "ui/service_menu.h" -#include // Para max +#include // Para max #include "audio.h" // Para Audio #include "lang.h" // Para getText, getCodeFromName, getNameFromCode diff --git a/source/ui/ui_message.h b/source/ui/ui_message.h index 94a7e38..c1fadfc 100644 --- a/source/ui/ui_message.h +++ b/source/ui/ui_message.h @@ -1,9 +1,9 @@ #pragma once -#include // Para shared_ptr -#include // Para string, basic_string +#include // Para shared_ptr +#include // Para string -#include "utils.h" // Para Color +#include "color.h" // Para Color class Text; diff --git a/source/utils.cpp b/source/utils.cpp index 129337d..57983c5 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -1,36 +1,21 @@ #define _USE_MATH_DEFINES #include "utils.h" -#include // Para SDL_RenderPoint, SDL_FRect, SDL_CloseIO, SDL_I... - -#include // Para min, clamp, find_if_not, find, transform +#include // Para SDL_RenderPoint, SDL_FRect, SDL_CloseIO, SDL_IOFromFile, SDL_LogCategory, SDL_LogError, SDL_LogInfo, SDL_ReadIO, SDL_FPoint, SDL_Renderer +#include // Para clamp, find_if_not, find, transform #include // Para tolower, isspace -#include // Para pow, sinf, fmaxf, fminf, M_PI, fmodf, roundf, sin -#include // Para operator< +#include // Para pow, sin, M_PI, cos +#include // Para operator<, __synth3way_t +#include // Para size_t #include // Para path #include // Para runtime_error -#include // Para basic_string, allocator, string, char_traits +#include // Para basic_string, allocator, string, operator==, operator+, char_traits -#include "lang.h" // Para getText +#include "lang.h" // Para getText // Variables Overrides overrides = Overrides(); -// Obtiene un color del vector de colores imitando al Coche Fantástico -auto getColorLikeKnightRider(const std::vector &colors, int counter) -> Color { - int cycle_length = colors.size() * 2 - 2; - size_t n = counter % cycle_length; - - size_t index; - if (n < colors.size()) { - index = n; // Avanza: 0,1,2,3 - } else { - index = 2 * (colors.size() - 1) - n; // Retrocede: 2,1 - } - - return colors[index]; -} - // Calcula el cuadrado de la distancia entre dos puntos auto distanceSquared(int x1, int y1, int x2, int y2) -> double { const int DELTA_X = x2 - x1; @@ -153,24 +138,6 @@ void drawCircle(SDL_Renderer *renderer, int32_t center_x, int32_t center_y, int3 } } -// Aclara el color -auto lightenColor(const Color &color, int amount) -> Color { - Color new_color; - new_color.r = std::min(255, color.r + amount); - new_color.g = std::min(255, color.g + amount); - new_color.b = std::min(255, color.b + amount); - return new_color; -} - -// Oscurece el color -auto darkenColor(const Color &color, int amount) -> Color { - Color new_color; - new_color.r = std::min(255, color.r - +amount); - new_color.g = std::min(255, color.g - +amount); - new_color.b = std::min(255, color.b - +amount); - return new_color; -} - // Quita los espacioes en un string auto trim(const std::string &str) -> std::string { auto start = std::find_if_not(str.begin(), str.end(), ::isspace); @@ -369,128 +336,4 @@ auto getFileName(const std::string &path) -> std::string { auto getPath(const std::string &full_path) -> std::string { std::filesystem::path path(full_path); return path.parent_path().string(); -} - -constexpr auto rgbToHsv(Color color) -> HSV { - float r = color.r / 255.0F; - float g = color.g / 255.0F; - float b = color.b / 255.0F; - - float max = fmaxf(fmaxf(r, g), b); - float min = fminf(fminf(r, g), b); - float delta = max - min; - - float h = 0.0F; - if (delta > 0.00001F) { - if (max == r) { - h = fmodf((g - b) / delta, 6.0F); - } else if (max == g) { - h = ((b - r) / delta) + 2.0F; - } else { - h = ((r - g) / delta) + 4.0F; - } - h *= 60.0F; - if (h < 0.0F) { - h += 360.0F; - } - } - - float s = (max <= 0.0F) ? 0.0F : delta / max; - float v = max; - - return {h, s, v}; -} - -constexpr auto hsvToRgb(HSV hsv) -> Color { - float c = hsv.v * hsv.s; - float x = c * (1 - std::abs(std::fmod(hsv.h / 60.0F, 2) - 1)); - float m = hsv.v - c; - - float r = 0; - float g = 0; - float b = 0; - - if (hsv.h < 60) { - r = c; - g = x; - b = 0; - } else if (hsv.h < 120) { - r = x; - g = c; - b = 0; - } else if (hsv.h < 180) { - r = 0; - g = c; - b = x; - } else if (hsv.h < 240) { - r = 0; - g = x; - b = c; - } else if (hsv.h < 300) { - r = x; - g = 0; - b = c; - } else { - r = c; - g = 0; - b = x; - } - - return Color( - static_cast(roundf((r + m) * 255)), - static_cast(roundf((g + m) * 255)), - static_cast(roundf((b + m) * 255))); -} - -auto generateMirroredCycle(Color base, ColorCycleStyle style) -> ColorCycle { - ColorCycle result{}; - HSV base_hsv = rgbToHsv(base); - - for (size_t i = 0; i < COLOR_CYCLE_SIZE; ++i) { - float t = static_cast(i) / (COLOR_CYCLE_SIZE - 1); // 0 → 1 - float hue_shift = 0.0F; - float sat_shift = 0.0F; - float val_shift = 0.0F; - - switch (style) { - case ColorCycleStyle::SUBTLE_PULSE: - // Solo brillo suave - val_shift = 0.07F * sinf(t * M_PI); - break; - - case ColorCycleStyle::HUE_WAVE: - // Oscilación leve de tono - hue_shift = 15.0F * (t - 0.5F) * 2.0F; - val_shift = 0.05F * sinf(t * M_PI); - break; - - case ColorCycleStyle::VIBRANT: - // Cambios fuertes en tono y brillo - hue_shift = 35.0F * sinf(t * M_PI); - val_shift = 0.2F * sinf(t * M_PI); - sat_shift = -0.2F * sinf(t * M_PI); - break; - - case ColorCycleStyle::DARKEN_GLOW: - // Se oscurece al centro - val_shift = -0.15F * sinf(t * M_PI); - break; - - case ColorCycleStyle::LIGHT_FLASH: - // Se ilumina al centro - val_shift = 0.25F * sinf(t * M_PI); - break; - } - - HSV adjusted = { - fmodf(base_hsv.h + hue_shift + 360.0F, 360.0F), - fminf(1.0F, fmaxf(0.0F, base_hsv.s + sat_shift)), - fminf(1.0F, fmaxf(0.0F, base_hsv.v + val_shift))}; - - Color c = hsvToRgb(adjusted); - result[i] = c; - result[2 * COLOR_CYCLE_SIZE - 1 - i] = c; // espejo - } - - return result; -} +} \ No newline at end of file diff --git a/source/utils.h b/source/utils.h index 9b7b0e7..1dcc1d0 100644 --- a/source/utils.h +++ b/source/utils.h @@ -2,20 +2,13 @@ #pragma once #include // Para Uint8, SDL_FRect, SDL_FPoint, SDL_Renderer - -#include // Para max, min -#include // Para array -#include // Para isxdigit -#include // Para int32_t -#include // Para size_t, abs -#include // Para invalid_argument -#include // Para string, basic_string, stoi -#include // Para vector +#include // Para int32_t +#include // Para string +#include // Para vector // --- Constantes --- constexpr int BLOCK = 8; constexpr int TOTAL_DEMO_DATA = 2000; -constexpr size_t COLOR_CYCLE_SIZE = 6; // Mitad del ciclo espejado // --- Estructuras y tipos --- struct Overrides { @@ -34,118 +27,6 @@ struct Circle { : x(x_coord), y(y_coord), r(radius) {} }; -// Estructura para definir un color RGBA -struct Color { - private: - static constexpr Uint8 MAX_COLOR_VALUE = 255; - static constexpr Uint8 MIN_COLOR_VALUE = 0; - static constexpr Uint8 DEFAULT_ALPHA = 255; - static constexpr int DEFAULT_LIGHTEN_AMOUNT = 50; - static constexpr int DEFAULT_DARKEN_AMOUNT = 50; - static constexpr int DEFAULT_APPROACH_STEP = 1; - static constexpr size_t HEX_RGB_LENGTH = 6; - static constexpr size_t HEX_RGBA_LENGTH = 8; - static constexpr int HEX_BASE = 16; - static constexpr size_t HEX_COMPONENT_LENGTH = 2; - - public: - Uint8 r, g, b, a; - - constexpr Color() : r(MIN_COLOR_VALUE), g(MIN_COLOR_VALUE), b(MIN_COLOR_VALUE), a(DEFAULT_ALPHA) {} - - explicit constexpr Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha = DEFAULT_ALPHA) - : r(red), g(green), b(blue), a(alpha) {} - - [[nodiscard]] constexpr auto INVERSE() const -> Color { - return Color(MAX_COLOR_VALUE - r, MAX_COLOR_VALUE - g, MAX_COLOR_VALUE - b, a); - } - - [[nodiscard]] constexpr auto LIGHTEN(int amount = DEFAULT_LIGHTEN_AMOUNT) const -> Color { - return Color( - std::min(static_cast(MAX_COLOR_VALUE), r + amount), - std::min(static_cast(MAX_COLOR_VALUE), g + amount), - std::min(static_cast(MAX_COLOR_VALUE), b + amount), - a); - } - - [[nodiscard]] constexpr auto DARKEN(int amount = DEFAULT_DARKEN_AMOUNT) const -> Color { - return Color( - std::max(static_cast(MIN_COLOR_VALUE), r - amount), - std::max(static_cast(MIN_COLOR_VALUE), g - amount), - std::max(static_cast(MIN_COLOR_VALUE), b - amount), - a); - } - - // Método estático para crear Color desde string hexadecimal - static auto fromHex(const std::string &hex_str) -> Color { - std::string hex = hex_str; - - // Quitar '#' si existe - if (!hex.empty() && hex[0] == '#') { - hex = hex.substr(1); - } - - // Verificar longitud válida (6 para RGB o 8 para RGBA) - if (hex.length() != HEX_RGB_LENGTH && hex.length() != HEX_RGBA_LENGTH) { - throw std::invalid_argument("String hexadecimal debe tener 6 o 8 caracteres"); - } - - // Verificar que todos los caracteres sean hexadecimales válidos - for (char c : hex) { - if (std::isxdigit(c) == 0) { - throw std::invalid_argument("String contiene caracteres no hexadecimales"); - } - } - - // Convertir cada par de caracteres a valores RGB(A) - Uint8 r = static_cast(std::stoi(hex.substr(0, HEX_COMPONENT_LENGTH), nullptr, HEX_BASE)); - Uint8 g = static_cast(std::stoi(hex.substr(HEX_COMPONENT_LENGTH, HEX_COMPONENT_LENGTH), nullptr, HEX_BASE)); - Uint8 b = static_cast(std::stoi(hex.substr(HEX_COMPONENT_LENGTH * 2, HEX_COMPONENT_LENGTH), nullptr, HEX_BASE)); - Uint8 a = DEFAULT_ALPHA; // Alpha por defecto - - // Si tiene 8 caracteres, extraer el alpha - if (hex.length() == HEX_RGBA_LENGTH) { - a = static_cast(std::stoi(hex.substr(HEX_COMPONENT_LENGTH * 3, HEX_COMPONENT_LENGTH), nullptr, HEX_BASE)); - } - - return Color(r, g, b, a); - } - - [[nodiscard]] constexpr auto IS_EQUAL_TO(const Color &other) const -> bool { - return r == other.r && g == other.g && b == other.b && a == other.a; - } - - [[nodiscard]] constexpr auto APPROACH_TO(const Color &target, int step = DEFAULT_APPROACH_STEP) const -> Color { - auto approach_component = [step](Uint8 current, Uint8 target_val) -> Uint8 { - if (std::abs(current - target_val) <= step) { - return target_val; - } - return (current < target_val) ? current + step : current - step; - }; - - Uint8 new_r = approach_component(r, target.r); - Uint8 new_g = approach_component(g, target.g); - Uint8 new_b = approach_component(b, target.b); - Uint8 new_a = approach_component(a, target.a); - - return Color(new_r, new_g, new_b, new_a); - } -}; - -// Estructura para definir un color HSV -struct HSV { - float h, s, v; -}; - -// Estructura para definir el ciclo de color -enum class ColorCycleStyle { - SUBTLE_PULSE, // Variación leve en brillo (por defecto) - HUE_WAVE, // Variación suave en tono (sin verde) - VIBRANT, // Cambios agresivos en tono y brillo - DARKEN_GLOW, // Oscurece hacia el centro y regresa - LIGHT_FLASH // Ilumina hacia el centro y regresa -}; - // Posiciones de las notificaciones enum class NotifyPosition { TOP, @@ -193,28 +74,8 @@ struct Zone { float third_quarter_y; // Anclaje al 75% del eje Y }; -// --- Alias --- -using ColorCycle = std::array; - // --- Funciones utilitarias --- -// Colores -constexpr Color NO_TEXT_COLOR = Color(0XFF, 0XFF, 0XFF); -constexpr Color SHADOW_TEXT_COLOR = Color(0X43, 0X43, 0X4F); -constexpr Color TITLE_SHADOW_TEXT_COLOR = Color(0x14, 0x87, 0xc4); - -constexpr Color FLASH_COLOR = Color(0XFF, 0XFF, 0XFF); - -constexpr Color BLUE_SKY_COLOR = Color(0X02, 0X88, 0XD1); -constexpr Color PINK_SKY_COLOR = Color(0XFF, 0X6B, 0X97); -constexpr Color GREEN_SKY_COLOR = Color(0X00, 0X79, 0X6B); - -// Colores y gráficos -auto getColorLikeKnightRider(const std::vector &colors, int counter) -> Color; -constexpr auto rgbToHsv(Color color) -> HSV; -constexpr auto hsvToRgb(HSV hsv) -> Color; -auto generateMirroredCycle(Color base, ColorCycleStyle style = ColorCycleStyle::SUBTLE_PULSE) -> ColorCycle; - // Colisiones y geometría auto distanceSquared(int x1, int y1, int x2, int y2) -> double; auto checkCollision(const Circle &a, const Circle &b) -> bool; @@ -232,10 +93,6 @@ auto trim(const std::string &str) -> std::string; // Dibujo void drawCircle(SDL_Renderer *renderer, int32_t center_x, int32_t center_y, int32_t radius); -// Manipulación de color -auto lightenColor(const Color &color, int amount) -> Color; -auto darkenColor(const Color &color, int amount) -> Color; - // Funciones de suavizado (easing) auto easeOutQuint(double time) -> double; auto easeInQuint(double time) -> double;