creat color.h i color.cpp i llevat de utils.h i utils.cpp

This commit is contained in:
2025-07-21 14:43:35 +02:00
parent 087643c71b
commit 8b7b667c60
70 changed files with 529 additions and 570 deletions

View File

@@ -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

View File

@@ -1,10 +1,9 @@
#include "animated_sprite.h"
#include <SDL3/SDL.h> // Para SDL_LogWarn, SDL_LogCategory, SDL_LogError
#include <algorithm> // Para min
#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, ifst...
#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

View File

@@ -1,7 +1,6 @@
#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,7 +1,6 @@
#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

View File

@@ -1,7 +1,6 @@
#include "audio.h"
#include <SDL3/SDL.h> // Para SDL_LogInfo, SDL_LogCategory, SDL_G...
#include <algorithm> // Para clamp
#include "external/jail_audio.h" // Para JA_FadeOutMusic, JA_Init, JA_PauseM...

View File

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

View File

@@ -1,9 +1,8 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint8, Uint16, SDL_FRect, Uint32
#include <array>
#include <memory> // Para shared_ptr, unique_ptr
#include <array> // Para array
#include <memory> // Para allocator, shared_ptr, unique_ptr
#include <string> // Para basic_string, string
#include <vector> // Para vector

View File

@@ -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()

View File

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

View File

@@ -1,7 +1,6 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint8
#include <memory> // Para unique_ptr
#include <string> // Para string

181
source/color.cpp Normal file
View File

