style: aplicar readability-uppercase-literal-suffix

- Cambiar todos los literales float de minúscula a mayúscula (1.0f → 1.0F)
- 657 correcciones aplicadas automáticamente con clang-tidy
- Check 1/N completado

🤖 Generated with Claude Code
This commit is contained in:
2025-12-18 13:06:48 +01:00
parent 44cd0857e0
commit bc94eff176
41 changed files with 705 additions and 594 deletions

View File

@@ -60,7 +60,7 @@ inline JA_Music_t* current_music{nullptr};
inline JA_Channel_t channels[JA_MAX_SIMULTANEOUS_CHANNELS];
inline SDL_AudioSpec JA_audioSpec{SDL_AUDIO_S16, 2, 48000};
inline float JA_musicVolume{1.0f};
inline float JA_musicVolume{1.0F};
inline float JA_soundVolume[JA_MAX_GROUPS];
inline bool JA_musicEnabled{true};
inline bool JA_soundEnabled{true};
@@ -69,7 +69,7 @@ inline SDL_AudioDeviceID sdlAudioDevice{0};
inline bool fading{false};
inline int fade_start_time{0};
inline int fade_duration{0};
inline float fade_initial_volume{0.0f}; // Corregido de 'int' a 'float'
inline float fade_initial_volume{0.0F}; // Corregido de 'int' a 'float'
// --- Forward Declarations ---
inline void JA_StopMusic();
@@ -128,7 +128,7 @@ inline void JA_Init(const int freq, const SDL_AudioFormat format, const int num_
sdlAudioDevice = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &JA_audioSpec);
if (sdlAudioDevice == 0) SDL_Log("Failed to initialize SDL audio!");
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; ++i) channels[i].state = JA_CHANNEL_FREE;
for (int i = 0; i < JA_MAX_GROUPS; ++i) JA_soundVolume[i] = 0.5f;
for (int i = 0; i < JA_MAX_GROUPS; ++i) JA_soundVolume[i] = 0.5F;
}
inline void JA_Quit() {
@@ -274,7 +274,7 @@ inline void JA_DeleteMusic(JA_Music_t* music) {
}
inline float JA_SetMusicVolume(float volume) {
JA_musicVolume = SDL_clamp(volume, 0.0f, 1.0f);
JA_musicVolume = SDL_clamp(volume, 0.0F, 1.0F);
if (current_music && current_music->stream) {
SDL_SetAudioStreamGain(current_music->stream, JA_musicVolume);
}
@@ -443,7 +443,7 @@ inline JA_Channel_state JA_GetChannelState(const int channel) {
inline float JA_SetSoundVolume(float volume, const int group = -1) // -1 para todos los grupos
{
const float v = SDL_clamp(volume, 0.0f, 1.0f);
const float v = SDL_clamp(volume, 0.0F, 1.0F);
if (group == -1) {
for (int i = 0; i < JA_MAX_GROUPS; ++i) {

View File

@@ -11,9 +11,9 @@ constexpr int HEIGHT = 480;
constexpr int MIN_WIDTH = 320; // Mínimo: mitad del original
constexpr int MIN_HEIGHT = 240;
// Zoom system
constexpr float BASE_ZOOM = 1.0f; // 640x480 baseline
constexpr float MIN_ZOOM = 0.5f; // 320x240 minimum
constexpr float ZOOM_INCREMENT = 0.1f; // 10% steps (F1/F2)
constexpr float BASE_ZOOM = 1.0F; // 640x480 baseline
constexpr float MIN_ZOOM = 0.5F; // 320x240 minimum
constexpr float ZOOM_INCREMENT = 0.1F; // 10% steps (F1/F2)
} // namespace Window
// Dimensions base del joc (coordenades lògiques)
@@ -28,12 +28,12 @@ namespace Zones {
// Totes les zones definides com a percentatges de Game::WIDTH (640) i Game::HEIGHT (480)
// Percentatges d'alçada (divisió vertical)
constexpr float SCOREBOARD_TOP_HEIGHT_PERCENT = 0.02f; // 10% superior
constexpr float MAIN_PLAYAREA_HEIGHT_PERCENT = 0.88f; // 80% central
constexpr float SCOREBOARD_BOTTOM_HEIGHT_PERCENT = 0.10f; // 10% inferior
constexpr float SCOREBOARD_TOP_HEIGHT_PERCENT = 0.02F; // 10% superior
constexpr float MAIN_PLAYAREA_HEIGHT_PERCENT = 0.88F; // 80% central
constexpr float SCOREBOARD_BOTTOM_HEIGHT_PERCENT = 0.10F; // 10% inferior
// Padding horizontal per a PLAYAREA (dins de MAIN_PLAYAREA)
constexpr float PLAYAREA_PADDING_HORIZONTAL_PERCENT = 0.015f; // 5% a cada costat
constexpr float PLAYAREA_PADDING_HORIZONTAL_PERCENT = 0.015F; // 5% a cada costat
// --- CÀLCULS AUTOMÀTICS DE PÍXELS ---
// Càlculs automàtics a partir dels percentatges
@@ -44,7 +44,7 @@ constexpr float MAIN_PLAYAREA_H = Game::HEIGHT * MAIN_PLAYAREA_HEIGHT_PERCENT;
constexpr float SCOREBOARD_BOTTOM_H = Game::HEIGHT * SCOREBOARD_BOTTOM_HEIGHT_PERCENT;
// Posicions Y
constexpr float SCOREBOARD_TOP_Y = 0.0f;
constexpr float SCOREBOARD_TOP_Y = 0.0F;
constexpr float MAIN_PLAYAREA_Y = SCOREBOARD_TOP_H;
constexpr float SCOREBOARD_BOTTOM_Y = MAIN_PLAYAREA_Y + MAIN_PLAYAREA_H;
@@ -56,7 +56,7 @@ constexpr float PLAYAREA_PADDING_H = Game::WIDTH * PLAYAREA_PADDING_HORIZONTAL_P
// Marcador superior (reservat per a futur ús)
// Ocupa: 10% superior (0-48px)
constexpr SDL_FRect SCOREBOARD_TOP = {
0.0f, // x = 0.0
0.0F, // x = 0.0
SCOREBOARD_TOP_Y, // y = 0.0
static_cast<float>(Game::WIDTH), // w = 640.0
SCOREBOARD_TOP_H // h = 48.0
@@ -65,7 +65,7 @@ constexpr SDL_FRect SCOREBOARD_TOP = {
// Àrea de joc principal (contenidor del 80% central, sense padding)
// Ocupa: 10-90% (48-432px), ample complet
constexpr SDL_FRect MAIN_PLAYAREA = {
0.0f, // x = 0.0
0.0F, // x = 0.0
MAIN_PLAYAREA_Y, // y = 48.0
static_cast<float>(Game::WIDTH), // w = 640.0
MAIN_PLAYAREA_H // h = 384.0
@@ -77,21 +77,21 @@ constexpr SDL_FRect MAIN_PLAYAREA = {
constexpr SDL_FRect PLAYAREA = {
PLAYAREA_PADDING_H, // x = 32.0
MAIN_PLAYAREA_Y, // y = 48.0 (igual que MAIN_PLAYAREA)
Game::WIDTH - 2.0f * PLAYAREA_PADDING_H, // w = 576.0
Game::WIDTH - 2.0F * PLAYAREA_PADDING_H, // w = 576.0
MAIN_PLAYAREA_H // h = 384.0 (igual que MAIN_PLAYAREA)
};
// Marcador inferior (marcador actual)
// Ocupa: 10% inferior (432-480px)
constexpr SDL_FRect SCOREBOARD = {
0.0f, // x = 0.0
0.0F, // x = 0.0
SCOREBOARD_BOTTOM_Y, // y = 432.0
static_cast<float>(Game::WIDTH), // w = 640.0
SCOREBOARD_BOTTOM_H // h = 48.0
};
// Padding horizontal del marcador (per alinear zones esquerra/dreta amb PLAYAREA)
constexpr float SCOREBOARD_PADDING_H = 0.0f; // Game::WIDTH * 0.015f;
constexpr float SCOREBOARD_PADDING_H = 0.0F; // Game::WIDTH * 0.015f;
} // namespace Zones
// Objetos del juego
@@ -100,144 +100,144 @@ constexpr int MAX_ORNIS = 15;
constexpr int MAX_BALES = 3;
constexpr int MAX_IPUNTS = 30;
constexpr float SHIP_RADIUS = 12.0f;
constexpr float ENEMY_RADIUS = 20.0f;
constexpr float BULLET_RADIUS = 3.0f;
constexpr float SHIP_RADIUS = 12.0F;
constexpr float ENEMY_RADIUS = 20.0F;
constexpr float BULLET_RADIUS = 3.0F;
} // namespace Entities
// Ship (nave del jugador)
namespace Ship {
// Invulnerabilidad post-respawn
constexpr float INVULNERABILITY_DURATION = 3.0f; // Segundos de invulnerabilidad
constexpr float INVULNERABILITY_DURATION = 3.0F; // Segundos de invulnerabilidad
// Parpadeo visual durante invulnerabilidad
constexpr float BLINK_VISIBLE_TIME = 0.1f; // Tiempo visible (segundos)
constexpr float BLINK_INVISIBLE_TIME = 0.1f; // Tiempo invisible (segundos)
constexpr float BLINK_VISIBLE_TIME = 0.1F; // Tiempo visible (segundos)
constexpr float BLINK_INVISIBLE_TIME = 0.1F; // Tiempo invisible (segundos)
// Frecuencia total: 0.2s/ciclo = 5 Hz (~15 parpadeos en 3s)
} // namespace Ship
// Game rules (lives, respawn, game over)
namespace Game {
constexpr int STARTING_LIVES = 3; // Initial lives
constexpr float DEATH_DURATION = 3.0f; // Seconds of death animation
constexpr float GAME_OVER_DURATION = 5.0f; // Seconds to display game over
constexpr float COLLISION_SHIP_ENEMY_AMPLIFIER = 0.80f; // 80% hitbox (generous)
constexpr float DEATH_DURATION = 3.0F; // Seconds of death animation
constexpr float GAME_OVER_DURATION = 5.0F; // Seconds to display game over
constexpr float COLLISION_SHIP_ENEMY_AMPLIFIER = 0.80F; // 80% hitbox (generous)
// Friendly fire system
constexpr bool FRIENDLY_FIRE_ENABLED = true; // Activar friendly fire
constexpr float COLLISION_BULLET_PLAYER_AMPLIFIER = 1.0f; // Hitbox exacto (100%)
constexpr float BULLET_GRACE_PERIOD = 0.2f; // Inmunidad post-disparo (s)
constexpr float COLLISION_BULLET_PLAYER_AMPLIFIER = 1.0F; // Hitbox exacto (100%)
constexpr float BULLET_GRACE_PERIOD = 0.2F; // Inmunidad post-disparo (s)
// Transición LEVEL_START (mensajes aleatorios PRE-level)
constexpr float LEVEL_START_DURATION = 3.0f; // Duración total
constexpr float LEVEL_START_TYPING_RATIO = 0.3f; // 30% escribiendo, 70% mostrando
constexpr float LEVEL_START_DURATION = 3.0F; // Duración total
constexpr float LEVEL_START_TYPING_RATIO = 0.3F; // 30% escribiendo, 70% mostrando
// Transición LEVEL_COMPLETED (mensaje "GOOD JOB COMMANDER!")
constexpr float LEVEL_COMPLETED_DURATION = 3.0f; // Duración total
constexpr float LEVEL_COMPLETED_TYPING_RATIO = 0.0f; // 0.0 = sin typewriter (directo)
constexpr float LEVEL_COMPLETED_DURATION = 3.0F; // Duración total
constexpr float LEVEL_COMPLETED_TYPING_RATIO = 0.0F; // 0.0 = sin typewriter (directo)
// Transición INIT_HUD (animación inicial del HUD)
constexpr float INIT_HUD_DURATION = 3.0f; // Duración total del estado
constexpr float INIT_HUD_DURATION = 3.0F; // Duración total del estado
// Ratios de animación (inicio y fin como porcentajes del tiempo total)
// RECT (rectángulo de marges)
constexpr float INIT_HUD_RECT_RATIO_INIT = 0.30f;
constexpr float INIT_HUD_RECT_RATIO_END = 0.85f;
constexpr float INIT_HUD_RECT_RATIO_INIT = 0.30F;
constexpr float INIT_HUD_RECT_RATIO_END = 0.85F;
// SCORE (marcador de puntuación)
constexpr float INIT_HUD_SCORE_RATIO_INIT = 0.60f;
constexpr float INIT_HUD_SCORE_RATIO_END = 0.90f;
constexpr float INIT_HUD_SCORE_RATIO_INIT = 0.60F;
constexpr float INIT_HUD_SCORE_RATIO_END = 0.90F;
// SHIP1 (nave jugador 1)
constexpr float INIT_HUD_SHIP1_RATIO_INIT = 0.0f;
constexpr float INIT_HUD_SHIP1_RATIO_END = 1.0f;
constexpr float INIT_HUD_SHIP1_RATIO_INIT = 0.0F;
constexpr float INIT_HUD_SHIP1_RATIO_END = 1.0F;
// SHIP2 (nave jugador 2)
constexpr float INIT_HUD_SHIP2_RATIO_INIT = 0.20f;
constexpr float INIT_HUD_SHIP2_RATIO_END = 1.0f;
constexpr float INIT_HUD_SHIP2_RATIO_INIT = 0.20F;
constexpr float INIT_HUD_SHIP2_RATIO_END = 1.0F;
// Posición inicial de la nave en INIT_HUD (75% de altura de zona de juego)
constexpr float INIT_HUD_SHIP_START_Y_RATIO = 0.75f; // 75% desde el top de PLAYAREA
constexpr float INIT_HUD_SHIP_START_Y_RATIO = 0.75F; // 75% desde el top de PLAYAREA
// Spawn positions (distribución horizontal para 2 jugadores)
constexpr float P1_SPAWN_X_RATIO = 0.33f; // 33% desde izquierda
constexpr float P2_SPAWN_X_RATIO = 0.67f; // 67% desde izquierda
constexpr float SPAWN_Y_RATIO = 0.75f; // 75% desde arriba
constexpr float P1_SPAWN_X_RATIO = 0.33F; // 33% desde izquierda
constexpr float P2_SPAWN_X_RATIO = 0.67F; // 67% desde izquierda
constexpr float SPAWN_Y_RATIO = 0.75F; // 75% desde arriba
// Continue system behavior
constexpr int CONTINUE_COUNT_START = 9; // Countdown starts at 9
constexpr float CONTINUE_TICK_DURATION = 1.0f; // Seconds per countdown tick
constexpr float CONTINUE_TICK_DURATION = 1.0F; // Seconds per countdown tick
constexpr int MAX_CONTINUES = 3; // Maximum continues per game
constexpr bool INFINITE_CONTINUES = false; // If true, unlimited continues
// Continue screen visual configuration
namespace ContinueScreen {
// "CONTINUE" text
constexpr float CONTINUE_TEXT_SCALE = 2.0f; // Text size
constexpr float CONTINUE_TEXT_Y_RATIO = 0.30f; // 35% from top of PLAYAREA
constexpr float CONTINUE_TEXT_SCALE = 2.0F; // Text size
constexpr float CONTINUE_TEXT_Y_RATIO = 0.30F; // 35% from top of PLAYAREA
// Countdown number (9, 8, 7...)
constexpr float COUNTER_TEXT_SCALE = 4.0f; // Text size (large)
constexpr float COUNTER_TEXT_Y_RATIO = 0.50f; // 50% from top of PLAYAREA
constexpr float COUNTER_TEXT_SCALE = 4.0F; // Text size (large)
constexpr float COUNTER_TEXT_Y_RATIO = 0.50F; // 50% from top of PLAYAREA
// "CONTINUES LEFT: X" text
constexpr float INFO_TEXT_SCALE = 0.7f; // Text size (small)
constexpr float INFO_TEXT_Y_RATIO = 0.75f; // 65% from top of PLAYAREA
constexpr float INFO_TEXT_SCALE = 0.7F; // Text size (small)
constexpr float INFO_TEXT_Y_RATIO = 0.75F; // 65% from top of PLAYAREA
} // namespace ContinueScreen
// Game Over screen visual configuration
namespace GameOverScreen {
constexpr float TEXT_SCALE = 2.0f; // "GAME OVER" text size
constexpr float TEXT_SPACING = 4.0f; // Character spacing
constexpr float TEXT_SCALE = 2.0F; // "GAME OVER" text size
constexpr float TEXT_SPACING = 4.0F; // Character spacing
} // namespace GameOverScreen
// Stage message configuration (LEVEL_START, LEVEL_COMPLETED)
constexpr float STAGE_MESSAGE_Y_RATIO = 0.25f; // 25% from top of PLAYAREA
constexpr float STAGE_MESSAGE_MAX_WIDTH_RATIO = 0.9f; // 90% of PLAYAREA width
constexpr float STAGE_MESSAGE_Y_RATIO = 0.25F; // 25% from top of PLAYAREA
constexpr float STAGE_MESSAGE_MAX_WIDTH_RATIO = 0.9F; // 90% of PLAYAREA width
} // namespace Game
// Física (valores actuales del juego, sincronizados con joc_asteroides.cpp)
namespace Physics {
constexpr float ROTATION_SPEED = 3.14f; // rad/s (~180°/s)
constexpr float ACCELERATION = 400.0f; // px/s²
constexpr float MAX_VELOCITY = 120.0f; // px/s
constexpr float FRICTION = 20.0f; // px/s²
constexpr float ENEMY_SPEED = 2.0f; // unidades/frame
constexpr float BULLET_SPEED = 6.0f; // unidades/frame
constexpr float VELOCITY_SCALE = 20.0f; // factor conversión frame→tiempo
constexpr float ROTATION_SPEED = 3.14F; // rad/s (~180°/s)
constexpr float ACCELERATION = 400.0F; // px/s²
constexpr float MAX_VELOCITY = 120.0F; // px/s
constexpr float FRICTION = 20.0F; // px/s²
constexpr float ENEMY_SPEED = 2.0F; // unidades/frame
constexpr float BULLET_SPEED = 6.0F; // unidades/frame
constexpr float VELOCITY_SCALE = 20.0F; // factor conversión frame→tiempo
// Explosions (debris physics)
namespace Debris {
constexpr float VELOCITAT_BASE = 80.0f; // Velocitat inicial (px/s)
constexpr float VARIACIO_VELOCITAT = 40.0f; // ±variació aleatòria (px/s)
constexpr float ACCELERACIO = -60.0f; // Fricció/desacceleració (px/s²)
constexpr float ROTACIO_MIN = 0.1f; // Rotació mínima (rad/s ~5.7°/s)
constexpr float ROTACIO_MAX = 0.3f; // Rotació màxima (rad/s ~17.2°/s)
constexpr float TEMPS_VIDA = 2.0f; // Duració màxima (segons) - enemy/bullet debris
constexpr float TEMPS_VIDA_NAU = 3.0f; // Ship debris lifetime (matches DEATH_DURATION)
constexpr float SHRINK_RATE = 0.5f; // Reducció de mida (factor/s)
constexpr float VELOCITAT_BASE = 80.0F; // Velocitat inicial (px/s)
constexpr float VARIACIO_VELOCITAT = 40.0F; // ±variació aleatòria (px/s)
constexpr float ACCELERACIO = -60.0F; // Fricció/desacceleració (px/s²)
constexpr float ROTACIO_MIN = 0.1F; // Rotació mínima (rad/s ~5.7°/s)
constexpr float ROTACIO_MAX = 0.3F; // Rotació màxima (rad/s ~17.2°/s)
constexpr float TEMPS_VIDA = 2.0F; // Duració màxima (segons) - enemy/bullet debris
constexpr float TEMPS_VIDA_NAU = 3.0F; // Ship debris lifetime (matches DEATH_DURATION)
constexpr float SHRINK_RATE = 0.5F; // Reducció de mida (factor/s)
// Herència de velocitat angular (trayectorias curvas)
constexpr float FACTOR_HERENCIA_MIN = 0.7f; // Mínimo 70% del drotacio heredat
constexpr float FACTOR_HERENCIA_MAX = 1.0f; // Màxim 100% del drotacio heredat
constexpr float FRICCIO_ANGULAR = 0.5f; // Desacceleració angular (rad/s²)
constexpr float FACTOR_HERENCIA_MIN = 0.7F; // Mínimo 70% del drotacio heredat
constexpr float FACTOR_HERENCIA_MAX = 1.0F; // Màxim 100% del drotacio heredat
constexpr float FRICCIO_ANGULAR = 0.5F; // Desacceleració angular (rad/s²)
// Angular velocity cap for trajectory inheritance
// Excess above this threshold is converted to tangential linear velocity
// Prevents "vortex trap" problem with high-rotation enemies
constexpr float VELOCITAT_ROT_MAX = 1.5f; // rad/s (~86°/s)
constexpr float VELOCITAT_ROT_MAX = 1.5F; // rad/s (~86°/s)
} // namespace Debris
} // namespace Physics
// Matemáticas
namespace Math {
constexpr float PI = 3.14159265359f;
constexpr float PI = 3.14159265359F;
} // namespace Math
// Colores (oscilación para efecto CRT)
namespace Color {
// Frecuencia de oscilación
constexpr float FREQUENCY = 6.0f; // 1 Hz (1 ciclo/segundo)
constexpr float FREQUENCY = 6.0F; // 1 Hz (1 ciclo/segundo)
// Color de líneas (efecto fósforo verde CRT)
constexpr uint8_t LINE_MIN_R = 100; // Verde oscuro
@@ -261,15 +261,15 @@ constexpr uint8_t BACKGROUND_MAX_B = 0;
// Brillantor (control de intensitat per cada tipus d'entitat)
namespace Brightness {
// Brillantor estàtica per entitats de joc (0.0-1.0)
constexpr float NAU = 1.0f; // Màxima visibilitat (jugador)
constexpr float ENEMIC = 0.7f; // 30% més tènue (destaca menys)
constexpr float BALA = 1.0f; // Brillo a tope (màxima visibilitat)
constexpr float NAU = 1.0F; // Màxima visibilitat (jugador)
constexpr float ENEMIC = 0.7F; // 30% més tènue (destaca menys)
constexpr float BALA = 1.0F; // Brillo a tope (màxima visibilitat)
// Starfield: gradient segons distància al centre
// distancia_centre: 0.0 (centre) → 1.0 (vora pantalla)
// brightness = MIN + (MAX - MIN) * distancia_centre
constexpr float STARFIELD_MIN = 0.3f; // Estrelles llunyanes (prop del centre)
constexpr float STARFIELD_MAX = 0.8f; // Estrelles properes (vora pantalla)
constexpr float STARFIELD_MIN = 0.3F; // Estrelles llunyanes (prop del centre)
constexpr float STARFIELD_MAX = 0.8F; // Estrelles properes (vora pantalla)
} // namespace Brightness
// Renderització (V-Sync i altres opcions de render)
@@ -328,68 +328,68 @@ constexpr SDL_Keycode SHOOT = SDLK_LSHIFT;
namespace Enemies {
// Pentagon (esquivador - zigzag evasion)
namespace Pentagon {
constexpr float VELOCITAT = 35.0f; // px/s (slightly slower)
constexpr float CANVI_ANGLE_PROB = 0.20f; // 20% per wall hit (frequent zigzag)
constexpr float CANVI_ANGLE_MAX = 1.0f; // Max random angle change (rad)
constexpr float DROTACIO_MIN = 0.75f; // Min visual rotation (rad/s) [+50%]
constexpr float DROTACIO_MAX = 3.75f; // Max visual rotation (rad/s) [+50%]
constexpr float VELOCITAT = 35.0F; // px/s (slightly slower)
constexpr float CANVI_ANGLE_PROB = 0.20F; // 20% per wall hit (frequent zigzag)
constexpr float CANVI_ANGLE_MAX = 1.0F; // Max random angle change (rad)
constexpr float DROTACIO_MIN = 0.75F; // Min visual rotation (rad/s) [+50%]
constexpr float DROTACIO_MAX = 3.75F; // Max visual rotation (rad/s) [+50%]
constexpr const char* SHAPE_FILE = "enemy_pentagon.shp";
} // namespace Pentagon
// Quadrat (perseguidor - tracks player)
namespace Quadrat {
constexpr float VELOCITAT = 40.0f; // px/s (medium speed)
constexpr float TRACKING_STRENGTH = 0.5f; // Interpolation toward player (0.0-1.0)
constexpr float TRACKING_INTERVAL = 1.0f; // Seconds between angle updates
constexpr float DROTACIO_MIN = 0.3f; // Slow rotation [+50%]
constexpr float DROTACIO_MAX = 1.5f; // [+50%]
constexpr float VELOCITAT = 40.0F; // px/s (medium speed)
constexpr float TRACKING_STRENGTH = 0.5F; // Interpolation toward player (0.0-1.0)
constexpr float TRACKING_INTERVAL = 1.0F; // Seconds between angle updates
constexpr float DROTACIO_MIN = 0.3F; // Slow rotation [+50%]
constexpr float DROTACIO_MAX = 1.5F; // [+50%]
constexpr const char* SHAPE_FILE = "enemy_square.shp";
} // namespace Quadrat
// Molinillo (agressiu - fast straight lines, proximity spin-up)
namespace Molinillo {
constexpr float VELOCITAT = 50.0f; // px/s (fastest)
constexpr float CANVI_ANGLE_PROB = 0.05f; // 5% per wall hit (rare direction change)
constexpr float CANVI_ANGLE_MAX = 0.3f; // Small angle adjustments
constexpr float DROTACIO_MIN = 3.0f; // Base rotation (rad/s) [+50%]
constexpr float DROTACIO_MAX = 6.0f; // [+50%]
constexpr float DROTACIO_PROXIMITY_MULTIPLIER = 3.0f; // Spin-up multiplier when near ship
constexpr float PROXIMITY_DISTANCE = 100.0f; // Distance threshold (px)
constexpr float VELOCITAT = 50.0F; // px/s (fastest)
constexpr float CANVI_ANGLE_PROB = 0.05F; // 5% per wall hit (rare direction change)
constexpr float CANVI_ANGLE_MAX = 0.3F; // Small angle adjustments
constexpr float DROTACIO_MIN = 3.0F; // Base rotation (rad/s) [+50%]
constexpr float DROTACIO_MAX = 6.0F; // [+50%]
constexpr float DROTACIO_PROXIMITY_MULTIPLIER = 3.0F; // Spin-up multiplier when near ship
constexpr float PROXIMITY_DISTANCE = 100.0F; // Distance threshold (px)
constexpr const char* SHAPE_FILE = "enemy_pinwheel.shp";
} // namespace Molinillo
// Animation parameters (shared)
namespace Animation {
// Palpitation
constexpr float PALPITACIO_TRIGGER_PROB = 0.01f; // 1% chance per second
constexpr float PALPITACIO_DURACIO_MIN = 1.0f; // Min duration (seconds)
constexpr float PALPITACIO_DURACIO_MAX = 3.0f; // Max duration (seconds)
constexpr float PALPITACIO_AMPLITUD_MIN = 0.08f; // Min scale variation
constexpr float PALPITACIO_AMPLITUD_MAX = 0.20f; // Max scale variation
constexpr float PALPITACIO_FREQ_MIN = 1.5f; // Min frequency (Hz)
constexpr float PALPITACIO_FREQ_MAX = 3.0f; // Max frequency (Hz)
constexpr float PALPITACIO_TRIGGER_PROB = 0.01F; // 1% chance per second
constexpr float PALPITACIO_DURACIO_MIN = 1.0F; // Min duration (seconds)
constexpr float PALPITACIO_DURACIO_MAX = 3.0F; // Max duration (seconds)
constexpr float PALPITACIO_AMPLITUD_MIN = 0.08F; // Min scale variation
constexpr float PALPITACIO_AMPLITUD_MAX = 0.20F; // Max scale variation
constexpr float PALPITACIO_FREQ_MIN = 1.5F; // Min frequency (Hz)
constexpr float PALPITACIO_FREQ_MAX = 3.0F; // Max frequency (Hz)
// Rotation acceleration
constexpr float ROTACIO_ACCEL_TRIGGER_PROB = 0.02f; // 2% chance per second [4x more frequent]
constexpr float ROTACIO_ACCEL_DURACIO_MIN = 3.0f; // Min transition time
constexpr float ROTACIO_ACCEL_DURACIO_MAX = 8.0f; // Max transition time
constexpr float ROTACIO_ACCEL_MULTIPLIER_MIN = 0.3f; // Min speed multiplier [more dramatic]
constexpr float ROTACIO_ACCEL_MULTIPLIER_MAX = 4.0f; // Max speed multiplier [more dramatic]
constexpr float ROTACIO_ACCEL_TRIGGER_PROB = 0.02F; // 2% chance per second [4x more frequent]
constexpr float ROTACIO_ACCEL_DURACIO_MIN = 3.0F; // Min transition time
constexpr float ROTACIO_ACCEL_DURACIO_MAX = 8.0F; // Max transition time
constexpr float ROTACIO_ACCEL_MULTIPLIER_MIN = 0.3F; // Min speed multiplier [more dramatic]
constexpr float ROTACIO_ACCEL_MULTIPLIER_MAX = 4.0F; // Max speed multiplier [more dramatic]
} // namespace Animation
// Spawn safety and invulnerability system
namespace Spawn {
// Safe spawn distance from player
constexpr float SAFETY_DISTANCE_MULTIPLIER = 3.0f; // 3x ship radius
constexpr float SAFETY_DISTANCE_MULTIPLIER = 3.0F; // 3x ship radius
constexpr float SAFETY_DISTANCE = Defaults::Entities::SHIP_RADIUS * SAFETY_DISTANCE_MULTIPLIER; // 36.0f px
constexpr int MAX_SPAWN_ATTEMPTS = 50; // Max attempts to find safe position
// Invulnerability system
constexpr float INVULNERABILITY_DURATION = 3.0f; // Seconds
constexpr float INVULNERABILITY_BRIGHTNESS_START = 0.3f; // Dim
constexpr float INVULNERABILITY_BRIGHTNESS_END = 0.7f; // Normal (same as Defaults::Brightness::ENEMIC)
constexpr float INVULNERABILITY_SCALE_START = 0.0f; // Invisible
constexpr float INVULNERABILITY_SCALE_END = 1.0f; // Full size
constexpr float INVULNERABILITY_DURATION = 3.0F; // Seconds
constexpr float INVULNERABILITY_BRIGHTNESS_START = 0.3F; // Dim
constexpr float INVULNERABILITY_BRIGHTNESS_END = 0.7F; // Normal (same as Defaults::Brightness::ENEMIC)
constexpr float INVULNERABILITY_SCALE_START = 0.0F; // Invisible
constexpr float INVULNERABILITY_SCALE_END = 1.0F; // Full size
} // namespace Spawn
// Scoring system (puntuació per tipus d'enemic)
@@ -409,33 +409,33 @@ namespace Ships {
// ============================================================
// 1. Escala global de les naus
constexpr float SHIP_BASE_SCALE = 2.5f; // Multiplicador (1.0 = mida original del .shp)
constexpr float SHIP_BASE_SCALE = 2.5F; // Multiplicador (1.0 = mida original del .shp)
// 2. Altura vertical (cercanía al centro)
// Ratio Y desde el centro de la pantalla (0.0 = centro, 1.0 = bottom de pantalla)
constexpr float TARGET_Y_RATIO = 0.15625f;
constexpr float TARGET_Y_RATIO = 0.15625F;
// 3. Radio orbital (distancia radial desde centro en coordenadas polares)
constexpr float CLOCK_RADIUS = 150.0f; // Distància des del centre
constexpr float CLOCK_RADIUS = 150.0F; // Distància des del centre
// 4. Ángulos de posición (clock positions en coordenadas polares)
// En coordenades de pantalla: 0° = dreta, 90° = baix, 180° = esquerra, 270° = dalt
constexpr float CLOCK_8_ANGLE = 150.0f * Math::PI / 180.0f; // 8 o'clock (bottom-left)
constexpr float CLOCK_4_ANGLE = 30.0f * Math::PI / 180.0f; // 4 o'clock (bottom-right)
constexpr float CLOCK_8_ANGLE = 150.0F * Math::PI / 180.0F; // 8 o'clock (bottom-left)
constexpr float CLOCK_4_ANGLE = 30.0F * Math::PI / 180.0F; // 4 o'clock (bottom-right)
// 5. Radio máximo de la forma de la nave (para calcular offset automáticamente)
constexpr float SHIP_MAX_RADIUS = 30.0f; // Radi del cercle circumscrit a ship_starfield.shp
constexpr float SHIP_MAX_RADIUS = 30.0F; // Radi del cercle circumscrit a ship_starfield.shp
// 6. Margen de seguridad para offset de entrada
constexpr float ENTRY_OFFSET_MARGIN = 227.5f; // Para offset total de ~340px (ajustado)
constexpr float ENTRY_OFFSET_MARGIN = 227.5F; // Para offset total de ~340px (ajustado)
// ============================================================
// VALORS DERIVATS (calculats automàticament - NO modificar)
// ============================================================
// Centre de la pantalla (punt de referència)
constexpr float CENTER_X = Game::WIDTH / 2.0f; // 320.0f
constexpr float CENTER_Y = Game::HEIGHT / 2.0f; // 240.0f
constexpr float CENTER_X = Game::WIDTH / 2.0F; // 320.0f
constexpr float CENTER_Y = Game::HEIGHT / 2.0F; // 240.0f
// Posicions target (calculades dinàmicament des dels paràmetres base)
// Nota: std::cos/sin no són constexpr en C++20, però funcionen en runtime
@@ -444,18 +444,18 @@ inline float P1_TARGET_X() {
return CENTER_X + CLOCK_RADIUS * std::cos(CLOCK_8_ANGLE);
}
inline float P1_TARGET_Y() {
return CENTER_Y + (Game::HEIGHT / 2.0f) * TARGET_Y_RATIO;
return CENTER_Y + (Game::HEIGHT / 2.0F) * TARGET_Y_RATIO;
}
inline float P2_TARGET_X() {
return CENTER_X + CLOCK_RADIUS * std::cos(CLOCK_4_ANGLE);
}
inline float P2_TARGET_Y() {
return CENTER_Y + (Game::HEIGHT / 2.0f) * TARGET_Y_RATIO;
return CENTER_Y + (Game::HEIGHT / 2.0F) * TARGET_Y_RATIO;
}
// Escales d'animació (relatives a SHIP_BASE_SCALE)
constexpr float ENTRY_SCALE_START = 1.5f * SHIP_BASE_SCALE; // Entrada: 50% més gran
constexpr float FLOATING_SCALE = 1.0f * SHIP_BASE_SCALE; // Flotant: escala base
constexpr float ENTRY_SCALE_START = 1.5F * SHIP_BASE_SCALE; // Entrada: 50% més gran
constexpr float FLOATING_SCALE = 1.0F * SHIP_BASE_SCALE; // Flotant: escala base
// Offset d'entrada (ajustat automàticament a l'escala)
// Fórmula: (radi màxim de la nau * escala d'entrada) + marge
@@ -470,58 +470,58 @@ constexpr float VANISHING_POINT_Y = CENTER_Y; // 240.0f
// ============================================================
// Durades d'animació
constexpr float ENTRY_DURATION = 2.0f; // Entrada (segons)
constexpr float EXIT_DURATION = 1.0f; // Sortida (segons)
constexpr float ENTRY_DURATION = 2.0F; // Entrada (segons)
constexpr float EXIT_DURATION = 1.0F; // Sortida (segons)
// Flotació (oscil·lació reduïda i diferenciada per nau)
constexpr float FLOAT_AMPLITUDE_X = 4.0f; // Amplitud X (píxels)
constexpr float FLOAT_AMPLITUDE_Y = 2.5f; // Amplitud Y (píxels)
constexpr float FLOAT_AMPLITUDE_X = 4.0F; // Amplitud X (píxels)
constexpr float FLOAT_AMPLITUDE_Y = 2.5F; // Amplitud Y (píxels)
// Freqüències base
constexpr float FLOAT_FREQUENCY_X_BASE = 0.5f; // Hz
constexpr float FLOAT_FREQUENCY_Y_BASE = 0.7f; // Hz
constexpr float FLOAT_PHASE_OFFSET = 1.57f; // π/2 (90°)
constexpr float FLOAT_FREQUENCY_X_BASE = 0.5F; // Hz
constexpr float FLOAT_FREQUENCY_Y_BASE = 0.7F; // Hz
constexpr float FLOAT_PHASE_OFFSET = 1.57F; // π/2 (90°)
// Delays d'entrada (per a entrada escalonada)
constexpr float P1_ENTRY_DELAY = 0.0f; // P1 entra immediatament
constexpr float P2_ENTRY_DELAY = 0.5f; // P2 entra 0.5s després
constexpr float P1_ENTRY_DELAY = 0.0F; // P1 entra immediatament
constexpr float P2_ENTRY_DELAY = 0.5F; // P2 entra 0.5s després
// Delay global abans d'iniciar l'animació d'entrada al estat MAIN
constexpr float ENTRANCE_DELAY = 5.0f; // Temps d'espera abans que les naus entrin
constexpr float ENTRANCE_DELAY = 5.0F; // Temps d'espera abans que les naus entrin
// Multiplicadors de freqüència per a cada nau (variació sutil ±12%)
constexpr float P1_FREQUENCY_MULTIPLIER = 0.88f; // 12% més lenta
constexpr float P2_FREQUENCY_MULTIPLIER = 1.12f; // 12% més ràpida
constexpr float P1_FREQUENCY_MULTIPLIER = 0.88F; // 12% més lenta
constexpr float P2_FREQUENCY_MULTIPLIER = 1.12F; // 12% més ràpida
} // namespace Ships
namespace Layout {
// Posicions verticals (anclatges des del TOP de pantalla lògica, 0.0-1.0)
constexpr float LOGO_POS = 0.20f; // Logo "ORNI"
constexpr float PRESS_START_POS = 0.75f; // "PRESS START TO PLAY"
constexpr float COPYRIGHT1_POS = 0.90f; // Primera línia copyright
constexpr float LOGO_POS = 0.20F; // Logo "ORNI"
constexpr float PRESS_START_POS = 0.75F; // "PRESS START TO PLAY"
constexpr float COPYRIGHT1_POS = 0.90F; // Primera línia copyright
// Separacions relatives (proporció respecte Game::HEIGHT = 480px)
constexpr float LOGO_LINE_SPACING = 0.02f; // Entre "ORNI" i "ATTACK!" (10px)
constexpr float COPYRIGHT_LINE_SPACING = 0.0f; // Entre línies copyright (5px)
constexpr float LOGO_LINE_SPACING = 0.02F; // Entre "ORNI" i "ATTACK!" (10px)
constexpr float COPYRIGHT_LINE_SPACING = 0.0F; // Entre línies copyright (5px)
// Factors d'escala
constexpr float LOGO_SCALE = 0.6f; // Escala "ORNI ATTACK!"
constexpr float PRESS_START_SCALE = 1.0f; // Escala "PRESS START TO PLAY"
constexpr float COPYRIGHT_SCALE = 0.5f; // Escala copyright
constexpr float LOGO_SCALE = 0.6F; // Escala "ORNI ATTACK!"
constexpr float PRESS_START_SCALE = 1.0F; // Escala "PRESS START TO PLAY"
constexpr float COPYRIGHT_SCALE = 0.5F; // Escala copyright
// Espaiat entre caràcters (usat per VectorText)
constexpr float TEXT_SPACING = 2.0f;
constexpr float TEXT_SPACING = 2.0F;
} // namespace Layout
} // namespace Title
// Floating score numbers (números flotants de puntuació)
namespace FloatingScore {
constexpr float LIFETIME = 2.0f; // Duració màxima (segons)
constexpr float VELOCITY_Y = -30.0f; // Velocitat vertical (px/s, negatiu = amunt)
constexpr float VELOCITY_X = 0.0f; // Velocitat horizontal (px/s)
constexpr float SCALE = 0.45f; // Escala del text (0.6 = 60% del marcador)
constexpr float SPACING = 0.0f; // Espaiat entre caràcters
constexpr float LIFETIME = 2.0F; // Duració màxima (segons)
constexpr float VELOCITY_Y = -30.0F; // Velocitat vertical (px/s, negatiu = amunt)
constexpr float VELOCITY_X = 0.0F; // Velocitat horizontal (px/s)
constexpr float SCALE = 0.45F; // Escala del text (0.6 = 60% del marcador)
constexpr float SPACING = 0.0F; // Espaiat entre caràcters
constexpr int MAX_CONCURRENT = 15; // Pool size (= MAX_ORNIS)
} // namespace FloatingScore

View File

@@ -11,8 +11,8 @@
namespace Graphics {
Shape::Shape(const std::string& filepath)
: centre_({0.0f, 0.0f}),
escala_defecte_(1.0f),
: centre_({0.0F, 0.0F}),
escala_defecte_(1.0F),
nom_("unnamed") {
carregar(filepath);
}
@@ -55,7 +55,7 @@ bool Shape::parsejar_fitxer(const std::string& contingut) {
escala_defecte_ = std::stof(extract_value(line));
} catch (...) {
std::cerr << "[Shape] Warning: escala invàlida, usant 1.0" << std::endl;
escala_defecte_ = 1.0f;
escala_defecte_ = 1.0F;
}
} else if (starts_with(line, "center:")) {
parse_center(extract_value(line));
@@ -124,7 +124,7 @@ void Shape::parse_center(const std::string& value) {
centre_.y = std::stof(trim(val.substr(comma + 1)));
} catch (...) {
std::cerr << "[Shape] Warning: centre invàlid, usant (0,0)" << std::endl;
centre_ = {0.0f, 0.0f};
centre_ = {0.0F, 0.0F};
}
}
}

View File

@@ -32,13 +32,13 @@ Starfield::Starfield(SDL_Renderer* renderer,
// Configurar 3 capes amb diferents velocitats i escales
// Capa 0: Fons llunyà (lenta, petita)
capes_.push_back({20.0f, 0.3f, 0.8f, densitat / 3});
capes_.push_back({20.0F, 0.3F, 0.8F, densitat / 3});
// Capa 1: Profunditat mitjana
capes_.push_back({40.0f, 0.5f, 1.2f, densitat / 3});
capes_.push_back({40.0F, 0.5F, 1.2F, densitat / 3});
// Capa 2: Primer pla (ràpida, gran)
capes_.push_back({80.0f, 0.8f, 2.0f, densitat / 3});
capes_.push_back({80.0F, 0.8F, 2.0F, densitat / 3});
// Calcular radi màxim (distància del centre al racó més llunyà)
float dx = std::max(punt_fuga_.x, area_.w - punt_fuga_.x);
@@ -53,7 +53,7 @@ Starfield::Starfield(SDL_Renderer* renderer,
estrella.capa = capa_idx;
// Angle aleatori
estrella.angle = (static_cast<float>(rand()) / RAND_MAX) * 2.0f * Defaults::Math::PI;
estrella.angle = (static_cast<float>(rand()) / RAND_MAX) * 2.0F * Defaults::Math::PI;
// Distància aleatòria (0.0 a 1.0) per omplir tota la pantalla
estrella.distancia_centre = static_cast<float>(rand()) / RAND_MAX;
@@ -71,10 +71,10 @@ Starfield::Starfield(SDL_Renderer* renderer,
// Inicialitzar una estrella (nova o regenerada)
void Starfield::inicialitzar_estrella(Estrella& estrella) {
// Angle aleatori des del punt de fuga cap a fora
estrella.angle = (static_cast<float>(rand()) / RAND_MAX) * 2.0f * Defaults::Math::PI;
estrella.angle = (static_cast<float>(rand()) / RAND_MAX) * 2.0F * Defaults::Math::PI;
// Distància inicial petita (5% del radi màxim) - neix prop del centre
estrella.distancia_centre = 0.05f;
estrella.distancia_centre = 0.05F;
// Posició inicial: molt prop del punt de fuga
float radi = estrella.distancia_centre * radi_max_;
@@ -109,7 +109,7 @@ float Starfield::calcular_brightness(const Estrella& estrella) const {
estrella.distancia_centre;
// Aplicar multiplicador i limitar a 1.0
return std::min(1.0f, brightness_base * multiplicador_brightness_);
return std::min(1.0F, brightness_base * multiplicador_brightness_);
}
// Actualitzar posicions de les estrelles
@@ -141,7 +141,7 @@ void Starfield::actualitzar(float delta_time) {
// Establir multiplicador de brightness
void Starfield::set_brightness(float multiplier) {
multiplicador_brightness_ = std::max(0.0f, multiplier); // Evitar valors negatius
multiplicador_brightness_ = std::max(0.0F, multiplier); // Evitar valors negatius
}
// Dibuixar totes les estrelles
@@ -160,10 +160,10 @@ void Starfield::dibuixar() {
renderer_,
shape_estrella_,
estrella.posicio,
0.0f, // angle (les estrelles no giren)
0.0F, // angle (les estrelles no giren)
escala, // escala dinàmica
true, // dibuixar
1.0f, // progress (sempre visible)
1.0F, // progress (sempre visible)
brightness // brightness dinàmica
);
}

View File

@@ -76,7 +76,7 @@ class Starfield {
SDL_FRect area_; // Àrea activa
float radi_max_; // Distància màxima del centre al límit de pantalla
int densitat_; // Nombre total d'estrelles
float multiplicador_brightness_{1.0f}; // Multiplicador de brillantor (1.0 = default)
float multiplicador_brightness_{1.0F}; // Multiplicador de brillantor (1.0 = default)
};
} // namespace Graphics

View File

@@ -11,8 +11,8 @@
namespace Graphics {
// Constants per a mides base dels caràcters
constexpr float char_width = 20.0f; // Amplada base del caràcter
constexpr float char_height = 40.0f; // Altura base del caràcter
constexpr float char_width = 20.0F; // Amplada base del caràcter
constexpr float char_height = 40.0F; // Altura base del caràcter
VectorText::VectorText(SDL_Renderer* renderer)
: renderer_(renderer) {
@@ -222,8 +222,8 @@ void VectorText::render(const std::string& text, const Punt& posicio, float esca
// Renderizar carácter
// Ajustar X e Y para que posicio represente esquina superior izquierda
// (render_shape espera el centro, así que sumamos la mitad de ancho y altura)
Punt char_pos = {current_x + char_width_scaled / 2.0f, posicio.y + char_height_scaled / 2.0f};
Rendering::render_shape(renderer_, it->second, char_pos, 0.0f, escala, true, 1.0f, brightness);
Punt char_pos = {current_x + char_width_scaled / 2.0F, posicio.y + char_height_scaled / 2.0F};
Rendering::render_shape(renderer_, it->second, char_pos, 0.0F, escala, true, 1.0F, brightness);
// Avanzar posición
current_x += char_width_scaled + spacing_scaled;
@@ -244,8 +244,8 @@ void VectorText::render_centered(const std::string& text, const Punt& centre_pun
// Calcular posició de l'esquina superior esquerra
// restant la meitat de les dimensions del punt central
Punt posicio_esquerra = {
centre_punt.x - (text_width / 2.0f),
centre_punt.y - (text_height / 2.0f)};
centre_punt.x - (text_width / 2.0F),
centre_punt.y - (text_height / 2.0F)};
// Delegar al mètode render() existent
render(text, posicio_esquerra, escala, spacing, brightness);
@@ -253,7 +253,7 @@ void VectorText::render_centered(const std::string& text, const Punt& centre_pun
float VectorText::get_text_width(const std::string& text, float escala, float spacing) const {
if (text.empty()) {
return 0.0f;
return 0.0F;
}
const float char_width_scaled = char_width * escala;

View File

@@ -25,7 +25,7 @@ class VectorText {
// - escala: factor de escala (1.0 = 20×40 px por carácter)
// - spacing: espacio entre caracteres en píxeles (a escala 1.0)
// - brightness: factor de brillantor (0.0-1.0, default 1.0 = màxima brillantor)
void render(const std::string& text, const Punt& posicio, float escala = 1.0f, float spacing = 2.0f, float brightness = 1.0f);
void render(const std::string& text, const Punt& posicio, float escala = 1.0F, float spacing = 2.0F, float brightness = 1.0F);
// Renderizar string centrado en un punto
// - text: cadena a renderizar
@@ -33,13 +33,13 @@ class VectorText {
// - escala: factor de escala (1.0 = 20×40 px por carácter)
// - spacing: espacio entre caracteres en píxeles (a escala 1.0)
// - brightness: factor de brillantor (0.0-1.0, default 1.0 = màxima brillantor)
void render_centered(const std::string& text, const Punt& centre_punt, float escala = 1.0f, float spacing = 2.0f, float brightness = 1.0f);
void render_centered(const std::string& text, const Punt& centre_punt, float escala = 1.0F, float spacing = 2.0F, float brightness = 1.0F);
// Calcular ancho total de un string (útil para centrado)
float get_text_width(const std::string& text, float escala = 1.0f, float spacing = 2.0f) const;
float get_text_width(const std::string& text, float escala = 1.0F, float spacing = 2.0F) const;
// Calcular altura del texto (útil para centrado vertical)
float get_text_height(float escala = 1.0f) const;
float get_text_height(float escala = 1.0F) const;
// Verificar si un carácter está soportado
bool is_supported(char c) const;

View File

@@ -9,7 +9,7 @@ namespace Easing {
// t = progreso normalizado [0.0 - 1.0]
// retorna valor interpolado [0.0 - 1.0]
inline float ease_out_quad(float t) {
return 1.0f - (1.0f - t) * (1.0f - t);
return 1.0F - (1.0F - t) * (1.0F - t);
}
// Ease-in quadratic: empieza lento, acelera
@@ -23,17 +23,17 @@ inline float ease_in_quad(float t) {
// t = progreso normalizado [0.0 - 1.0]
// retorna valor interpolado [0.0 - 1.0]
inline float ease_in_out_quad(float t) {
return (t < 0.5f)
? 2.0f * t * t
: 1.0f - (-2.0f * t + 2.0f) * (-2.0f * t + 2.0f) / 2.0f;
return (t < 0.5F)
? 2.0F * t * t
: 1.0F - (-2.0F * t + 2.0F) * (-2.0F * t + 2.0F) / 2.0F;
}
// Ease-out cubic: desaceleración más suave que quadratic
// t = progreso normalizado [0.0 - 1.0]
// retorna valor interpolado [0.0 - 1.0]
inline float ease_out_cubic(float t) {
float t1 = 1.0f - t;
return 1.0f - t1 * t1 * t1;
float t1 = 1.0F - t;
return 1.0F - t1 * t1 * t1;
}
// Interpolación lineal básica (para referencia)

View File

@@ -10,7 +10,7 @@
namespace Rendering {
ColorOscillator::ColorOscillator()
: accumulated_time_(0.0f) {
: accumulated_time_(0.0F) {
// Inicialitzar amb el color mínim
current_line_color_ = {Defaults::Color::LINE_MIN_R,
Defaults::Color::LINE_MIN_G,
@@ -54,8 +54,8 @@ void ColorOscillator::update(float delta_time) {
float ColorOscillator::calculateOscillationFactor(float time, float frequency) {
// Oscil·lació senoïdal: sin(t * freq * 2π)
// Mapejar de [-1, 1] a [0, 1]
float radians = time * frequency * 2.0f * Defaults::Math::PI;
return (std::sin(radians) + 1.0f) / 2.0f;
float radians = time * frequency * 2.0F * Defaults::Math::PI;
return (std::sin(radians) + 1.0F) / 2.0F;
}
SDL_Color ColorOscillator::interpolateColor(SDL_Color min, SDL_Color max, float factor) {

View File

@@ -6,6 +6,6 @@
namespace Rendering {
// Factor d'escala global (inicialitzat a 1.0 per defecte)
float g_current_scale_factor = 1.0f;
float g_current_scale_factor = 1.0F;
} // namespace Rendering

View File

@@ -9,7 +9,7 @@ namespace Rendering {
// Algorisme de Bresenham per dibuixar línies
// Retorna true si hi ha col·lisió (per Fase 10)
// brightness: factor de brillantor (0.0-1.0, default 1.0 = màxima brillantor)
bool linea(SDL_Renderer* renderer, int x1, int y1, int x2, int y2, bool dibuixar, float brightness = 1.0f);
bool linea(SDL_Renderer* renderer, int x1, int y1, int x2, int y2, bool dibuixar, float brightness = 1.0F);
// [NUEVO] Establir el color global de les línies (oscil·lació)
void setLineColor(SDL_Color color);

View File

@@ -35,15 +35,15 @@ float angle_punt(const Punt& p) {
if (p.y != 0) {
return std::atan(p.x / p.y);
}
return 0.0f;
return 0.0F;
}
void crear_poligon_regular(Poligon& pol, uint8_t n, float r) {
// Crear un polígon regular amb n costats i radi r
// Distribueix els punts uniformement al voltant d'un cercle
float interval = 2.0f * Defaults::Math::PI / n;
float act = 0.0f;
float interval = 2.0F * Defaults::Math::PI / n;
float act = 0.0F;
for (uint8_t i = 0; i < n; i++) {
pol.ipuntx[i].r = r;
@@ -52,15 +52,15 @@ void crear_poligon_regular(Poligon& pol, uint8_t n, float r) {
}
// Inicialitzar propietats del polígon
pol.centre.x = 320.0f;
pol.centre.y = 200.0f;
pol.angle = 0.0f;
pol.centre.x = 320.0F;
pol.centre.y = 200.0F;
pol.angle = 0.0F;
// Convertir velocitat de px/frame a px/s: 2 px/frame × 20 FPS = 40 px/s
pol.velocitat = Defaults::Physics::ENEMY_SPEED * 20.0f;
pol.velocitat = Defaults::Physics::ENEMY_SPEED * 20.0F;
pol.n = n;
// Convertir rotació de rad/frame a rad/s: 0.0785 rad/frame × 20 FPS = 1.57
// rad/s (~90°/s)
pol.drotacio = 0.078539816f * 20.0f;
pol.rotacio = 0.0f;
pol.drotacio = 0.078539816F * 20.0F;
pol.rotacio = 0.0F;
pol.esta = true;
}

View File

@@ -17,7 +17,7 @@
SDLManager::SDLManager()
: finestra_(nullptr),
renderer_(nullptr),
fps_accumulator_(0.0f),
fps_accumulator_(0.0F),
fps_frame_count_(0),
fps_display_(0),
current_width_(Defaults::Window::WIDTH),
@@ -28,7 +28,7 @@ SDLManager::SDLManager()
zoom_factor_(Defaults::Window::BASE_ZOOM),
windowed_width_(Defaults::Window::WIDTH),
windowed_height_(Defaults::Window::HEIGHT),
max_zoom_(1.0f) {
max_zoom_(1.0F) {
// Inicialitzar SDL3
if (!SDL_Init(SDL_INIT_VIDEO)) {
std::cerr << "Error inicialitzant SDL3: " << SDL_GetError() << std::endl;
@@ -81,7 +81,7 @@ SDLManager::SDLManager()
SDLManager::SDLManager(int width, int height, bool fullscreen)
: finestra_(nullptr),
renderer_(nullptr),
fps_accumulator_(0.0f),
fps_accumulator_(0.0F),
fps_frame_count_(0),
fps_display_(0),
current_width_(width),
@@ -92,7 +92,7 @@ SDLManager::SDLManager(int width, int height, bool fullscreen)
zoom_factor_(static_cast<float>(width) / Defaults::Window::WIDTH),
windowed_width_(width),
windowed_height_(height),
max_zoom_(1.0f) {
max_zoom_(1.0F) {
// Inicialitzar SDL3
if (!SDL_Init(SDL_INIT_VIDEO)) {
std::cerr << "Error inicialitzant SDL3: " << SDL_GetError() << std::endl;
@@ -221,7 +221,7 @@ void SDLManager::applyZoom(float new_zoom) {
new_zoom = std::round(new_zoom / Defaults::Window::ZOOM_INCREMENT) * Defaults::Window::ZOOM_INCREMENT;
// No change?
if (std::abs(new_zoom - zoom_factor_) < 0.01f) {
if (std::abs(new_zoom - zoom_factor_) < 0.01F) {
return;
}
@@ -430,10 +430,10 @@ void SDLManager::updateFPS(float delta_time) {
fps_frame_count_++;
// Actualitzar display cada 0.5 segons
if (fps_accumulator_ >= 0.5f) {
if (fps_accumulator_ >= 0.5F) {
fps_display_ = static_cast<int>(fps_frame_count_ / fps_accumulator_);
fps_frame_count_ = 0;
fps_accumulator_ = 0.0f;
fps_accumulator_ = 0.0F;
// Actualitzar títol de la finestra
std::string vsync_state = (Options::rendering.vsync == 1) ? "ON" : "OFF";
@@ -468,7 +468,7 @@ void SDLManager::toggleVSync() {
}
// Reset FPS counter para evitar valores mixtos entre regímenes
fps_accumulator_ = 0.0f;
fps_accumulator_ = 0.0F;
fps_frame_count_ = 0;
// Guardar configuració

View File

@@ -12,7 +12,7 @@ namespace Rendering {
// Helper: aplicar rotació 3D a un punt 2D (assumeix Z=0)
static Punt apply_3d_rotation(float x, float y, const Rotation3D& rot) {
float z = 0.0f; // Tots els punts 2D comencen a Z=0
float z = 0.0F; // Tots els punts 2D comencen a Z=0
// Pitch (rotació eix X): cabeceo arriba/baix
float cos_pitch = std::cos(rot.pitch);
@@ -35,7 +35,7 @@ static Punt apply_3d_rotation(float x, float y, const Rotation3D& rot) {
// Proyecció perspectiva (Z-divide simple)
// Naus volen cap al punt de fuga (320, 240) a "infinit" (Z → +∞)
// Z més gran = més lluny = més petit a pantalla
constexpr float perspective_factor = 500.0f;
constexpr float perspective_factor = 500.0F;
float scale_factor = perspective_factor / (perspective_factor + z2);
return {x3 * scale_factor, y3 * scale_factor};
@@ -87,7 +87,7 @@ void render_shape(SDL_Renderer* renderer,
}
// Si progress < 1.0, no dibuixar (tot o res)
if (progress < 1.0f) {
if (progress < 1.0F) {
return;
}

View File

@@ -19,16 +19,16 @@ struct Rotation3D {
float roll; // Rotació eix Z (alabeo lateral)
Rotation3D()
: pitch(0.0f),
yaw(0.0f),
roll(0.0f) {}
: pitch(0.0F),
yaw(0.0F),
roll(0.0F) {}
Rotation3D(float p, float y, float r)
: pitch(p),
yaw(y),
roll(r) {}
bool has_rotation() const {
return pitch != 0.0f || yaw != 0.0f || roll != 0.0f;
return pitch != 0.0F || yaw != 0.0F || roll != 0.0F;
}
};
@@ -45,10 +45,10 @@ void render_shape(SDL_Renderer* renderer,
const std::shared_ptr<Graphics::Shape>& shape,
const Punt& posicio,
float angle,
float escala = 1.0f,
float escala = 1.0F,
bool dibuixar = true,
float progress = 1.0f,
float brightness = 1.0f,
float progress = 1.0F,
float brightness = 1.0F,
const Rotation3D* rotation_3d = nullptr);
} // namespace Rendering