@@ -0,0 +1,181 @@
#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
// 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<Uint8>(std::stoi(hex.substr(0, HEX_COMPONENT_LENGTH), nullptr, HEX_BASE));
Uint8 g = static_cast<Uint8>(std::stoi(hex.substr(HEX_COMPONENT_LENGTH, HEX_COMPONENT_LENGTH), nullptr, HEX_BASE));
Uint8 b = static_cast<Uint8>(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<Uint8>(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<Color> &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<uint8_t>(roundf((r + m) * 255)),
static_cast<uint8_t>(roundf((g + m) * 255)),
static_cast<uint8_t>(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<float>(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;
}

116
source/color.h Normal file
View File

@@ -0,0 +1,116 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint8
#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 <vector> // 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<int>(MAX_COLOR_VALUE), r + amount),
std::min(static_cast<int>(MAX_COLOR_VALUE), g + amount),
std::min(static_cast<int>(MAX_COLOR_VALUE), b + amount),
a);
}
[[nodiscard]] constexpr auto DARKEN(int amount = DEFAULT_DARKEN_AMOUNT) const -> Color {
return Color(
std::max(static_cast<int>(MIN_COLOR_VALUE), r - amount),
std::max(static_cast<int>(MIN_COLOR_VALUE), g - amount),
std::max(static_cast<int>(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<Color, 2 * COLOR_CYCLE_SIZE>;
// --- 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<Color> &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;

View File

@@ -1,7 +1,6 @@
#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,19 +1,18 @@
// IWYU pragma: no_include <bits/chrono.h>
#include "director.h"
#include <SDL3/SDL.h> // Para SDL_Scancode, SDL_GamepadButton
#include <SDL3/SDL.h> // Para SDL_Scancode, SDL_GamepadButton, SDL_LogCategory, SDL_LogInfo, SDL_SetLogPriority, SDL_LogPriority, SDL_Quit
#include <sys/stat.h> // Para mkdir, stat, S_IRWXU
#include <unistd.h> // Para getuid
#include <algorithm> // Para min
#include <cerrno> // Para errno, EEXIST, EACCES, ENAMETOOLONG
#include <cstdio> // Para printf, perror
#include <cstdlib> // Para exit, EXIT_FAILURE, size_t, srand
#include <cstdlib> // Para exit, EXIT_FAILURE, size_t, srand, rand, system
#include <ctime> // Para time
#include <memory> // Para make_unique, unique_ptr
#include <span>
#include <span> // Para span
#include <stdexcept> // Para runtime_error
#include <string> // Para operator+, basic_string, allocator
#include <string> // Para operator+, allocator, char_traits, operator==, string, basic_string
#include <vector> // Para vector
#include "asset.h" // Para Asset, AssetType
@@ -21,13 +20,13 @@
#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

View File

@@ -2,7 +2,7 @@
#include <array> // Para array
#include <cstddef> // Para size_t
#include <string> // Para string, basic_string
#include <string> // Para allocator, string
#include "utils.h" // Para trim

View File

@@ -1,13 +1,12 @@
#include "fade.h"
#include <SDL3/SDL.h> // Para SDL_SetRenderTarget, SDL_FRect, SDL_GetRenderT...
#include <SDL3/SDL.h> // 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 <algorithm> // Para min, max
#include <cstdlib> // Para rand, size_t
#include "color.h" // Para Color
#include "param.h" // Para Param, param, ParamGame, ParamFade
#include "screen.h" // Para Screen
#include "utils.h" // Para Color
// Constructor
Fade::Fade()

View File

@@ -1,7 +1,6 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint8, SDL_FRect, SDL_Renderer, SDL_Texture, Uint16
#include <vector> // Para vector
struct Color;

View File

@@ -1,18 +1,17 @@
#include "game_logo.h"
#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
#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;

View File

@@ -1,15 +1,15 @@
#include "global_inputs.h"
#include <string> // Para basic_string, operator+, allocator, cha...
#include <string> // Para operator+, allocator, char_traits, to_string, string
#include <vector> // 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

View File

@@ -1,7 +1,6 @@
#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,7 +1,6 @@
#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,7 +1,6 @@
#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

View File

@@ -1,7 +1,6 @@
#include "manage_hiscore_table.h"
#include <SDL3/SDL.h> // Para SDL_ReadIO, SDL_WriteIO, SDL_CloseIO, SDL_GetE...
#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

View File

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

View File

@@ -1,14 +1,13 @@
#include "options.h"
#include <SDL3/SDL.h> // Para SDL_LogCategory, SDL_LogInfo, SDL_LogError
#include <algorithm> // Para clamp
#include <fstream> // Para basic_ostream, operator<<, basic_ostream::...
#include <SDL3/SDL.h> // Para SDL_GamepadButton, SDL_ScaleMode, SDL_LogCategory, SDL_LogInfo, SDL_LogError, SDL_LogWarn
#include <algorithm> // Para clamp, max
#include <fstream> // Para basic_ostream, operator<<, basic_ostream::operator<<, basic_ofstream, basic_istream, basic_ifstream, ifstream, ofstream
#include <utility> // Para swap
#include <vector> // Para vector
#include "asset.h"
#include "input.h" // Para InputDeviceToUse
#include "asset.h" // Para Asset
#include "input.h" // Para InputDevice
#include "lang.h" // Para Code
#include "utils.h" // Para boolToString, stringToBool, getFileName

View File

@@ -1,7 +1,6 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_GamepadButton, SDL_ScaleMode
#include <algorithm> // Para copy
#include <string> // Para allocator, string
#include <utility> // Para move

View File

@@ -1,7 +1,6 @@
#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
@@ -9,7 +8,8 @@
#include <string> // Para operator==, stoi, char_traits, string, ope...
#include <unordered_map>
#include "utils.h" // Para Zone, Color, NotifyPosition, getFileName
#include "color.h"
#include "utils.h"
Param param;

View File

@@ -1,11 +1,11 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint32, SDL_FRect
#include <array> // Para array
#include <string> // 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 {

View File

@@ -1,7 +1,6 @@
#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,7 +1,6 @@
#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,8 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint32, SDL_FRect
#include <memory> // Para unique_ptr, shared_ptr
#include <string> // Para basic_string, string
#include <memory> // Para allocator, unique_ptr, shared_ptr
#include <string> // Para string
#include <vector> // Para vector
#include "animated_sprite.h" // Para AnimatedSprite

View File

@@ -1,19 +1,19 @@
#include "resource.h"
#include <SDL3/SDL.h> // Para SDL_LogInfo, SDL_LogCategory, SDL_L...
#include <algorithm> // Para find_if
#include <SDL3/SDL.h> // Para SDL_LogInfo, SDL_LogCategory, SDL_LogError, SDL_SetRenderDrawColor, SDL_EventType, SDL_PollEvent, SDL_RenderFillRect, SDL_RenderRect, SDLK_ESCAPE, SDL_Event
#include <algorithm> // Para find_if, max
#include <array> // Para array
#include <cstdlib> // Para exit
#include <stdexcept> // Para runtime_error
#include <utility>
#include <utility> // 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

View File

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

View File

@@ -1,12 +1,12 @@
#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
#include <sstream> // 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

View File

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

View File

@@ -1,22 +1,22 @@
#include "screen.h"
#include <SDL3/SDL.h> // Para SDL_SetRenderTarget, SDL_LogCategory
#include <SDL3/SDL.h> // 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 <algorithm> // Para min, max
#include <fstream> // Para basic_ifstream, ifstream
#include <iterator> // Para istreambuf_iterator, operator==
#include <memory> // Para allocator, shared_ptr, __shared_pt...
#include <string> // Para basic_string, char_traits, operator+
#include <memory> // Para allocator, shared_ptr, make_shared, __shared_ptr_access
#include <string> // 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;

View File

@@ -1,12 +1,11 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_FRect, SDL_HideWindow, SDL_Renderer, SDL_ShowWindow, Uint32, SDL_Texture, SDL_Window
#include <memory> // Para shared_ptr
#include <string> // Para basic_string, string
#include <string> // Para string
#include "color.h" // Para Color
#include "options.h" // Para VideoOptions, video
#include "utils.h" // Para Color
class Notifier;
class ServiceMenu;

View File

@@ -2,7 +2,6 @@
#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
@@ -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";

View File

@@ -1,13 +1,13 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_FRect, Uint32, SDL_Texture, Uint64
#include <memory> // Para unique_ptr, shared_ptr
#include <vector> // 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;

View File

@@ -1,9 +1,8 @@
#include "game.h"
#include <SDL3/SDL.h> // Para SDL_GetTicks, SDL_SetRenderTarget
#include <algorithm> // Para find_if, clamp, find, min
#include <array>
#include <SDL3/SDL.h> // 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 <algorithm> // Para max, find_if, clamp, find, min
#include <array> // Para array
#include <cstdlib> // Para rand, size_t
#include <functional> // Para function
#include <iterator> // Para distance, size
@@ -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

View File

@@ -1,13 +1,11 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_Event, SDL_Renderer, SDL_Texture, Uint64, Uint8
#include <SDL3/SDL.h> // Para SDL_Event, SDL_Renderer, SDL_Texture, Uint64
#include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para string
#include <vector> // 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;

View File

@@ -1,7 +1,6 @@
#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
@@ -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()

View File

@@ -1,13 +1,12 @@
#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 "color.h" // Para Color
#include "path_sprite.h" // Para Path, PathSprite (ptr only)
#include "utils.h" // Para Color
class Background;
class Fade;

View File

@@ -1,7 +1,6 @@
#include "instructions.h"
#include <SDL3/SDL.h> // Para SDL_GetTicks, SDL_SetRenderTarget, SDL_Re...
#include <algorithm> // Para max
#include <array> // Para array
#include <string> // Para basic_string, string
@@ -9,6 +8,7 @@
#include <vector> // 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()

View File

@@ -1,7 +1,6 @@
#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

View File

@@ -1,7 +1,6 @@
#include "intro.h"
#include <SDL3/SDL.h> // 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 <algorithm> // Para max
#include <array> // Para array
#include <functional> // Para function
@@ -10,6 +9,7 @@
#include <utility> // 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,7 +22,7 @@
#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 "utils.h"
#include "writer.h" // Para Writer
#ifdef DEBUG

View File

@@ -1,14 +1,14 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint32, Uint64
#include <SDL3/SDL.h> // Para SDL_Keycode, Uint32, Uint64
#include <stdint.h> // Para uint8_t
#include <memory> // Para unique_ptr
#include <vector> // 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
/*

View File

@@ -1,11 +1,11 @@
#include "logo.h"
#include <SDL3/SDL.h> // Para SDL_GetTicks, SDL_PollEvent, SDL_Event, SDL_FRect
#include <algorithm> // Para max
#include <utility> // 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()

View File

@@ -1,12 +1,11 @@
#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 "utils.h" // Para Color
class Texture;

View File

@@ -1,7 +1,6 @@
#include "title.h"
#include <SDL3/SDL.h> // Para SDL_GetTicks, Uint32, SDL_EventType
#include <algorithm> // Para find_if
#include <cstddef> // Para size_t
#include <iostream> // Para basic_ostream, basic_ostream::operator<<
@@ -9,6 +8,7 @@
#include <vector> // 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;

View File

@@ -1,7 +1,6 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint32
#include <memory> // Para unique_ptr, shared_ptr
#include <string_view>
#include <vector>

View File

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

View File

@@ -2,7 +2,6 @@
#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

View File

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

View File

@@ -1,7 +1,6 @@
#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

View File

@@ -1,14 +1,12 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint8
#include <array>
#include <memory> // Para unique_ptr, shared_ptr
#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 "utils.h"
class Texture;

View File

@@ -2,7 +2,6 @@
#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
@@ -12,9 +11,10 @@
#include <utility>
#include <vector> // 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)

View File

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

View File

@@ -3,10 +3,12 @@
#include <algorithm> // Para max
#include <utility> // 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<Text> element_text, std::shared_ptr<Text> title_text)
: element_text_(std::move(element_text)), title_text_(std::move(title_text)) {}

View File

@@ -1,14 +1,13 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_FRect, Uint32
#include <array>
#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
#include "utils.h" // Para Color
class MenuOption;
// Forward declarations

View File

@@ -1,7 +1,6 @@
#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,12 +1,12 @@
#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
#include "utils.h" // Para stringInVector, Color
#include "color.h" // Para stringInVector, Color
#include "utils.h"
class Sprite;
class Text;

View File

@@ -1,9 +1,9 @@
#pragma once
#include <memory> // Para shared_ptr
#include <string> // Para string, basic_string
#include <string> // Para string
#include "utils.h" // Para Color
#include "color.h" // Para Color
class Text;

View File

@@ -1,36 +1,21 @@
#define _USE_MATH_DEFINES
#include "utils.h"
#include <SDL3/SDL.h> // Para SDL_RenderPoint, SDL_FRect, SDL_CloseIO, SDL_I...
#include <algorithm> // Para min, clamp, find_if_not, find, transform
#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, sinf, fmaxf, fminf, M_PI, fmodf, roundf, sin
#include <compare> // Para operator<
#include <cmath> // Para pow, sin, M_PI, cos
#include <compare> // Para operator<, __synth3way_t
#include <cstdlib> // Para size_t
#include <filesystem> // Para path
#include <stdexcept> // Para runtime_error
#include <string> // Para basic_string, allocator, string, char_traits
#include <string> // Para basic_string, allocator, string, operator==, operator+, char_traits
#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<Color> &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);
@@ -370,127 +337,3 @@ 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<uint8_t>(roundf((r + m) * 255)),
static_cast<uint8_t>(roundf((g + m) * 255)),
static_cast<uint8_t>(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<float>(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;
}

View File

@@ -2,20 +2,13 @@
#pragma once
#include <SDL3/SDL.h> // Para Uint8, SDL_FRect, SDL_FPoint, SDL_Renderer
#include <algorithm> // Para max, min
#include <array> // Para array
#include <cctype> // Para isxdigit
#include <cstdint> // Para int32_t
#include <cstdlib> // Para size_t, abs
#include <stdexcept> // Para invalid_argument
#include <string> // Para string, basic_string, stoi
#include <string> // Para string
#include <vector> // 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<int>(MAX_COLOR_VALUE), r + amount),
std::min(static_cast<int>(MAX_COLOR_VALUE), g + amount),
std::min(static_cast<int>(MAX_COLOR_VALUE), b + amount),
a);
}
[[nodiscard]] constexpr auto DARKEN(int amount = DEFAULT_DARKEN_AMOUNT) const -> Color {
return Color(
std::max(static_cast<int>(MIN_COLOR_VALUE), r - amount),
std::max(static_cast<int>(MIN_COLOR_VALUE), g - amount),
std::max(static_cast<int>(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<Uint8>(std::stoi(hex.substr(0, HEX_COMPONENT_LENGTH), nullptr, HEX_BASE));
Uint8 g = static_cast<Uint8>(std::stoi(hex.substr(HEX_COMPONENT_LENGTH, HEX_COMPONENT_LENGTH), nullptr, HEX_BASE));
Uint8 b = static_cast<Uint8>(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<Uint8>(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<Color, 2 * COLOR_CYCLE_SIZE>;
// --- 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<Color> &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;