diff --git a/.clang-tidy b/.clang-tidy index 7c03a92..983bf47 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,10 @@ Checks: - - readability-* + # Estrategia: Habilitar checks uno por uno, aplicar fix, compilar, commit + # Check 1/N: readability-uppercase-literal-suffix (1.0f → 1.0F) + - readability-uppercase-literal-suffix + + # TODO: Habilitar gradualmente +# - readability-* # - modernize-* # - performance-* # - bugprone-unchecked-optional-access @@ -9,8 +14,6 @@ Checks: # - bugprone-undefined-memory-manipulation # - bugprone-use-after-move # - bugprone-out-of-bound-access - - -readability-identifier-length - - -readability-magic-numbers # - -bugprone-narrowing-conversions # - -performance-enum-size # - -performance-inefficient-string-concatenation diff --git a/CMakeLists.txt b/CMakeLists.txt index d95210f..3c8cdcd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,9 +131,24 @@ endif() # Targets de clang-tidy if(CLANG_TIDY_EXE) + # En macOS, obtener la ruta del SDK para que clang-tidy encuentre los headers del sistema + set(CLANG_TIDY_EXTRA_ARGS "") + if(APPLE) + execute_process( + COMMAND xcrun --show-sdk-path + OUTPUT_VARIABLE MACOS_SDK_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(MACOS_SDK_PATH) + set(CLANG_TIDY_EXTRA_ARGS "--extra-arg=-isysroot${MACOS_SDK_PATH}") + message(STATUS "clang-tidy usará SDK de macOS: ${MACOS_SDK_PATH}") + endif() + endif() + add_custom_target(tidy COMMAND ${CLANG_TIDY_EXE} -p ${CMAKE_BINARY_DIR} + ${CLANG_TIDY_EXTRA_ARGS} --fix --fix-errors ${ALL_SOURCE_FILES} @@ -144,6 +159,7 @@ if(CLANG_TIDY_EXE) add_custom_target(tidy-check COMMAND ${CLANG_TIDY_EXE} -p ${CMAKE_BINARY_DIR} + ${CLANG_TIDY_EXTRA_ARGS} --warnings-as-errors='*' ${ALL_SOURCE_FILES} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} diff --git a/reports/math-report.txt b/reports/math-report.txt new file mode 100644 index 0000000..6273104 --- /dev/null +++ b/reports/math-report.txt @@ -0,0 +1,86 @@ +21 warnings generated. +/Users/sergio/orni/source/core/math/easing.hpp:11:14: error: invalid case style for function 'ease_out_quad' [readability-identifier-naming,-warnings-as-errors] + 11 | inline float ease_out_quad(float t) { + | ^~~~~~~~~~~~~ + | easeOutQuad +/Users/sergio/orni/source/core/math/easing.hpp:12:12: error: floating point literal has suffix 'f', which is not uppercase [readability-uppercase-literal-suffix,-warnings-as-errors] + 12 | return 1.0f - (1.0f - t) * (1.0f - t); + | ^ ~ + | F +/Users/sergio/orni/source/core/math/easing.hpp:12:19: error: '*' has higher precedence than '-'; add parentheses to explicitly specify the order of operations [readability-math-missing-parentheses,-warnings-as-errors] + 12 | return 1.0f - (1.0f - t) * (1.0f - t); + | ^~~~~~~~~~~~~~~~~~~~~~~~ + | ( ) +/Users/sergio/orni/source/core/math/easing.hpp:12:20: error: floating point literal has suffix 'f', which is not uppercase [readability-uppercase-literal-suffix,-warnings-as-errors] + 12 | return 1.0f - (1.0f - t) * (1.0f - t); + | ^ ~ + | F +/Users/sergio/orni/source/core/math/easing.hpp:12:33: error: floating point literal has suffix 'f', which is not uppercase [readability-uppercase-literal-suffix,-warnings-as-errors] + 12 | return 1.0f - (1.0f - t) * (1.0f - t); + | ^ ~ + | F +/Users/sergio/orni/source/core/math/easing.hpp:18:14: error: invalid case style for function 'ease_in_quad' [readability-identifier-naming,-warnings-as-errors] + 18 | inline float ease_in_quad(float t) { + | ^~~~~~~~~~~~ + | easeInQuad +/Users/sergio/orni/source/core/math/easing.hpp:25:14: error: invalid case style for function 'ease_in_out_quad' [readability-identifier-naming,-warnings-as-errors] + 25 | inline float ease_in_out_quad(float t) { + | ^~~~~~~~~~~~~~~~ + | easeInOutQuad +/Users/sergio/orni/source/core/math/easing.hpp:26:17: error: floating point literal has suffix 'f', which is not uppercase [readability-uppercase-literal-suffix,-warnings-as-errors] + 26 | return (t < 0.5f) + | ^ ~ + | F +/Users/sergio/orni/source/core/math/easing.hpp:27:11: error: floating point literal has suffix 'f', which is not uppercase [readability-uppercase-literal-suffix,-warnings-as-errors] + 27 | ? 2.0f * t * t + | ^ ~ + | F +/Users/sergio/orni/source/core/math/easing.hpp:28:11: error: floating point literal has suffix 'f', which is not uppercase [readability-uppercase-literal-suffix,-warnings-as-errors] + 28 | : 1.0f - (-2.0f * t + 2.0f) * (-2.0f * t + 2.0f) / 2.0f; + | ^ ~ + | F +/Users/sergio/orni/source/core/math/easing.hpp:28:18: error: '/' has higher precedence than '-'; add parentheses to explicitly specify the order of operations [readability-math-missing-parentheses,-warnings-as-errors] + 28 | : 1.0f - (-2.0f * t + 2.0f) * (-2.0f * t + 2.0f) / 2.0f; + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ( ) +/Users/sergio/orni/source/core/math/easing.hpp:28:20: error: floating point literal has suffix 'f', which is not uppercase [readability-uppercase-literal-suffix,-warnings-as-errors] + 28 | : 1.0f - (-2.0f * t + 2.0f) * (-2.0f * t + 2.0f) / 2.0f; + | ^ ~ + | F +/Users/sergio/orni/source/core/math/easing.hpp:28:31: error: floating point literal has suffix 'f', which is not uppercase [readability-uppercase-literal-suffix,-warnings-as-errors] + 28 | : 1.0f - (-2.0f * t + 2.0f) * (-2.0f * t + 2.0f) / 2.0f; + | ^ ~ + | F +/Users/sergio/orni/source/core/math/easing.hpp:28:41: error: floating point literal has suffix 'f', which is not uppercase [readability-uppercase-literal-suffix,-warnings-as-errors] + 28 | : 1.0f - (-2.0f * t + 2.0f) * (-2.0f * t + 2.0f) / 2.0f; + | ^ ~ + | F +/Users/sergio/orni/source/core/math/easing.hpp:28:52: error: floating point literal has suffix 'f', which is not uppercase [readability-uppercase-literal-suffix,-warnings-as-errors] + 28 | : 1.0f - (-2.0f * t + 2.0f) * (-2.0f * t + 2.0f) / 2.0f; + | ^ ~ + | F +/Users/sergio/orni/source/core/math/easing.hpp:28:60: error: floating point literal has suffix 'f', which is not uppercase [readability-uppercase-literal-suffix,-warnings-as-errors] + 28 | : 1.0f - (-2.0f * t + 2.0f) * (-2.0f * t + 2.0f) / 2.0f; + | ^ ~ + | F +/Users/sergio/orni/source/core/math/easing.hpp:34:14: error: invalid case style for function 'ease_out_cubic' [readability-identifier-naming,-warnings-as-errors] + 34 | inline float ease_out_cubic(float t) { + | ^~~~~~~~~~~~~~ + | easeOutCubic +/Users/sergio/orni/source/core/math/easing.hpp:35:16: error: floating point literal has suffix 'f', which is not uppercase [readability-uppercase-literal-suffix,-warnings-as-errors] + 35 | float t1 = 1.0f - t; + | ^ ~ + | F +/Users/sergio/orni/source/core/math/easing.hpp:36:12: error: floating point literal has suffix 'f', which is not uppercase [readability-uppercase-literal-suffix,-warnings-as-errors] + 36 | return 1.0f - t1 * t1 * t1; + | ^ ~ + | F +/Users/sergio/orni/source/core/math/easing.hpp:36:19: error: '*' has higher precedence than '-'; add parentheses to explicitly specify the order of operations [readability-math-missing-parentheses,-warnings-as-errors] + 36 | return 1.0f - t1 * t1 * t1; + | ^~~~~~~~~~~~~ + | ( ) +/Users/sergio/orni/source/core/math/easing.hpp:41:20: error: '*' has higher precedence than '+'; add parentheses to explicitly specify the order of operations [readability-math-missing-parentheses,-warnings-as-errors] + 41 | return start + (end - start) * t; + | ^~~~~~~~~~~~~~~~~~ + | ( ) +21 warnings treated as errors diff --git a/source/core/audio/jail_audio.hpp b/source/core/audio/jail_audio.hpp index bfcb03e..582094a 100644 --- a/source/core/audio/jail_audio.hpp +++ b/source/core/audio/jail_audio.hpp @@ -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) { diff --git a/source/core/defaults.hpp b/source/core/defaults.hpp index b5f8784..6f24449 100644 --- a/source/core/defaults.hpp +++ b/source/core/defaults.hpp @@ -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(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(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(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 diff --git a/source/core/graphics/shape.cpp b/source/core/graphics/shape.cpp index 6e194d2..d066112 100644 --- a/source/core/graphics/shape.cpp +++ b/source/core/graphics/shape.cpp @@ -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}; } } } diff --git a/source/core/graphics/starfield.cpp b/source/core/graphics/starfield.cpp index 1ace8fa..f202b1b 100644 --- a/source/core/graphics/starfield.cpp +++ b/source/core/graphics/starfield.cpp @@ -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(rand()) / RAND_MAX) * 2.0f * Defaults::Math::PI; + estrella.angle = (static_cast(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(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(rand()) / RAND_MAX) * 2.0f * Defaults::Math::PI; + estrella.angle = (static_cast(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 ); } diff --git a/source/core/graphics/starfield.hpp b/source/core/graphics/starfield.hpp index 788e69a..5135936 100644 --- a/source/core/graphics/starfield.hpp +++ b/source/core/graphics/starfield.hpp @@ -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 diff --git a/source/core/graphics/vector_text.cpp b/source/core/graphics/vector_text.cpp index dbcde6b..04ba6f3 100644 --- a/source/core/graphics/vector_text.cpp +++ b/source/core/graphics/vector_text.cpp @@ -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; diff --git a/source/core/graphics/vector_text.hpp b/source/core/graphics/vector_text.hpp index a5ba05f..c3d41eb 100644 --- a/source/core/graphics/vector_text.hpp +++ b/source/core/graphics/vector_text.hpp @@ -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; diff --git a/source/core/math/easing.hpp b/source/core/math/easing.hpp index 7bc48d7..9209a11 100644 --- a/source/core/math/easing.hpp +++ b/source/core/math/easing.hpp @@ -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) diff --git a/source/core/rendering/color_oscillator.cpp b/source/core/rendering/color_oscillator.cpp index 792a1d0..99ac2cc 100644 --- a/source/core/rendering/color_oscillator.cpp +++ b/source/core/rendering/color_oscillator.cpp @@ -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) { diff --git a/source/core/rendering/coordinate_transform.cpp b/source/core/rendering/coordinate_transform.cpp index 1b25d1f..4ed2314 100644 --- a/source/core/rendering/coordinate_transform.cpp +++ b/source/core/rendering/coordinate_transform.cpp @@ -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 diff --git a/source/core/rendering/line_renderer.hpp b/source/core/rendering/line_renderer.hpp index 0954eed..cf154a0 100644 --- a/source/core/rendering/line_renderer.hpp +++ b/source/core/rendering/line_renderer.hpp @@ -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); diff --git a/source/core/rendering/primitives.cpp b/source/core/rendering/primitives.cpp index 85f1ec7..1f3fc96 100644 --- a/source/core/rendering/primitives.cpp +++ b/source/core/rendering/primitives.cpp @@ -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; } diff --git a/source/core/rendering/sdl_manager.cpp b/source/core/rendering/sdl_manager.cpp index 5c71b3a..c415960 100644 --- a/source/core/rendering/sdl_manager.cpp +++ b/source/core/rendering/sdl_manager.cpp @@ -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(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(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ó diff --git a/source/core/rendering/shape_renderer.cpp b/source/core/rendering/shape_renderer.cpp index 87ae3ba..8cbc457 100644 --- a/source/core/rendering/shape_renderer.cpp +++ b/source/core/rendering/shape_renderer.cpp @@ -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; } diff --git a/source/core/rendering/shape_renderer.hpp b/source/core/rendering/shape_renderer.hpp index 44b8174..412fc38 100644 --- a/source/core/rendering/shape_renderer.hpp +++ b/source/core/rendering/shape_renderer.hpp @@ -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& 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 diff --git a/source/game/constants.hpp b/source/game/constants.hpp index c87700b..b960ca1 100644 --- a/source/game/constants.hpp +++ b/source/game/constants.hpp @@ -43,7 +43,7 @@ inline void obtenir_limits_zona(float& min_x, float& max_x, float& min_y, float& // Obtenir límits segurs (compensant radi de l'entitat) inline void obtenir_limits_zona_segurs(float radi, float& min_x, float& max_x, float& min_y, float& max_y) { const auto& zona = Defaults::Zones::PLAYAREA; - constexpr float MARGE_SEGURETAT = 10.0f; // Safety margin + constexpr float MARGE_SEGURETAT = 10.0F; // Safety margin min_x = zona.x + radi + MARGE_SEGURETAT; max_x = zona.x + zona.w - radi - MARGE_SEGURETAT; @@ -54,7 +54,7 @@ inline void obtenir_limits_zona_segurs(float radi, float& min_x, float& max_x, f // Obtenir centre de l'àrea de joc inline void obtenir_centre_zona(float& centre_x, float& centre_y) { const auto& zona = Defaults::Zones::PLAYAREA; - centre_x = zona.x + zona.w / 2.0f; - centre_y = zona.y + zona.h / 2.0f; + centre_x = zona.x + zona.w / 2.0F; + centre_y = zona.y + zona.h / 2.0F; } } // namespace Constants diff --git a/source/game/effects/debris_manager.cpp b/source/game/effects/debris_manager.cpp index 6e7c008..d928315 100644 --- a/source/game/effects/debris_manager.cpp +++ b/source/game/effects/debris_manager.cpp @@ -105,7 +105,7 @@ void DebrisManager::explotar(const std::shared_ptr& shape, // 5. Velocitat inicial (base ± variació aleatòria + velocitat heretada) float speed = velocitat_base + - ((std::rand() / static_cast(RAND_MAX)) * 2.0f - 1.0f) * + ((std::rand() / static_cast(RAND_MAX)) * 2.0F - 1.0F) * Defaults::Physics::Debris::VARIACIO_VELOCITAT; // Heredar velocitat de l'objecte original (suma vectorial) @@ -116,7 +116,7 @@ void DebrisManager::explotar(const std::shared_ptr& shape, // 6. Herència de velocitat angular amb cap + conversió d'excés // 6a. Rotació de TRAYECTORIA amb cap + conversió tangencial - if (std::abs(velocitat_angular) > 0.01f) { + if (std::abs(velocitat_angular) > 0.01F) { // FASE 1: Aplicar herència i variació (igual que abans) float factor_herencia = Defaults::Physics::Debris::FACTOR_HERENCIA_MIN + @@ -127,20 +127,20 @@ void DebrisManager::explotar(const std::shared_ptr& shape, float velocitat_ang_heretada = velocitat_angular * factor_herencia; float variacio = - (std::rand() / static_cast(RAND_MAX)) * 0.2f - 0.1f; - velocitat_ang_heretada *= (1.0f + variacio); + (std::rand() / static_cast(RAND_MAX)) * 0.2F - 0.1F; + velocitat_ang_heretada *= (1.0F + variacio); // FASE 2: Aplicar cap i calcular excés constexpr float CAP = Defaults::Physics::Debris::VELOCITAT_ROT_MAX; float abs_ang = std::abs(velocitat_ang_heretada); - float sign_ang = (velocitat_ang_heretada >= 0.0f) ? 1.0f : -1.0f; + float sign_ang = (velocitat_ang_heretada >= 0.0F) ? 1.0F : -1.0F; if (abs_ang > CAP) { // Excés: convertir a velocitat tangencial float excess = abs_ang - CAP; // Radi de la forma (enemics = 20 px) - float radius = 20.0f; + float radius = 20.0F; // Velocitat tangencial = ω_excés × radi float v_tangential = excess * radius; @@ -161,18 +161,18 @@ void DebrisManager::explotar(const std::shared_ptr& shape, debris->velocitat_rot = velocitat_ang_heretada; } } else { - debris->velocitat_rot = 0.0f; // Nave: sin curvas + debris->velocitat_rot = 0.0F; // Nave: sin curvas } // 6b. Rotació VISUAL (proporcional según factor_herencia_visual) - if (factor_herencia_visual > 0.01f && std::abs(velocitat_angular) > 0.01f) { + if (factor_herencia_visual > 0.01F && std::abs(velocitat_angular) > 0.01F) { // Heredar rotación visual con factor proporcional debris->velocitat_rot_visual = debris->velocitat_rot * factor_herencia_visual; // Variació aleatòria petita (±5%) per naturalitat float variacio_visual = - (std::rand() / static_cast(RAND_MAX)) * 0.1f - 0.05f; - debris->velocitat_rot_visual *= (1.0f + variacio_visual); + (std::rand() / static_cast(RAND_MAX)) * 0.1F - 0.05F; + debris->velocitat_rot_visual *= (1.0F + variacio_visual); } else { // Rotació visual aleatòria (factor = 0.0 o sin velocidad angular) debris->velocitat_rot_visual = @@ -187,10 +187,10 @@ void DebrisManager::explotar(const std::shared_ptr& shape, } } - debris->angle_rotacio = 0.0f; + debris->angle_rotacio = 0.0F; // 7. Configurar vida i shrinking - debris->temps_vida = 0.0f; + debris->temps_vida = 0.0F; debris->temps_max = Defaults::Physics::Debris::TEMPS_VIDA; debris->factor_shrink = Defaults::Physics::Debris::SHRINK_RATE; @@ -222,26 +222,26 @@ void DebrisManager::actualitzar(float delta_time) { float speed = std::sqrt(debris.velocitat.x * debris.velocitat.x + debris.velocitat.y * debris.velocitat.y); - if (speed > 1.0f) { + if (speed > 1.0F) { // Calcular direcció normalitzada float dir_x = debris.velocitat.x / speed; float dir_y = debris.velocitat.y / speed; // Aplicar acceleració negativa (fricció) float nova_speed = speed + debris.acceleracio * delta_time; - if (nova_speed < 0.0f) - nova_speed = 0.0f; + if (nova_speed < 0.0F) + nova_speed = 0.0F; debris.velocitat.x = dir_x * nova_speed; debris.velocitat.y = dir_y * nova_speed; } else { // Velocitat molt baixa, aturar - debris.velocitat.x = 0.0f; - debris.velocitat.y = 0.0f; + debris.velocitat.x = 0.0F; + debris.velocitat.y = 0.0F; } // 2b. Rotar vector de velocitat (trayectoria curva) - if (std::abs(debris.velocitat_rot) > 0.01f) { + if (std::abs(debris.velocitat_rot) > 0.01F) { // Calcular angle de rotació aquest frame float dangle = debris.velocitat_rot * delta_time; @@ -257,21 +257,21 @@ void DebrisManager::actualitzar(float delta_time) { } // 2c. Aplicar fricció angular (desacceleració gradual) - if (std::abs(debris.velocitat_rot) > 0.01f) { - float sign = (debris.velocitat_rot > 0) ? 1.0f : -1.0f; + if (std::abs(debris.velocitat_rot) > 0.01F) { + float sign = (debris.velocitat_rot > 0) ? 1.0F : -1.0F; float reduccion = Defaults::Physics::Debris::FRICCIO_ANGULAR * delta_time; debris.velocitat_rot -= sign * reduccion; // Evitar canvi de signe (no pot passar de CW a CCW) if ((debris.velocitat_rot > 0) != (sign > 0)) { - debris.velocitat_rot = 0.0f; + debris.velocitat_rot = 0.0F; } } // 3. Calcular centre del segment - Punt centre = {(debris.p1.x + debris.p2.x) / 2.0f, - (debris.p1.y + debris.p2.y) / 2.0f}; + Punt centre = {(debris.p1.x + debris.p2.x) / 2.0F, + (debris.p1.y + debris.p2.y) / 2.0F}; // 4. Actualitzar posició del centre centre.x += debris.velocitat.x * delta_time; @@ -282,15 +282,15 @@ void DebrisManager::actualitzar(float delta_time) { // 6. Aplicar shrinking (reducció de distància entre punts) float shrink_factor = - 1.0f - (debris.factor_shrink * debris.temps_vida / debris.temps_max); - shrink_factor = std::max(0.0f, shrink_factor); // No negatiu + 1.0F - (debris.factor_shrink * debris.temps_vida / debris.temps_max); + shrink_factor = std::max(0.0F, shrink_factor); // No negatiu // Calcular distància original entre punts float dx = debris.p2.x - debris.p1.x; float dy = debris.p2.y - debris.p1.y; // 7. Reconstruir segment amb nova mida i rotació - float half_length = std::sqrt(dx * dx + dy * dy) * shrink_factor / 2.0f; + float half_length = std::sqrt(dx * dx + dy * dy) * shrink_factor / 2.0F; float original_angle = std::atan2(dy, dx); float new_angle = original_angle + debris.angle_rotacio; @@ -330,8 +330,8 @@ Punt DebrisManager::calcular_direccio_explosio(const Punt& p1, const Punt& p2, const Punt& centre_objecte) const { // 1. Calcular centre del segment - float centro_seg_x = (p1.x + p2.x) / 2.0f; - float centro_seg_y = (p1.y + p2.y) / 2.0f; + float centro_seg_x = (p1.x + p2.x) / 2.0F; + float centro_seg_y = (p1.y + p2.y) / 2.0F; // 2. Calcular vector des del centre de l'objecte cap al centre del segment // Això garanteix que la direcció sempre apunte cap a fora (direcció radial) @@ -340,10 +340,10 @@ Punt DebrisManager::calcular_direccio_explosio(const Punt& p1, // 3. Normalitzar (obtenir vector unitari) float length = std::sqrt(dx * dx + dy * dy); - if (length < 0.001f) { + if (length < 0.001F) { // Segment al centre (cas extrem molt improbable), retornar direcció aleatòria float angle_rand = - (std::rand() / static_cast(RAND_MAX)) * 2.0f * Defaults::Math::PI; + (std::rand() / static_cast(RAND_MAX)) * 2.0F * Defaults::Math::PI; return {std::cos(angle_rand), std::sin(angle_rand)}; } @@ -352,7 +352,7 @@ Punt DebrisManager::calcular_direccio_explosio(const Punt& p1, // 4. Afegir variació aleatòria petita (±15°) per varietat visual float angle_variacio = - ((std::rand() % 30) - 15) * Defaults::Math::PI / 180.0f; + ((std::rand() % 30) - 15) * Defaults::Math::PI / 180.0F; float cos_v = std::cos(angle_variacio); float sin_v = std::sin(angle_variacio); diff --git a/source/game/effects/debris_manager.hpp b/source/game/effects/debris_manager.hpp index 1697e9e..35d97b6 100644 --- a/source/game/effects/debris_manager.hpp +++ b/source/game/effects/debris_manager.hpp @@ -34,10 +34,10 @@ class DebrisManager { float angle, float escala, float velocitat_base, - float brightness = 1.0f, - const Punt& velocitat_objecte = {0.0f, 0.0f}, - float velocitat_angular = 0.0f, - float factor_herencia_visual = 0.0f, + float brightness = 1.0F, + const Punt& velocitat_objecte = {0.0F, 0.0F}, + float velocitat_angular = 0.0F, + float factor_herencia_visual = 0.0F, const std::string& sound = Defaults::Sound::EXPLOSION); // Actualitzar tots els fragments actius diff --git a/source/game/effects/gestor_puntuacio_flotant.cpp b/source/game/effects/gestor_puntuacio_flotant.cpp index 6cc29ac..3baf033 100644 --- a/source/game/effects/gestor_puntuacio_flotant.cpp +++ b/source/game/effects/gestor_puntuacio_flotant.cpp @@ -26,9 +26,9 @@ void GestorPuntuacioFlotant::crear(int punts, const Punt& posicio) { pf->posicio = posicio; pf->velocitat = {Defaults::FloatingScore::VELOCITY_X, Defaults::FloatingScore::VELOCITY_Y}; - pf->temps_vida = 0.0f; + pf->temps_vida = 0.0F; pf->temps_max = Defaults::FloatingScore::LIFETIME; - pf->brightness = 1.0f; + pf->brightness = 1.0F; pf->actiu = true; } @@ -46,7 +46,7 @@ void GestorPuntuacioFlotant::actualitzar(float delta_time) { // 3. Calcular brightness (fade lineal) float progress = pf.temps_vida / pf.temps_max; // 0.0 → 1.0 - pf.brightness = 1.0f - progress; // 1.0 → 0.0 + pf.brightness = 1.0F - progress; // 1.0 → 0.0 // 4. Desactivar quan acaba el temps if (pf.temps_vida >= pf.temps_max) { diff --git a/source/game/entities/bala.cpp b/source/game/entities/bala.cpp index c1d288e..db4580c 100644 --- a/source/game/entities/bala.cpp +++ b/source/game/entities/bala.cpp @@ -15,11 +15,11 @@ Bala::Bala(SDL_Renderer* renderer) : renderer_(renderer), - centre_({0.0f, 0.0f}), - angle_(0.0f), - velocitat_(0.0f), + centre_({0.0F, 0.0F}), + angle_(0.0F), + velocitat_(0.0F), esta_(false), - grace_timer_(0.0f), + grace_timer_(0.0F), brightness_(Defaults::Brightness::BALA) { // [NUEVO] Carregar forma compartida des de fitxer forma_ = Graphics::ShapeLoader::load("bullet.shp"); @@ -32,10 +32,10 @@ Bala::Bala(SDL_Renderer* renderer) void Bala::inicialitzar() { // Inicialment inactiva esta_ = false; - centre_ = {0.0f, 0.0f}; - angle_ = 0.0f; - velocitat_ = 0.0f; - grace_timer_ = 0.0f; + centre_ = {0.0F, 0.0F}; + angle_ = 0.0F; + velocitat_ = 0.0F; + grace_timer_ = 0.0F; } void Bala::disparar(const Punt& posicio, float angle, uint8_t owner_id) { @@ -57,7 +57,7 @@ void Bala::disparar(const Punt& posicio, float angle, uint8_t owner_id) { // Velocitat alta (el joc Pascal original usava 7 px/frame) // 7 px/frame × 20 FPS = 140 px/s - velocitat_ = 140.0f; + velocitat_ = 140.0F; // Activar grace period (prevents instant self-collision) grace_timer_ = Defaults::Game::BULLET_GRACE_PERIOD; @@ -69,10 +69,10 @@ void Bala::disparar(const Punt& posicio, float angle, uint8_t owner_id) { void Bala::actualitzar(float delta_time) { if (esta_) { // Decrementar grace timer - if (grace_timer_ > 0.0f) { + if (grace_timer_ > 0.0F) { grace_timer_ -= delta_time; - if (grace_timer_ < 0.0f) { - grace_timer_ = 0.0f; + if (grace_timer_ < 0.0F) { + grace_timer_ = 0.0F; } } @@ -84,7 +84,7 @@ void Bala::dibuixar() const { if (esta_ && forma_) { // [NUEVO] Usar render_shape en lloc de rota_pol // Les bales roten segons l'angle de trajectòria - Rendering::render_shape(renderer_, forma_, centre_, angle_, 1.0f, true, 1.0f, brightness_); + Rendering::render_shape(renderer_, forma_, centre_, angle_, 1.0F, true, 1.0F, brightness_); } } @@ -98,8 +98,8 @@ void Bala::mou(float delta_time) { float velocitat_efectiva = velocitat_ * delta_time; // Calcular desplaçament (angle-PI/2 perquè angle=0 apunta amunt) - float dy = velocitat_efectiva * std::sin(angle_ - Constants::PI / 2.0f); - float dx = velocitat_efectiva * std::cos(angle_ - Constants::PI / 2.0f); + float dy = velocitat_efectiva * std::sin(angle_ - Constants::PI / 2.0F); + float dx = velocitat_efectiva * std::cos(angle_ - Constants::PI / 2.0F); // Acumulació directa amb precisió subpíxel centre_.y += dy; diff --git a/source/game/entities/enemic.cpp b/source/game/entities/enemic.cpp index d9ab819..f5a9332 100644 --- a/source/game/entities/enemic.cpp +++ b/source/game/entities/enemic.cpp @@ -15,18 +15,18 @@ Enemic::Enemic(SDL_Renderer* renderer) : renderer_(renderer), - centre_({0.0f, 0.0f}), - angle_(0.0f), - velocitat_(0.0f), - drotacio_(0.0f), - rotacio_(0.0f), + centre_({0.0F, 0.0F}), + angle_(0.0F), + velocitat_(0.0F), + drotacio_(0.0F), + rotacio_(0.0F), esta_(false), brightness_(Defaults::Brightness::ENEMIC), tipus_(TipusEnemic::PENTAGON), - tracking_timer_(0.0f), + tracking_timer_(0.0F), ship_position_(nullptr), - tracking_strength_(0.5f), // Default tracking strength - timer_invulnerabilitat_(0.0f) { // Start vulnerable + tracking_strength_(0.5F), // Default tracking strength + timer_invulnerabilitat_(0.0F) { // Start vulnerable // [NUEVO] Forma es carrega a inicialitzar() segons el tipus // Constructor no carrega forma per permetre tipus diferents } @@ -52,7 +52,7 @@ void Enemic::inicialitzar(TipusEnemic tipus, const Punt* ship_pos) { velocitat_ = Defaults::Enemies::Quadrat::VELOCITAT; drotacio_min = Defaults::Enemies::Quadrat::DROTACIO_MIN; drotacio_max = Defaults::Enemies::Quadrat::DROTACIO_MAX; - tracking_timer_ = 0.0f; + tracking_timer_ = 0.0F; break; case TipusEnemic::MOLINILLO: @@ -111,18 +111,18 @@ void Enemic::inicialitzar(TipusEnemic tipus, const Punt* ship_pos) { } // Angle aleatori de moviment - angle_ = (std::rand() % 360) * Constants::PI / 180.0f; + angle_ = (std::rand() % 360) * Constants::PI / 180.0F; // Rotació visual aleatòria (rad/s) dins del rang del tipus float drotacio_range = drotacio_max - drotacio_min; drotacio_ = drotacio_min + (static_cast(std::rand()) / RAND_MAX) * drotacio_range; - rotacio_ = 0.0f; + rotacio_ = 0.0F; // Inicialitzar estat d'animació animacio_ = AnimacioEnemic(); // Reset to defaults animacio_.drotacio_base = drotacio_; animacio_.drotacio_objetivo = drotacio_; - animacio_.drotacio_t = 1.0f; // Start without interpolating + animacio_.drotacio_t = 1.0F; // Start without interpolating // [NEW] Inicialitzar invulnerabilitat timer_invulnerabilitat_ = Defaults::Enemies::Spawn::INVULNERABILITY_DURATION; // 3.0s @@ -135,17 +135,17 @@ void Enemic::inicialitzar(TipusEnemic tipus, const Punt* ship_pos) { void Enemic::actualitzar(float delta_time) { if (esta_) { // [NEW] Update invulnerability timer and brightness - if (timer_invulnerabilitat_ > 0.0f) { + if (timer_invulnerabilitat_ > 0.0F) { timer_invulnerabilitat_ -= delta_time; - if (timer_invulnerabilitat_ < 0.0f) { - timer_invulnerabilitat_ = 0.0f; + if (timer_invulnerabilitat_ < 0.0F) { + timer_invulnerabilitat_ = 0.0F; } // [NEW] Update brightness with LERP during invulnerability float t_inv = timer_invulnerabilitat_ / Defaults::Enemies::Spawn::INVULNERABILITY_DURATION; - float t = 1.0f - t_inv; // 0.0 → 1.0 - float smooth_t = t * t * (3.0f - 2.0f * t); // smoothstep + float t = 1.0F - t_inv; // 0.0 → 1.0 + float smooth_t = t * t * (3.0F - 2.0F * t); // smoothstep constexpr float START = Defaults::Enemies::Spawn::INVULNERABILITY_BRIGHTNESS_START; constexpr float END = Defaults::Enemies::Spawn::INVULNERABILITY_BRIGHTNESS_END; @@ -169,7 +169,7 @@ void Enemic::dibuixar() const { float escala = calcular_escala_actual(); // brightness_ is already updated in actualitzar() - Rendering::render_shape(renderer_, forma_, centre_, rotacio_, escala, true, 1.0f, brightness_); + Rendering::render_shape(renderer_, forma_, centre_, rotacio_, escala, true, 1.0F, brightness_); } } @@ -195,8 +195,8 @@ void Enemic::comportament_pentagon(float delta_time) { float velocitat_efectiva = velocitat_ * delta_time; // Calcular desplaçament (angle-PI/2 perquè angle=0 apunta amunt) - float dy = velocitat_efectiva * std::sin(angle_ - Constants::PI / 2.0f); - float dx = velocitat_efectiva * std::cos(angle_ - Constants::PI / 2.0f); + float dy = velocitat_efectiva * std::sin(angle_ - Constants::PI / 2.0F); + float dx = velocitat_efectiva * std::cos(angle_ - Constants::PI / 2.0F); float new_y = centre_.y + dy; float new_x = centre_.x + dx; @@ -240,20 +240,20 @@ void Enemic::comportament_quadrat(float delta_time) { // Periodically update angle toward ship if (tracking_timer_ >= Defaults::Enemies::Quadrat::TRACKING_INTERVAL) { - tracking_timer_ = 0.0f; + tracking_timer_ = 0.0F; if (ship_position_) { // Calculate angle to ship float dx = ship_position_->x - centre_.x; float dy = ship_position_->y - centre_.y; - float target_angle = std::atan2(dy, dx) + Constants::PI / 2.0f; + float target_angle = std::atan2(dy, dx) + Constants::PI / 2.0F; // Interpolate toward target angle float angle_diff = target_angle - angle_; // Normalize angle difference to [-π, π] - while (angle_diff > Constants::PI) angle_diff -= 2.0f * Constants::PI; - while (angle_diff < -Constants::PI) angle_diff += 2.0f * Constants::PI; + while (angle_diff > Constants::PI) angle_diff -= 2.0F * Constants::PI; + while (angle_diff < -Constants::PI) angle_diff += 2.0F * Constants::PI; // Apply tracking strength (uses member variable, defaults to 0.5) angle_ += angle_diff * tracking_strength_; @@ -262,8 +262,8 @@ void Enemic::comportament_quadrat(float delta_time) { // Move in current direction float velocitat_efectiva = velocitat_ * delta_time; - float dy = velocitat_efectiva * std::sin(angle_ - Constants::PI / 2.0f); - float dx = velocitat_efectiva * std::cos(angle_ - Constants::PI / 2.0f); + float dy = velocitat_efectiva * std::sin(angle_ - Constants::PI / 2.0F); + float dx = velocitat_efectiva * std::cos(angle_ - Constants::PI / 2.0F); float new_y = centre_.y + dy; float new_x = centre_.x + dx; @@ -311,8 +311,8 @@ void Enemic::comportament_molinillo(float delta_time) { // Fast straight-line movement float velocitat_efectiva = velocitat_ * delta_time; - float dy = velocitat_efectiva * std::sin(angle_ - Constants::PI / 2.0f); - float dx = velocitat_efectiva * std::cos(angle_ - Constants::PI / 2.0f); + float dy = velocitat_efectiva * std::sin(angle_ - Constants::PI / 2.0F); + float dx = velocitat_efectiva * std::cos(angle_ - Constants::PI / 2.0F); float new_y = centre_.y + dy; float new_x = centre_.x + dx; @@ -355,13 +355,13 @@ void Enemic::actualitzar_animacio(float delta_time) { void Enemic::actualitzar_palpitacio(float delta_time) { if (animacio_.palpitacio_activa) { // Advance phase (2π * frequency * dt) - animacio_.palpitacio_fase += 2.0f * Constants::PI * animacio_.palpitacio_frequencia * delta_time; + animacio_.palpitacio_fase += 2.0F * Constants::PI * animacio_.palpitacio_frequencia * delta_time; // Decrement timer animacio_.palpitacio_temps_restant -= delta_time; // Deactivate when timer expires - if (animacio_.palpitacio_temps_restant <= 0.0f) { + if (animacio_.palpitacio_temps_restant <= 0.0F) { animacio_.palpitacio_activa = false; } } else { @@ -372,7 +372,7 @@ void Enemic::actualitzar_palpitacio(float delta_time) { if (rand_val < trigger_prob) { // Activate palpitation animacio_.palpitacio_activa = true; - animacio_.palpitacio_fase = 0.0f; + animacio_.palpitacio_fase = 0.0F; // Randomize parameters float freq_range = Defaults::Enemies::Animation::PALPITACIO_FREQ_MAX - @@ -394,18 +394,18 @@ void Enemic::actualitzar_palpitacio(float delta_time) { } void Enemic::actualitzar_rotacio_accelerada(float delta_time) { - if (animacio_.drotacio_t < 1.0f) { + if (animacio_.drotacio_t < 1.0F) { // Transitioning to new target animacio_.drotacio_t += delta_time / animacio_.drotacio_duracio; - if (animacio_.drotacio_t >= 1.0f) { - animacio_.drotacio_t = 1.0f; + if (animacio_.drotacio_t >= 1.0F) { + animacio_.drotacio_t = 1.0F; animacio_.drotacio_base = animacio_.drotacio_objetivo; // Reached target drotacio_ = animacio_.drotacio_base; } else { // Smoothstep interpolation: t² * (3 - 2t) float t = animacio_.drotacio_t; - float smooth_t = t * t * (3.0f - 2.0f * t); + float smooth_t = t * t * (3.0F - 2.0F * t); // Interpolate between base and target float initial = animacio_.drotacio_base; @@ -419,7 +419,7 @@ void Enemic::actualitzar_rotacio_accelerada(float delta_time) { if (rand_val < trigger_prob) { // Start new transition - animacio_.drotacio_t = 0.0f; + animacio_.drotacio_t = 0.0F; // Randomize target speed (multiplier * base) float mult_range = Defaults::Enemies::Animation::ROTACIO_ACCEL_MULTIPLIER_MAX - @@ -439,16 +439,16 @@ void Enemic::actualitzar_rotacio_accelerada(float delta_time) { } float Enemic::calcular_escala_actual() const { - float escala = 1.0f; + float escala = 1.0F; // [NEW] Invulnerability LERP prioritza sobre palpitació - if (timer_invulnerabilitat_ > 0.0f) { + if (timer_invulnerabilitat_ > 0.0F) { // Calculate t: 0.0 at spawn → 1.0 at end float t_inv = timer_invulnerabilitat_ / Defaults::Enemies::Spawn::INVULNERABILITY_DURATION; - float t = 1.0f - t_inv; // 0.0 → 1.0 + float t = 1.0F - t_inv; // 0.0 → 1.0 // Apply smoothstep: t² * (3 - 2t) - float smooth_t = t * t * (3.0f - 2.0f * t); + float smooth_t = t * t * (3.0F - 2.0F * t); // LERP scale from 0.0 to 1.0 constexpr float START = Defaults::Enemies::Spawn::INVULNERABILITY_SCALE_START; @@ -473,12 +473,12 @@ float Enemic::get_base_velocity() const { case TipusEnemic::MOLINILLO: return Defaults::Enemies::Molinillo::VELOCITAT; } - return 0.0f; + return 0.0F; } float Enemic::get_base_rotation() const { // Return the base rotation speed (drotacio_base if available, otherwise current drotacio_) - return animacio_.drotacio_base != 0.0f ? animacio_.drotacio_base : drotacio_; + return animacio_.drotacio_base != 0.0F ? animacio_.drotacio_base : drotacio_; } void Enemic::set_tracking_strength(float strength) { diff --git a/source/game/entities/enemic.hpp b/source/game/entities/enemic.hpp index f31b274..fed471a 100644 --- a/source/game/entities/enemic.hpp +++ b/source/game/entities/enemic.hpp @@ -22,16 +22,16 @@ enum class TipusEnemic : uint8_t { struct AnimacioEnemic { // Palpitation (breathing effect) bool palpitacio_activa = false; - float palpitacio_fase = 0.0f; // Phase in cycle (0.0-2π) - float palpitacio_frequencia = 2.0f; // Hz (cycles per second) - float palpitacio_amplitud = 0.15f; // Scale variation (±15%) - float palpitacio_temps_restant = 0.0f; // Time remaining (seconds) + float palpitacio_fase = 0.0F; // Phase in cycle (0.0-2π) + float palpitacio_frequencia = 2.0F; // Hz (cycles per second) + float palpitacio_amplitud = 0.15F; // Scale variation (±15%) + float palpitacio_temps_restant = 0.0F; // Time remaining (seconds) // Rotation acceleration (long-term spin modulation) - float drotacio_base = 0.0f; // Base rotation speed (rad/s) - float drotacio_objetivo = 0.0f; // Target rotation speed (rad/s) - float drotacio_t = 0.0f; // Interpolation progress (0.0-1.0) - float drotacio_duracio = 0.0f; // Duration of transition (seconds) + float drotacio_base = 0.0F; // Base rotation speed (rad/s) + float drotacio_objetivo = 0.0F; // Target rotation speed (rad/s) + float drotacio_t = 0.0F; // Interpolation progress (0.0-1.0) + float drotacio_duracio = 0.0F; // Duration of transition (seconds) }; class Enemic { @@ -53,8 +53,8 @@ class Enemic { float get_drotacio() const { return drotacio_; } Punt get_velocitat_vector() const { return { - velocitat_ * std::cos(angle_ - Constants::PI / 2.0f), - velocitat_ * std::sin(angle_ - Constants::PI / 2.0f)}; + velocitat_ * std::cos(angle_ - Constants::PI / 2.0F), + velocitat_ * std::sin(angle_ - Constants::PI / 2.0F)}; } // Set ship position reference for tracking behavior @@ -74,7 +74,7 @@ class Enemic { void set_tracking_strength(float strength); // [NEW] Invulnerability queries - bool es_invulnerable() const { return timer_invulnerabilitat_ > 0.0f; } + bool es_invulnerable() const { return timer_invulnerabilitat_ > 0.0F; } float get_temps_invulnerabilitat() const { return timer_invulnerabilitat_; } private: diff --git a/source/game/entities/nau.cpp b/source/game/entities/nau.cpp index 1fba668..f63d6d3 100644 --- a/source/game/entities/nau.cpp +++ b/source/game/entities/nau.cpp @@ -17,12 +17,12 @@ Nau::Nau(SDL_Renderer* renderer, const char* shape_file) : renderer_(renderer), - centre_({0.0f, 0.0f}), - angle_(0.0f), - velocitat_(0.0f), + centre_({0.0F, 0.0F}), + angle_(0.0F), + velocitat_(0.0F), esta_tocada_(false), brightness_(Defaults::Brightness::NAU), - invulnerable_timer_(0.0f) { + invulnerable_timer_(0.0F) { // [NUEVO] Carregar forma compartida des de fitxer forma_ = Graphics::ShapeLoader::load(shape_file); @@ -52,14 +52,14 @@ void Nau::inicialitzar(const Punt* spawn_point, bool activar_invulnerabilitat) { } // Estat inicial - angle_ = 0.0f; - velocitat_ = 0.0f; + angle_ = 0.0F; + velocitat_ = 0.0F; // Activar invulnerabilidad solo si es respawn if (activar_invulnerabilitat) { invulnerable_timer_ = Defaults::Ship::INVULNERABILITY_DURATION; } else { - invulnerable_timer_ = 0.0f; + invulnerable_timer_ = 0.0F; } esta_tocada_ = false; @@ -120,10 +120,10 @@ void Nau::actualitzar(float delta_time) { return; // Decrementar timer de invulnerabilidad - if (invulnerable_timer_ > 0.0f) { + if (invulnerable_timer_ > 0.0F) { invulnerable_timer_ -= delta_time; - if (invulnerable_timer_ < 0.0f) { - invulnerable_timer_ = 0.0f; + if (invulnerable_timer_ < 0.0F) { + invulnerable_timer_ = 0.0F; } } @@ -160,10 +160,10 @@ void Nau::dibuixar() const { // [NUEVO] Convertir suma de velocitat_visual a escala multiplicativa // Radio base del ship = 12 px // velocitat_visual = 0-6 → r = 12-18 → escala = 1.0-1.5 - float velocitat_visual = velocitat_ / 33.33f; - float escala = 1.0f + (velocitat_visual / 12.0f); + float velocitat_visual = velocitat_ / 33.33F; + float escala = 1.0F + (velocitat_visual / 12.0F); - Rendering::render_shape(renderer_, forma_, centre_, angle_, escala, true, 1.0f, brightness_); + Rendering::render_shape(renderer_, forma_, centre_, angle_, escala, true, 1.0F, brightness_); } void Nau::aplicar_fisica(float delta_time) { @@ -174,10 +174,10 @@ void Nau::aplicar_fisica(float delta_time) { // S'usa (angle - PI/2) perquè angle=0 apunta cap amunt, no cap a la dreta // velocitat_ està en px/s, així que multipliquem per delta_time float dy = - (velocitat_ * delta_time) * std::sin(angle_ - Constants::PI / 2.0f) + + (velocitat_ * delta_time) * std::sin(angle_ - Constants::PI / 2.0F) + centre_.y; float dx = - (velocitat_ * delta_time) * std::cos(angle_ - Constants::PI / 2.0f) + + (velocitat_ * delta_time) * std::cos(angle_ - Constants::PI / 2.0F) + centre_.x; // Boundary checking amb radi de la nau @@ -199,10 +199,10 @@ void Nau::aplicar_fisica(float delta_time) { } // Fricció - desacceleració gradual (time-based) - if (velocitat_ > 0.1f) { + if (velocitat_ > 0.1F) { velocitat_ -= Defaults::Physics::FRICTION * delta_time; - if (velocitat_ < 0.0f) { - velocitat_ = 0.0f; + if (velocitat_ < 0.0F) { + velocitat_ = 0.0F; } } } diff --git a/source/game/entities/nau.hpp b/source/game/entities/nau.hpp index 3ca9a17..98f2ab5 100644 --- a/source/game/entities/nau.hpp +++ b/source/game/entities/nau.hpp @@ -27,13 +27,13 @@ class Nau { float get_angle() const { return angle_; } bool esta_viva() const { return !esta_tocada_; } bool esta_tocada() const { return esta_tocada_; } - bool es_invulnerable() const { return invulnerable_timer_ > 0.0f; } + bool es_invulnerable() const { return invulnerable_timer_ > 0.0F; } const std::shared_ptr& get_forma() const { return forma_; } float get_brightness() const { return brightness_; } Punt get_velocitat_vector() const { return { - velocitat_ * std::cos(angle_ - Constants::PI / 2.0f), - velocitat_ * std::sin(angle_ - Constants::PI / 2.0f)}; + velocitat_ * std::cos(angle_ - Constants::PI / 2.0F), + velocitat_ * std::sin(angle_ - Constants::PI / 2.0F)}; } // Setters diff --git a/source/game/escenes/escena_joc.cpp b/source/game/escenes/escena_joc.cpp index a9f3a3a..972d7e1 100644 --- a/source/game/escenes/escena_joc.cpp +++ b/source/game/escenes/escena_joc.cpp @@ -72,12 +72,12 @@ void EscenaJoc::executar() { while (GestorEscenes::actual == Escena::JOC) { // Calcular delta_time real Uint64 current_time = SDL_GetTicks(); - float delta_time = (current_time - last_time) / 1000.0f; + float delta_time = (current_time - last_time) / 1000.0F; last_time = current_time; // Limitar delta_time per evitar grans salts - if (delta_time > 0.05f) { - delta_time = 0.05f; + if (delta_time > 0.05F) { + delta_time = 0.05F; } // Actualitzar comptador de FPS @@ -147,17 +147,17 @@ void EscenaJoc::inicialitzar() { stage_manager_->get_spawn_controller().set_ship_position(&naus_[0].get_centre()); // Inicialitzar timers de muerte per jugador - itocado_per_jugador_[0] = 0.0f; - itocado_per_jugador_[1] = 0.0f; + itocado_per_jugador_[0] = 0.0F; + itocado_per_jugador_[1] = 0.0F; // Initialize lives and game over state (independent lives per player) vides_per_jugador_[0] = Defaults::Game::STARTING_LIVES; vides_per_jugador_[1] = Defaults::Game::STARTING_LIVES; estat_game_over_ = EstatGameOver::NONE; continue_counter_ = 0; - continue_tick_timer_ = 0.0f; + continue_tick_timer_ = 0.0F; continues_usados_ = 0; - game_over_timer_ = 0.0f; + game_over_timer_ = 0.0F; // Initialize scores (separate per player) puntuacio_per_jugador_[0] = 0; @@ -181,7 +181,7 @@ void EscenaJoc::inicialitzar() { } else { // Jugador inactiu: marcar com a mort permanent naus_[i].marcar_tocada(); - itocado_per_jugador_[i] = 999.0f; // Valor sentinella (permanent inactiu) + itocado_per_jugador_[i] = 999.0F; // Valor sentinella (permanent inactiu) vides_per_jugador_[i] = 0; // Sense vides std::cout << "[EscenaJoc] Jugador " << (i + 1) << " inactiu\n"; } @@ -231,10 +231,10 @@ void EscenaJoc::actualitzar(float delta_time) { if (stage_manager_->get_estat() == StageSystem::EstatStage::PLAYING) { // Check if at least one player is alive and playing (game in progress) bool algun_jugador_viu = false; - if (config_partida_.jugador1_actiu && itocado_per_jugador_[0] != 999.0f) { + if (config_partida_.jugador1_actiu && itocado_per_jugador_[0] != 999.0F) { algun_jugador_viu = true; } - if (config_partida_.jugador2_actiu && itocado_per_jugador_[1] != 999.0f) { + if (config_partida_.jugador2_actiu && itocado_per_jugador_[1] != 999.0F) { algun_jugador_viu = true; } @@ -242,7 +242,7 @@ void EscenaJoc::actualitzar(float delta_time) { if (algun_jugador_viu) { // P2 can join if not currently playing (never joined OR dead without lives) bool p2_no_juga = !config_partida_.jugador2_actiu || // Never joined - itocado_per_jugador_[1] == 999.0f; // Dead without lives + itocado_per_jugador_[1] == 999.0F; // Dead without lives if (p2_no_juga) { if (input->checkActionPlayer2(InputAction::START, Input::DO_NOT_ALLOW_REPEAT)) { @@ -252,7 +252,7 @@ void EscenaJoc::actualitzar(float delta_time) { // P1 can join if not currently playing (never joined OR dead without lives) bool p1_no_juga = !config_partida_.jugador1_actiu || // Never joined - itocado_per_jugador_[0] == 999.0f; // Dead without lives + itocado_per_jugador_[0] == 999.0F; // Dead without lives if (p1_no_juga) { if (input->checkActionPlayer1(InputAction::START, Input::DO_NOT_ALLOW_REPEAT)) { @@ -285,7 +285,7 @@ void EscenaJoc::actualitzar(float delta_time) { // Game over: only update timer, enemies, bullets, and debris game_over_timer_ -= delta_time; - if (game_over_timer_ <= 0.0f) { + if (game_over_timer_ <= 0.0F) { // Aturar música de joc abans de tornar al títol Audio::get()->stopMusic(); // Transició a pantalla de títol @@ -311,7 +311,7 @@ void EscenaJoc::actualitzar(float delta_time) { // Check death sequence state for BOTH players bool algun_jugador_mort = false; for (uint8_t i = 0; i < 2; i++) { - if (itocado_per_jugador_[i] > 0.0f && itocado_per_jugador_[i] < 999.0f) { + if (itocado_per_jugador_[i] > 0.0F && itocado_per_jugador_[i] < 999.0F) { algun_jugador_mort = true; // Death sequence active: update timer itocado_per_jugador_[i] += delta_time; @@ -327,11 +327,11 @@ void EscenaJoc::actualitzar(float delta_time) { // Respawn ship en spawn position con invulnerabilidad Punt spawn_pos = obtenir_punt_spawn(i); naus_[i].inicialitzar(&spawn_pos, true); - itocado_per_jugador_[i] = 0.0f; + itocado_per_jugador_[i] = 0.0F; } else { // Player is permanently dead (out of lives) // Set sentinel value to prevent re-entering this block - itocado_per_jugador_[i] = 999.0f; + itocado_per_jugador_[i] = 999.0F; // Check if ALL ACTIVE players are dead (trigger continue screen) bool p1_dead = !config_partida_.jugador1_actiu || vides_per_jugador_[0] <= 0; @@ -380,8 +380,8 @@ void EscenaJoc::actualitzar(float delta_time) { } // Calcular global progress (0.0 al inicio → 1.0 al final) - float global_progress = 1.0f - (stage_manager_->get_timer_transicio() / Defaults::Game::INIT_HUD_DURATION); - global_progress = std::min(1.0f, global_progress); + float global_progress = 1.0F - (stage_manager_->get_timer_transicio() / Defaults::Game::INIT_HUD_DURATION); + global_progress = std::min(1.0F, global_progress); // [NEW] Calcular progress independiente para cada nave float ship1_progress = calcular_progress_rango( @@ -395,12 +395,12 @@ void EscenaJoc::actualitzar(float delta_time) { Defaults::Game::INIT_HUD_SHIP2_RATIO_END); // [MODIFICAT] Animar AMBAS naus con sus progress respectivos - if (config_partida_.jugador1_actiu && ship1_progress < 1.0f) { + if (config_partida_.jugador1_actiu && ship1_progress < 1.0F) { Punt pos_p1 = calcular_posicio_nau_init_hud(ship1_progress, 0); naus_[0].set_centre(pos_p1); } - if (config_partida_.jugador2_actiu && ship2_progress < 1.0f) { + if (config_partida_.jugador2_actiu && ship2_progress < 1.0F) { Punt pos_p2 = calcular_posicio_nau_init_hud(ship2_progress, 1); naus_[1].set_centre(pos_p2); } @@ -425,7 +425,7 @@ void EscenaJoc::actualitzar(float delta_time) { // [NEW] Allow both ships movement and shooting during intro for (uint8_t i = 0; i < 2; i++) { bool jugador_actiu = (i == 0) ? config_partida_.jugador1_actiu : config_partida_.jugador2_actiu; - if (jugador_actiu && itocado_per_jugador_[i] == 0.0f) { // Only active, alive players + if (jugador_actiu && itocado_per_jugador_[i] == 0.0F) { // Only active, alive players naus_[i].processar_input(delta_time, i); naus_[i].actualitzar(delta_time); } @@ -443,11 +443,11 @@ void EscenaJoc::actualitzar(float delta_time) { case StageSystem::EstatStage::PLAYING: { // [NEW] Update stage manager (spawns enemies, pause if BOTH dead) - bool pausar_spawn = (itocado_per_jugador_[0] > 0.0f && itocado_per_jugador_[1] > 0.0f); + bool pausar_spawn = (itocado_per_jugador_[0] > 0.0F && itocado_per_jugador_[1] > 0.0F); stage_manager_->get_spawn_controller().actualitzar(delta_time, orni_, pausar_spawn); // [NEW] Check stage completion (only when at least one player alive) - bool algun_jugador_viu = (itocado_per_jugador_[0] == 0.0f || itocado_per_jugador_[1] == 0.0f); + bool algun_jugador_viu = (itocado_per_jugador_[0] == 0.0F || itocado_per_jugador_[1] == 0.0F); if (algun_jugador_viu) { auto& spawn_ctrl = stage_manager_->get_spawn_controller(); if (spawn_ctrl.tots_enemics_destruits(orni_)) { @@ -460,7 +460,7 @@ void EscenaJoc::actualitzar(float delta_time) { // [EXISTING] Normal gameplay - update active players for (uint8_t i = 0; i < 2; i++) { bool jugador_actiu = (i == 0) ? config_partida_.jugador1_actiu : config_partida_.jugador2_actiu; - if (jugador_actiu && itocado_per_jugador_[i] == 0.0f) { // Only active, alive players + if (jugador_actiu && itocado_per_jugador_[i] == 0.0F) { // Only active, alive players naus_[i].processar_input(delta_time, i); naus_[i].actualitzar(delta_time); } @@ -489,7 +489,7 @@ void EscenaJoc::actualitzar(float delta_time) { // [NEW] Allow both ships movement and shooting during outro for (uint8_t i = 0; i < 2; i++) { bool jugador_actiu = (i == 0) ? config_partida_.jugador1_actiu : config_partida_.jugador2_actiu; - if (jugador_actiu && itocado_per_jugador_[i] == 0.0f) { // Only active, alive players + if (jugador_actiu && itocado_per_jugador_[i] == 0.0F) { // Only active, alive players naus_[i].processar_input(delta_time, i); naus_[i].actualitzar(delta_time); } @@ -553,8 +553,8 @@ void EscenaJoc::dibuixar() { // Calcular centre de l'àrea de joc usant constants const SDL_FRect& play_area = Defaults::Zones::PLAYAREA; - float centre_x = play_area.x + play_area.w / 2.0f; - float centre_y = play_area.y + play_area.h / 2.0f; + float centre_x = play_area.x + play_area.w / 2.0F; + float centre_y = play_area.y + play_area.h / 2.0F; text_.render_centered(game_over_text, {centre_x, centre_y}, escala, spacing); @@ -570,7 +570,7 @@ void EscenaJoc::dibuixar() { // Calcular progrés de cada animació independent float timer = stage_manager_->get_timer_transicio(); float total_time = Defaults::Game::INIT_HUD_DURATION; - float global_progress = 1.0f - (timer / total_time); + float global_progress = 1.0F - (timer / total_time); // [NEW] Calcular progress independiente para cada elemento float rect_progress = calcular_progress_rango( @@ -594,7 +594,7 @@ void EscenaJoc::dibuixar() { Defaults::Game::INIT_HUD_SHIP2_RATIO_END); // Dibuixar elements animats - if (rect_progress > 0.0f) { + if (rect_progress > 0.0F) { // [NOU] Reproduir so quan comença l'animació del rectangle if (!init_hud_rect_sound_played_) { Audio::get()->playSound(Defaults::Sound::INIT_HUD, Audio::Group::GAME); @@ -604,16 +604,16 @@ void EscenaJoc::dibuixar() { dibuixar_marges_animat(rect_progress); } - if (score_progress > 0.0f) { + if (score_progress > 0.0F) { dibuixar_marcador_animat(score_progress); } // [MODIFICAT] Dibuixar naus amb progress independent - if (ship1_progress > 0.0f && config_partida_.jugador1_actiu && !naus_[0].esta_tocada()) { + if (ship1_progress > 0.0F && config_partida_.jugador1_actiu && !naus_[0].esta_tocada()) { naus_[0].dibuixar(); } - if (ship2_progress > 0.0f && config_partida_.jugador2_actiu && !naus_[1].esta_tocada()) { + if (ship2_progress > 0.0F && config_partida_.jugador2_actiu && !naus_[1].esta_tocada()) { naus_[1].dibuixar(); } @@ -625,7 +625,7 @@ void EscenaJoc::dibuixar() { // [NEW] Draw both ships if active and alive for (uint8_t i = 0; i < 2; i++) { bool jugador_actiu = (i == 0) ? config_partida_.jugador1_actiu : config_partida_.jugador2_actiu; - if (jugador_actiu && itocado_per_jugador_[i] == 0.0f) { + if (jugador_actiu && itocado_per_jugador_[i] == 0.0F) { naus_[i].dibuixar(); } } @@ -650,7 +650,7 @@ void EscenaJoc::dibuixar() { // [EXISTING] Normal rendering - active ships for (uint8_t i = 0; i < 2; i++) { bool jugador_actiu = (i == 0) ? config_partida_.jugador1_actiu : config_partida_.jugador2_actiu; - if (jugador_actiu && itocado_per_jugador_[i] == 0.0f) { + if (jugador_actiu && itocado_per_jugador_[i] == 0.0F) { naus_[i].dibuixar(); } } @@ -673,7 +673,7 @@ void EscenaJoc::dibuixar() { // [NEW] Draw both ships if active and alive for (uint8_t i = 0; i < 2; i++) { bool jugador_actiu = (i == 0) ? config_partida_.jugador1_actiu : config_partida_.jugador2_actiu; - if (jugador_actiu && itocado_per_jugador_[i] == 0.0f) { + if (jugador_actiu && itocado_per_jugador_[i] == 0.0F) { naus_[i].dibuixar(); } } @@ -700,7 +700,7 @@ void EscenaJoc::tocado(uint8_t player_id) { // Phase 2: Animation (0 < itocado_ < 3.0s) - debris animation // Phase 3: Respawn or game over (itocado_ >= 3.0s) - handled in actualitzar() - if (itocado_per_jugador_[player_id] == 0.0f) { + if (itocado_per_jugador_[player_id] == 0.0F) { // *** PHASE 1: TRIGGER DEATH *** // Mark ship as dead (stops rendering and input) @@ -711,23 +711,23 @@ void EscenaJoc::tocado(uint8_t player_id) { float ship_angle = naus_[player_id].get_angle(); Punt vel_nau = naus_[player_id].get_velocitat_vector(); // Reduir a 80% la velocitat heretada per la nau (més realista) - Punt vel_nau_80 = {vel_nau.x * 0.8f, vel_nau.y * 0.8f}; + Punt vel_nau_80 = {vel_nau.x * 0.8F, vel_nau.y * 0.8F}; debris_manager_.explotar( naus_[player_id].get_forma(), // Ship shape (3 lines) ship_pos, // Center position ship_angle, // Ship orientation - 1.0f, // Normal scale + 1.0F, // Normal scale Defaults::Physics::Debris::VELOCITAT_BASE, // 80 px/s naus_[player_id].get_brightness(), // Heredar brightness vel_nau_80, // Heredar 80% velocitat - 0.0f, // Nave: trayectorias rectas (sin drotacio) - 0.0f, // Sin herencia visual (rotación aleatoria) + 0.0F, // Nave: trayectorias rectas (sin drotacio) + 0.0F, // Sin herencia visual (rotación aleatoria) Defaults::Sound::EXPLOSION2 // Sonido alternativo para la explosión ); // Start death timer (non-zero to avoid re-triggering) - itocado_per_jugador_[player_id] = 0.001f; + itocado_per_jugador_[player_id] = 0.001F; } // Phase 2 is automatic (debris updates in actualitzar()) // Phase 3 is handled in actualitzar() when itocado_per_jugador_ >= DEATH_DURATION @@ -755,13 +755,13 @@ void EscenaJoc::dibuixar_marcador() { std::string text = construir_marcador(); // Paràmetres de renderització - const float escala = 0.85f; - const float spacing = 0.0f; + const float escala = 0.85F; + const float spacing = 0.0F; // Calcular centre de la zona del marcador const SDL_FRect& scoreboard = Defaults::Zones::SCOREBOARD; - float centre_x = scoreboard.w / 2.0f; - float centre_y = scoreboard.y + scoreboard.h / 2.0f; + float centre_x = scoreboard.w / 2.0F; + float centre_y = scoreboard.y + scoreboard.h / 2.0F; // Renderitzar centrat text_.render_centered(text, {centre_x, centre_y}, escala, spacing); @@ -784,12 +784,12 @@ void EscenaJoc::dibuixar_marges_animat(float progress) const { int cx = (x1 + x2) / 2; // Dividir en 3 fases de 33% cada una - constexpr float PHASE_1_END = 0.33f; - constexpr float PHASE_2_END = 0.66f; + constexpr float PHASE_1_END = 0.33F; + constexpr float PHASE_2_END = 0.66F; // --- FASE 1: Línies horitzontals superiors (0-33%) --- - if (eased_progress > 0.0f) { - float phase1_progress = std::min(eased_progress / PHASE_1_END, 1.0f); + if (eased_progress > 0.0F) { + float phase1_progress = std::min(eased_progress / PHASE_1_END, 1.0F); // Línia esquerra: creix des del centre cap a l'esquerra int x1_phase1 = static_cast(cx - (cx - x1) * phase1_progress); @@ -802,7 +802,7 @@ void EscenaJoc::dibuixar_marges_animat(float progress) const { // --- FASE 2: Línies verticals laterals (33-66%) --- if (eased_progress > PHASE_1_END) { - float phase2_progress = std::min((eased_progress - PHASE_1_END) / (PHASE_2_END - PHASE_1_END), 1.0f); + float phase2_progress = std::min((eased_progress - PHASE_1_END) / (PHASE_2_END - PHASE_1_END), 1.0F); // Línia esquerra: creix des de dalt cap a baix int y2_phase2 = static_cast(y1 + (y2 - y1) * phase2_progress); @@ -814,7 +814,7 @@ void EscenaJoc::dibuixar_marges_animat(float progress) const { // --- FASE 3: Línies horitzontals inferiors (66-100%) --- if (eased_progress > PHASE_2_END) { - float phase3_progress = (eased_progress - PHASE_2_END) / (1.0f - PHASE_2_END); + float phase3_progress = (eased_progress - PHASE_2_END) / (1.0F - PHASE_2_END); // Línia esquerra: creix des de l'esquerra cap al centre int x_left_phase3 = static_cast(x1 + (cx - x1) * phase3_progress); @@ -836,13 +836,13 @@ void EscenaJoc::dibuixar_marcador_animat(float progress) { std::string text = construir_marcador(); // Paràmetres - const float escala = 0.85f; - const float spacing = 0.0f; + const float escala = 0.85F; + const float spacing = 0.0F; // Calcular centre de la zona del marcador const SDL_FRect& scoreboard = Defaults::Zones::SCOREBOARD; - float centre_x = scoreboard.w / 2.0f; - float centre_y_final = scoreboard.y + scoreboard.h / 2.0f; + float centre_x = scoreboard.w / 2.0F; + float centre_y_final = scoreboard.y + scoreboard.h / 2.0F; // Posició Y inicial (offscreen, sota de la pantalla) float centre_y_inicial = static_cast(Defaults::Game::HEIGHT); @@ -869,7 +869,7 @@ Punt EscenaJoc::calcular_posicio_nau_init_hud(float progress, uint8_t player_id) float y_final = spawn_final.y; // Y inicial: offscreen, 50px sota la zona de joc - float y_inicial = zona.y + zona.h + 50.0f; + float y_inicial = zona.y + zona.h + 50.0F; // X no canvia (destí segons player_id) // Y interpola amb easing @@ -888,15 +888,15 @@ float EscenaJoc::calcular_progress_rango(float global_progress, float ratio_init // Validación de parámetros (evita división por cero) if (ratio_init >= ratio_end) { - return (global_progress >= ratio_end) ? 1.0f : 0.0f; + return (global_progress >= ratio_end) ? 1.0F : 0.0F; } if (global_progress < ratio_init) { - return 0.0f; + return 0.0F; } if (global_progress > ratio_end) { - return 1.0f; + return 1.0F; } // Normalizar rango [INIT, END] a [0.0, 1.0] @@ -946,11 +946,11 @@ void EscenaJoc::detectar_col·lisions_bales_enemics() { // Constants amplificades per hitbox més generós (115%) constexpr float RADI_BALA = Defaults::Entities::BULLET_RADIUS; constexpr float RADI_ENEMIC = Defaults::Entities::ENEMY_RADIUS; - constexpr float SUMA_RADIS = (RADI_BALA + RADI_ENEMIC) * 1.15f; // 28.75 px + constexpr float SUMA_RADIS = (RADI_BALA + RADI_ENEMIC) * 1.15F; // 28.75 px constexpr float SUMA_RADIS_QUADRAT = SUMA_RADIS * SUMA_RADIS; // 826.56 // Velocitat d'explosió reduïda per efecte suau - constexpr float VELOCITAT_EXPLOSIO = 80.0f; // px/s (en lloc de 80.0f per defecte) + constexpr float VELOCITAT_EXPLOSIO = 80.0F; // px/s (en lloc de 80.0f per defecte) // Iterar per totes les bales actives for (auto& bala : bales_) { @@ -1006,13 +1006,13 @@ void EscenaJoc::detectar_col·lisions_bales_enemics() { debris_manager_.explotar( enemic.get_forma(), // Forma vectorial del pentàgon pos_enemic, // Posició central - 0.0f, // Angle (enemic té rotació interna) - 1.0f, // Escala normal + 0.0F, // Angle (enemic té rotació interna) + 1.0F, // Escala normal VELOCITAT_EXPLOSIO, // 50 px/s (explosió suau) enemic.get_brightness(), // Heredar brightness vel_enemic, // Heredar velocitat enemic.get_drotacio(), // Heredar velocitat angular (trayectorias curvas) - 0.0f // Sin herencia visual (rotación aleatoria) + 0.0F // Sin herencia visual (rotación aleatoria) ); // 3. Desactivar bala @@ -1036,7 +1036,7 @@ void EscenaJoc::detectar_col·lisio_naus_enemics() { // Check collision for BOTH players for (uint8_t i = 0; i < 2; i++) { // Skip collisions if player is dead or invulnerable - if (itocado_per_jugador_[i] > 0.0f) continue; + if (itocado_per_jugador_[i] > 0.0F) continue; if (!naus_[i].esta_viva()) continue; if (naus_[i].es_invulnerable()) continue; @@ -1089,7 +1089,7 @@ void EscenaJoc::detectar_col·lisions_bales_jugadors() { } // Skip bullets in grace period (prevents instant self-collision) - if (bala.get_grace_timer() > 0.0f) { + if (bala.get_grace_timer() > 0.0F) { continue; } @@ -1099,7 +1099,7 @@ void EscenaJoc::detectar_col·lisions_bales_jugadors() { // Check collision with BOTH players for (uint8_t player_id = 0; player_id < 2; player_id++) { // Skip if player is dead, invulnerable, or inactive - if (itocado_per_jugador_[player_id] > 0.0f) continue; + if (itocado_per_jugador_[player_id] > 0.0F) continue; if (!naus_[player_id].esta_viva()) continue; if (naus_[player_id].es_invulnerable()) continue; @@ -1147,8 +1147,8 @@ void EscenaJoc::detectar_col·lisions_bales_jugadors() { // [NEW] Stage system helper methods void EscenaJoc::dibuixar_missatge_stage(const std::string& missatge) { - constexpr float escala_base = 1.0f; - constexpr float spacing = 2.0f; + constexpr float escala_base = 1.0F; + constexpr float spacing = 2.0F; const SDL_FRect& play_area = Defaults::Zones::PLAYAREA; const float max_width = play_area.w * Defaults::Game::STAGE_MESSAGE_MAX_WIDTH_RATIO; @@ -1168,16 +1168,16 @@ void EscenaJoc::dibuixar_missatge_stage(const std::string& missatge) { // Calculate progress from timer (0.0 at start → 1.0 at end) float remaining_time = stage_manager_->get_timer_transicio(); - float progress = 1.0f - (remaining_time / total_time); + float progress = 1.0F - (remaining_time / total_time); // Determine how many characters to show size_t visible_chars; - if (typing_ratio > 0.0f && progress < typing_ratio) { + if (typing_ratio > 0.0F && progress < typing_ratio) { // Typewriter phase: show partial text float typing_progress = progress / typing_ratio; // Normalize to 0.0-1.0 visible_chars = static_cast(missatge.length() * typing_progress); - if (visible_chars == 0 && progress > 0.0f) { + if (visible_chars == 0 && progress > 0.0F) { visible_chars = 1; // Show at least 1 character after first frame } } else { @@ -1203,8 +1203,8 @@ void EscenaJoc::dibuixar_missatge_stage(const std::string& missatge) { float text_height = text_.get_text_height(escala); // Calculate position as if FULL text was there (for fixed position typewriter) - float x = play_area.x + (play_area.w - full_text_width) / 2.0f; - float y = play_area.y + (play_area.h * Defaults::Game::STAGE_MESSAGE_Y_RATIO) - (text_height / 2.0f); + float x = play_area.x + (play_area.w - full_text_width) / 2.0F; + float y = play_area.y + (play_area.h * Defaults::Game::STAGE_MESSAGE_Y_RATIO) - (text_height / 2.0F); // Render only the partial message (typewriter effect) Punt pos = {x, y}; @@ -1221,7 +1221,7 @@ Punt EscenaJoc::obtenir_punt_spawn(uint8_t player_id) const { float x_ratio; if (config_partida_.es_un_jugador()) { // Un sol jugador: spawn al centre (50%) - x_ratio = 0.5f; + x_ratio = 0.5F; } else { // Dos jugadors: spawn a posicions separades x_ratio = (player_id == 0) @@ -1236,15 +1236,15 @@ Punt EscenaJoc::obtenir_punt_spawn(uint8_t player_id) const { void EscenaJoc::disparar_bala(uint8_t player_id) { // Verificar que el jugador está vivo - if (itocado_per_jugador_[player_id] > 0.0f) return; + if (itocado_per_jugador_[player_id] > 0.0F) return; if (!naus_[player_id].esta_viva()) return; // Calcular posición en la punta de la nave const Punt& ship_centre = naus_[player_id].get_centre(); float ship_angle = naus_[player_id].get_angle(); - constexpr float LOCAL_TIP_X = 0.0f; - constexpr float LOCAL_TIP_Y = -12.0f; + constexpr float LOCAL_TIP_X = 0.0F; + constexpr float LOCAL_TIP_Y = -12.0F; float cos_a = std::cos(ship_angle); float sin_a = std::sin(ship_angle); float tip_x = LOCAL_TIP_X * cos_a - LOCAL_TIP_Y * sin_a + ship_centre.x; @@ -1273,7 +1273,7 @@ void EscenaJoc::check_and_apply_continue_timeout() { void EscenaJoc::actualitzar_continue(float delta_time) { continue_tick_timer_ -= delta_time; - if (continue_tick_timer_ <= 0.0f) { + if (continue_tick_timer_ <= 0.0F) { continue_counter_--; continue_tick_timer_ = Defaults::Game::CONTINUE_TICK_DURATION; @@ -1314,7 +1314,7 @@ void EscenaJoc::processar_input_continue() { // Reset score and lives (KEEP level and enemies!) puntuacio_per_jugador_[player_to_revive] = 0; vides_per_jugador_[player_to_revive] = Defaults::Game::STARTING_LIVES; - itocado_per_jugador_[player_to_revive] = 0.0f; + itocado_per_jugador_[player_to_revive] = 0.0F; // Activate player if not already if (player_to_revive == 0) { @@ -1332,7 +1332,7 @@ void EscenaJoc::processar_input_continue() { uint8_t other_player = 1; puntuacio_per_jugador_[other_player] = 0; vides_per_jugador_[other_player] = Defaults::Game::STARTING_LIVES; - itocado_per_jugador_[other_player] = 0.0f; + itocado_per_jugador_[other_player] = 0.0F; config_partida_.jugador2_actiu = true; Punt spawn_pos2 = obtenir_punt_spawn(other_player); naus_[other_player].inicialitzar(&spawn_pos2, true); @@ -1341,7 +1341,7 @@ void EscenaJoc::processar_input_continue() { // Resume game estat_game_over_ = EstatGameOver::NONE; continue_counter_ = 0; - continue_tick_timer_ = 0.0f; + continue_tick_timer_ = 0.0F; // Play continue confirmation sound Audio::get()->playSound(Defaults::Sound::START, Audio::Group::GAME); @@ -1373,14 +1373,14 @@ void EscenaJoc::processar_input_continue() { void EscenaJoc::dibuixar_continue() { const SDL_FRect& play_area = Defaults::Zones::PLAYAREA; - constexpr float spacing = 4.0f; + constexpr float spacing = 4.0F; // "CONTINUE" text (using constants) const std::string continue_text = "CONTINUE"; float escala_continue = Defaults::Game::ContinueScreen::CONTINUE_TEXT_SCALE; float y_ratio_continue = Defaults::Game::ContinueScreen::CONTINUE_TEXT_Y_RATIO; - float centre_x = play_area.x + play_area.w / 2.0f; + float centre_x = play_area.x + play_area.w / 2.0F; float centre_y_continue = play_area.y + play_area.h * y_ratio_continue; text_.render_centered(continue_text, {centre_x, centre_y_continue}, escala_continue, spacing); @@ -1417,7 +1417,7 @@ void EscenaJoc::unir_jugador(uint8_t player_id) { // Reset stats vides_per_jugador_[player_id] = Defaults::Game::STARTING_LIVES; puntuacio_per_jugador_[player_id] = 0; - itocado_per_jugador_[player_id] = 0.0f; + itocado_per_jugador_[player_id] = 0.0F; // Spawn with invulnerability Punt spawn_pos = obtenir_punt_spawn(player_id); diff --git a/source/game/escenes/escena_logo.cpp b/source/game/escenes/escena_logo.cpp index 0a9dc0e..cf69e75 100644 --- a/source/game/escenes/escena_logo.cpp +++ b/source/game/escenes/escena_logo.cpp @@ -26,19 +26,19 @@ using Opcio = ContextEscenes::Opcio; // en funció del progrés global (efecte seqüencial) static float calcular_progress_letra(size_t letra_index, size_t num_letras, float global_progress, float threshold) { if (num_letras == 0) - return 1.0f; + return 1.0F; // Calcular temps per lletra - float duration_per_letra = 1.0f / static_cast(num_letras); + float duration_per_letra = 1.0F / static_cast(num_letras); float step = threshold * duration_per_letra; float start = static_cast(letra_index) * step; float end = start + duration_per_letra; // Interpolar progrés if (global_progress < start) { - return 0.0f; // Encara no ha començat + return 0.0F; // Encara no ha començat } else if (global_progress >= end) { - return 1.0f; // Completament apareguda + return 1.0F; // Completament apareguda } else { return (global_progress - start) / (end - start); } @@ -48,10 +48,10 @@ EscenaLogo::EscenaLogo(SDLManager& sdl, ContextEscenes& context) : sdl_(sdl), context_(context), estat_actual_(EstatAnimacio::PRE_ANIMATION), - temps_estat_actual_(0.0f), + temps_estat_actual_(0.0F), debris_manager_(std::make_unique(sdl.obte_renderer())), lletra_explosio_index_(0), - temps_des_ultima_explosio_(0.0f) { + temps_des_ultima_explosio_(0.0F) { std::cout << "Escena Logo: Inicialitzant...\n"; // Consumir opcions (LOGO no processa opcions actualment) @@ -75,12 +75,12 @@ void EscenaLogo::executar() { while (GestorEscenes::actual == Escena::LOGO) { // Calcular delta_time real Uint64 current_time = SDL_GetTicks(); - float delta_time = (current_time - last_time) / 1000.0f; + float delta_time = (current_time - last_time) / 1000.0F; last_time = current_time; // Limitar delta_time per evitar grans salts - if (delta_time > 0.05f) { - delta_time = 0.05f; + if (delta_time > 0.05F) { + delta_time = 0.05F; } // Actualitzar comptador de FPS @@ -140,7 +140,7 @@ void EscenaLogo::inicialitzar_lletres() { "logo/letra_s.shp"}; // Pas 1: Carregar totes les formes i calcular amplades - float ancho_total = 0.0f; + float ancho_total = 0.0F; for (const auto& fitxer : fitxers) { auto forma = ShapeLoader::load(fitxer); @@ -168,7 +168,7 @@ void EscenaLogo::inicialitzar_lletres() { float offset_centre = (forma->get_centre().x - min_x) * ESCALA_FINAL; lletres_.push_back({forma, - {0.0f, 0.0f}, // Posició es calcularà després + {0.0F, 0.0F}, // Posició es calcularà després ancho, offset_centre}); @@ -179,11 +179,11 @@ void EscenaLogo::inicialitzar_lletres() { ancho_total += ESPAI_ENTRE_LLETRES * (lletres_.size() - 1); // Pas 3: Calcular posició inicial (centrat horitzontal) - constexpr float PANTALLA_ANCHO = 640.0f; - constexpr float PANTALLA_ALTO = 480.0f; + constexpr float PANTALLA_ANCHO = 640.0F; + constexpr float PANTALLA_ALTO = 480.0F; - float x_inicial = (PANTALLA_ANCHO - ancho_total) / 2.0f; - float y_centre = PANTALLA_ALTO / 2.0f; + float x_inicial = (PANTALLA_ANCHO - ancho_total) / 2.0F; + float y_centre = PANTALLA_ALTO / 2.0F; // Pas 4: Assignar posicions a cada lletra float x_actual = x_inicial; @@ -205,12 +205,12 @@ void EscenaLogo::inicialitzar_lletres() { void EscenaLogo::canviar_estat(EstatAnimacio nou_estat) { estat_actual_ = nou_estat; - temps_estat_actual_ = 0.0f; // Reset temps + temps_estat_actual_ = 0.0F; // Reset temps // Inicialitzar estat d'explosió if (nou_estat == EstatAnimacio::EXPLOSION) { lletra_explosio_index_ = 0; - temps_des_ultima_explosio_ = 0.0f; + temps_des_ultima_explosio_ = 0.0F; // Generar ordre aleatori d'explosions ordre_explosio_.clear(); @@ -246,18 +246,18 @@ void EscenaLogo::actualitzar_explosions(float delta_time) { debris_manager_->explotar( lletra.forma, // Forma a explotar lletra.posicio, // Posició - 0.0f, // Angle (sense rotació) + 0.0F, // Angle (sense rotació) ESCALA_FINAL, // Escala (lletres a escala final) VELOCITAT_EXPLOSIO, // Velocitat base - 1.0f, // Brightness màxim (per defecte) - {0.0f, 0.0f} // Sense velocitat (per defecte) + 1.0F, // Brightness màxim (per defecte) + {0.0F, 0.0F} // Sense velocitat (per defecte) ); std::cout << "[EscenaLogo] Explota lletra " << lletra_explosio_index_ << "\n"; // Passar a la següent lletra lletra_explosio_index_++; - temps_des_ultima_explosio_ = 0.0f; + temps_des_ultima_explosio_ = 0.0F; } else { // Totes les lletres han explotat, transició a POST_EXPLOSION canviar_estat(EstatAnimacio::POST_EXPLOSION); @@ -277,7 +277,7 @@ void EscenaLogo::actualitzar(float delta_time) { case EstatAnimacio::ANIMATION: { // Reproduir so per cada lletra quan comença a aparèixer - float global_progress = std::min(temps_estat_actual_ / DURACIO_ZOOM, 1.0f); + float global_progress = std::min(temps_estat_actual_ / DURACIO_ZOOM, 1.0F); for (size_t i = 0; i < lletres_.size() && i < so_reproduit_.size(); i++) { if (!so_reproduit_[i]) { @@ -288,7 +288,7 @@ void EscenaLogo::actualitzar(float delta_time) { THRESHOLD_LETRA); // Reproduir so quan la lletra comença a aparèixer (progress > 0) - if (letra_progress > 0.0f) { + if (letra_progress > 0.0F) { Audio::get()->playSound(Defaults::Sound::LOGO, Audio::Group::GAME); so_reproduit_[i] = true; } @@ -345,8 +345,8 @@ void EscenaLogo::dibuixar() { estat_actual_ == EstatAnimacio::POST_ANIMATION) { float global_progress = (estat_actual_ == EstatAnimacio::ANIMATION) - ? std::min(temps_estat_actual_ / DURACIO_ZOOM, 1.0f) - : 1.0f; // POST: mantenir al 100% + ? std::min(temps_estat_actual_ / DURACIO_ZOOM, 1.0F) + : 1.0F; // POST: mantenir al 100% const Punt ORIGEN_ZOOM = {ORIGEN_ZOOM_X, ORIGEN_ZOOM_Y}; @@ -359,7 +359,7 @@ void EscenaLogo::dibuixar() { global_progress, THRESHOLD_LETRA); - if (letra_progress <= 0.0f) { + if (letra_progress <= 0.0F) { continue; } @@ -370,7 +370,7 @@ void EscenaLogo::dibuixar() { ORIGEN_ZOOM.y + (lletra.posicio.y - ORIGEN_ZOOM.y) * letra_progress; float t = letra_progress; - float ease_factor = 1.0f - (1.0f - t) * (1.0f - t); + float ease_factor = 1.0F - (1.0F - t) * (1.0F - t); float escala_actual = ESCALA_INICIAL + (ESCALA_FINAL - ESCALA_INICIAL) * ease_factor; @@ -378,10 +378,10 @@ void EscenaLogo::dibuixar() { sdl_.obte_renderer(), lletra.forma, pos_actual, - 0.0f, + 0.0F, escala_actual, true, - 1.0f); + 1.0F); } } @@ -402,10 +402,10 @@ void EscenaLogo::dibuixar() { sdl_.obte_renderer(), lletra.forma, lletra.posicio, - 0.0f, + 0.0F, ESCALA_FINAL, true, - 1.0f); + 1.0F); } } } diff --git a/source/game/escenes/escena_logo.hpp b/source/game/escenes/escena_logo.hpp index 0b2ed47..717f02f 100644 --- a/source/game/escenes/escena_logo.hpp +++ b/source/game/escenes/escena_logo.hpp @@ -62,20 +62,20 @@ class EscenaLogo { std::array so_reproduit_; // Track si cada lletra ja ha reproduit el so // Constants d'animació - static constexpr float DURACIO_PRE = 1.5f; // Duració PRE_ANIMATION (pantalla negra) - static constexpr float DURACIO_ZOOM = 4.0f; // Duració del zoom (segons) - static constexpr float DURACIO_POST_ANIMATION = 3.0f; // Duració POST_ANIMATION (logo complet) - static constexpr float DURACIO_POST_EXPLOSION = 3.0f; // Duració POST_EXPLOSION (espera final) - static constexpr float DELAY_ENTRE_EXPLOSIONS = 0.1f; // Temps entre explosions de lletres - static constexpr float VELOCITAT_EXPLOSIO = 240.0f; // Velocitat base fragments (px/s) - static constexpr float ESCALA_INICIAL = 0.1f; // Escala inicial (10%) - static constexpr float ESCALA_FINAL = 0.8f; // Escala final (80%) - static constexpr float ESPAI_ENTRE_LLETRES = 10.0f; // Espaiat entre lletres + static constexpr float DURACIO_PRE = 1.5F; // Duració PRE_ANIMATION (pantalla negra) + static constexpr float DURACIO_ZOOM = 4.0F; // Duració del zoom (segons) + static constexpr float DURACIO_POST_ANIMATION = 3.0F; // Duració POST_ANIMATION (logo complet) + static constexpr float DURACIO_POST_EXPLOSION = 3.0F; // Duració POST_EXPLOSION (espera final) + static constexpr float DELAY_ENTRE_EXPLOSIONS = 0.1F; // Temps entre explosions de lletres + static constexpr float VELOCITAT_EXPLOSIO = 240.0F; // Velocitat base fragments (px/s) + static constexpr float ESCALA_INICIAL = 0.1F; // Escala inicial (10%) + static constexpr float ESCALA_FINAL = 0.8F; // Escala final (80%) + static constexpr float ESPAI_ENTRE_LLETRES = 10.0F; // Espaiat entre lletres // Constants d'animació seqüencial - static constexpr float THRESHOLD_LETRA = 0.6f; // Umbral per activar següent lletra (0.0-1.0) - static constexpr float ORIGEN_ZOOM_X = Defaults::Game::WIDTH * 0.5f; // Punt inicial X del zoom - static constexpr float ORIGEN_ZOOM_Y = Defaults::Game::HEIGHT * 0.4f; // Punt inicial Y del zoom + static constexpr float THRESHOLD_LETRA = 0.6F; // Umbral per activar següent lletra (0.0-1.0) + static constexpr float ORIGEN_ZOOM_X = Defaults::Game::WIDTH * 0.5F; // Punt inicial X del zoom + static constexpr float ORIGEN_ZOOM_Y = Defaults::Game::HEIGHT * 0.4F; // Punt inicial Y del zoom // Mètodes privats void inicialitzar_lletres(); diff --git a/source/game/escenes/escena_titol.cpp b/source/game/escenes/escena_titol.cpp index 4ff991f..769bfc8 100644 --- a/source/game/escenes/escena_titol.cpp +++ b/source/game/escenes/escena_titol.cpp @@ -27,11 +27,11 @@ EscenaTitol::EscenaTitol(SDLManager& sdl, ContextEscenes& context) context_(context), text_(sdl.obte_renderer()), estat_actual_(EstatTitol::STARFIELD_FADE_IN), - temps_acumulat_(0.0f), - temps_animacio_(0.0f), - temps_estat_main_(0.0f), + temps_acumulat_(0.0F), + temps_animacio_(0.0F), + temps_estat_main_(0.0F), animacio_activa_(false), - factor_lerp_(0.0f) { + factor_lerp_(0.0F) { std::cout << "Escena Titol: Inicialitzant...\n"; // Inicialitzar configuració de partida (cap jugador actiu per defecte) @@ -45,13 +45,13 @@ EscenaTitol::EscenaTitol(SDLManager& sdl, ContextEscenes& context) if (opcio == Opcio::JUMP_TO_TITLE_MAIN) { std::cout << "Escena Titol: Opció JUMP_TO_TITLE_MAIN activada\n"; estat_actual_ = EstatTitol::MAIN; - temps_estat_main_ = 0.0f; + temps_estat_main_ = 0.0F; } // Crear starfield de fons Punt centre_pantalla{ - Defaults::Game::WIDTH / 2.0f, - Defaults::Game::HEIGHT / 2.0f}; + Defaults::Game::WIDTH / 2.0F, + Defaults::Game::HEIGHT / 2.0F}; SDL_FRect area_completa{ 0, @@ -72,7 +72,7 @@ EscenaTitol::EscenaTitol(SDLManager& sdl, ContextEscenes& context) starfield_->set_brightness(BRIGHTNESS_STARFIELD); } else { // Flux normal: comença amb brightness 0.0 per fade-in - starfield_->set_brightness(0.0f); + starfield_->set_brightness(0.0F); } // Inicialitzar animador de naus 3D @@ -113,7 +113,7 @@ void EscenaTitol::inicialitzar_titol() { "title/letra_i.shp"}; // Pas 1: Carregar formes i calcular amplades per "ORNI" - float ancho_total_orni = 0.0f; + float ancho_total_orni = 0.0F; for (const auto& fitxer : fitxers_orni) { auto forma = ShapeLoader::load(fitxer); @@ -145,7 +145,7 @@ void EscenaTitol::inicialitzar_titol() { float altura = altura_sin_escalar * Defaults::Title::Layout::LOGO_SCALE; float offset_centre = (forma->get_centre().x - min_x) * Defaults::Title::Layout::LOGO_SCALE; - lletres_orni_.push_back({forma, {0.0f, 0.0f}, ancho, altura, offset_centre}); + lletres_orni_.push_back({forma, {0.0F, 0.0F}, ancho, altura, offset_centre}); ancho_total_orni += ancho; } @@ -154,7 +154,7 @@ void EscenaTitol::inicialitzar_titol() { ancho_total_orni += ESPAI_ENTRE_LLETRES * (lletres_orni_.size() - 1); // Calcular posició inicial (centrat horitzontal) per "ORNI" - float x_inicial_orni = (Defaults::Game::WIDTH - ancho_total_orni) / 2.0f; + float x_inicial_orni = (Defaults::Game::WIDTH - ancho_total_orni) / 2.0F; float x_actual = x_inicial_orni; for (auto& lletra : lletres_orni_) { @@ -168,7 +168,7 @@ void EscenaTitol::inicialitzar_titol() { // === Calcular posició Y dinàmica per "ATTACK!" === // Totes les lletres ORNI tenen la mateixa altura, utilitzem la primera - float altura_orni = lletres_orni_.empty() ? 50.0f : lletres_orni_[0].altura; + float altura_orni = lletres_orni_.empty() ? 50.0F : lletres_orni_[0].altura; float y_orni = Defaults::Game::HEIGHT * Defaults::Title::Layout::LOGO_POS; float separacion_lineas = Defaults::Game::HEIGHT * Defaults::Title::Layout::LOGO_LINE_SPACING; y_attack_dinamica_ = y_orni + altura_orni + separacion_lineas; @@ -187,7 +187,7 @@ void EscenaTitol::inicialitzar_titol() { "title/letra_exclamacion.shp"}; // Pas 1: Carregar formes i calcular amplades per "ATTACK!" - float ancho_total_attack = 0.0f; + float ancho_total_attack = 0.0F; for (const auto& fitxer : fitxers_attack) { auto forma = ShapeLoader::load(fitxer); @@ -219,7 +219,7 @@ void EscenaTitol::inicialitzar_titol() { float altura = altura_sin_escalar * Defaults::Title::Layout::LOGO_SCALE; float offset_centre = (forma->get_centre().x - min_x) * Defaults::Title::Layout::LOGO_SCALE; - lletres_attack_.push_back({forma, {0.0f, 0.0f}, ancho, altura, offset_centre}); + lletres_attack_.push_back({forma, {0.0F, 0.0F}, ancho, altura, offset_centre}); ancho_total_attack += ancho; } @@ -228,7 +228,7 @@ void EscenaTitol::inicialitzar_titol() { ancho_total_attack += ESPAI_ENTRE_LLETRES * (lletres_attack_.size() - 1); // Calcular posició inicial (centrat horitzontal) per "ATTACK!" - float x_inicial_attack = (Defaults::Game::WIDTH - ancho_total_attack) / 2.0f; + float x_inicial_attack = (Defaults::Game::WIDTH - ancho_total_attack) / 2.0F; x_actual = x_inicial_attack; for (auto& lletra : lletres_attack_) { @@ -261,12 +261,12 @@ void EscenaTitol::executar() { while (GestorEscenes::actual == Escena::TITOL) { // Calcular delta_time real Uint64 current_time = SDL_GetTicks(); - float delta_time = (current_time - last_time) / 1000.0f; + float delta_time = (current_time - last_time) / 1000.0F; last_time = current_time; // Limitar delta_time per evitar grans salts - if (delta_time > 0.05f) { - delta_time = 0.05f; + if (delta_time > 0.05F) { + delta_time = 0.05F; } // Actualitzar comptador de FPS @@ -339,7 +339,7 @@ void EscenaTitol::actualitzar(float delta_time) { temps_acumulat_ += delta_time; // Calcular progrés del fade (0.0 → 1.0) - float progress = std::min(1.0f, temps_acumulat_ / DURACIO_FADE_IN); + float progress = std::min(1.0F, temps_acumulat_ / DURACIO_FADE_IN); // Lerp brightness de 0.0 a BRIGHTNESS_STARFIELD float brightness_actual = progress * BRIGHTNESS_STARFIELD; @@ -348,7 +348,7 @@ void EscenaTitol::actualitzar(float delta_time) { // Transició a STARFIELD quan el fade es completa if (temps_acumulat_ >= DURACIO_FADE_IN) { estat_actual_ = EstatTitol::STARFIELD; - temps_acumulat_ = 0.0f; // Reset timer per al següent estat + temps_acumulat_ = 0.0F; // Reset timer per al següent estat starfield_->set_brightness(BRIGHTNESS_STARFIELD); // Assegurar valor final } break; @@ -358,9 +358,9 @@ void EscenaTitol::actualitzar(float delta_time) { temps_acumulat_ += delta_time; if (temps_acumulat_ >= DURACIO_INIT) { estat_actual_ = EstatTitol::MAIN; - temps_estat_main_ = 0.0f; // Reset timer al entrar a MAIN + temps_estat_main_ = 0.0F; // Reset timer al entrar a MAIN animacio_activa_ = false; // Comença estàtic - factor_lerp_ = 0.0f; // Sense animació encara + factor_lerp_ = 0.0F; // Sense animació encara // Naus esperaran ENTRANCE_DELAY abans d'entrar (no iniciar aquí) } @@ -379,7 +379,7 @@ void EscenaTitol::actualitzar(float delta_time) { // Fase 1: Estàtic (0-10s) if (temps_estat_main_ < DELAY_INICI_ANIMACIO) { - factor_lerp_ = 0.0f; + factor_lerp_ = 0.0F; animacio_activa_ = false; } // Fase 2: Lerp (10-12s) @@ -390,7 +390,7 @@ void EscenaTitol::actualitzar(float delta_time) { } // Fase 3: Animació completa (12s+) else { - factor_lerp_ = 1.0f; + factor_lerp_ = 1.0F; animacio_activa_ = true; } @@ -430,7 +430,7 @@ void EscenaTitol::actualitzar(float delta_time) { Audio::get()->playSound(Defaults::Sound::START, Audio::Group::GAME); // Reiniciar el timer per allargar el temps de transició - temps_acumulat_ = 0.0f; + temps_acumulat_ = 0.0F; std::cout << "[EscenaTitol] Segon jugador s'ha unit - so i timer reiniciats\n"; } @@ -439,7 +439,7 @@ void EscenaTitol::actualitzar(float delta_time) { if (temps_acumulat_ >= DURACIO_TRANSITION) { // Transició a pantalla negra estat_actual_ = EstatTitol::BLACK_SCREEN; - temps_acumulat_ = 0.0f; + temps_acumulat_ = 0.0F; std::cout << "[EscenaTitol] Passant a BLACK_SCREEN\n"; } break; @@ -462,7 +462,7 @@ void EscenaTitol::actualitzar(float delta_time) { // Saltar a MAIN estat_actual_ = EstatTitol::MAIN; starfield_->set_brightness(BRIGHTNESS_STARFIELD); - temps_estat_main_ = 0.0f; + temps_estat_main_ = 0.0F; // Naus esperaran ENTRANCE_DELAY abans d'entrar (no iniciar aquí) } @@ -491,7 +491,7 @@ void EscenaTitol::actualitzar(float delta_time) { context_.canviar_escena(Escena::JOC); estat_actual_ = EstatTitol::PLAYER_JOIN_PHASE; - temps_acumulat_ = 0.0f; + temps_acumulat_ = 0.0F; // Trigger animació de sortida NOMÉS per les naus que han premut START if (ship_animator_) { @@ -524,8 +524,8 @@ void EscenaTitol::actualitzar_animacio_logo(float delta_time) { float frequency_y_actual = ORBIT_FREQUENCY_Y; // Calcular offset orbital - float offset_x = amplitude_x_actual * std::sin(2.0f * Defaults::Math::PI * frequency_x_actual * temps_animacio_); - float offset_y = amplitude_y_actual * std::sin(2.0f * Defaults::Math::PI * frequency_y_actual * temps_animacio_ + ORBIT_PHASE_OFFSET); + float offset_x = amplitude_x_actual * std::sin(2.0F * Defaults::Math::PI * frequency_x_actual * temps_animacio_); + float offset_y = amplitude_y_actual * std::sin(2.0F * Defaults::Math::PI * frequency_y_actual * temps_animacio_ + ORBIT_PHASE_OFFSET); // Aplicar offset a totes les lletres de "ORNI" for (size_t i = 0; i < lletres_orni_.size(); ++i) { @@ -567,7 +567,7 @@ void EscenaTitol::dibuixar() { // === Calcular i renderitzar ombra (només si animació activa) === if (animacio_activa_) { float temps_shadow = temps_animacio_ - SHADOW_DELAY; - if (temps_shadow < 0.0f) temps_shadow = 0.0f; // Evitar temps negatiu + if (temps_shadow < 0.0F) temps_shadow = 0.0F; // Evitar temps negatiu // Usar amplituds i freqüències completes per l'ombra float amplitude_x_shadow = ORBIT_AMPLITUDE_X; @@ -576,8 +576,8 @@ void EscenaTitol::dibuixar() { float frequency_y_shadow = ORBIT_FREQUENCY_Y; // Calcular offset de l'ombra - float shadow_offset_x = amplitude_x_shadow * std::sin(2.0f * Defaults::Math::PI * frequency_x_shadow * temps_shadow) + SHADOW_OFFSET_X; - float shadow_offset_y = amplitude_y_shadow * std::sin(2.0f * Defaults::Math::PI * frequency_y_shadow * temps_shadow + ORBIT_PHASE_OFFSET) + SHADOW_OFFSET_Y; + float shadow_offset_x = amplitude_x_shadow * std::sin(2.0F * Defaults::Math::PI * frequency_x_shadow * temps_shadow) + SHADOW_OFFSET_X; + float shadow_offset_y = amplitude_y_shadow * std::sin(2.0F * Defaults::Math::PI * frequency_y_shadow * temps_shadow + ORBIT_PHASE_OFFSET) + SHADOW_OFFSET_Y; // === RENDERITZAR OMBRA PRIMER (darrera del logo principal) === @@ -591,10 +591,10 @@ void EscenaTitol::dibuixar() { sdl_.obte_renderer(), lletres_orni_[i].forma, pos_shadow, - 0.0f, + 0.0F, Defaults::Title::Layout::LOGO_SCALE, true, - 1.0f, // progress = 1.0 (totalment visible) + 1.0F, // progress = 1.0 (totalment visible) SHADOW_BRIGHTNESS // brightness = 0.4 (brillantor reduïda) ); } @@ -609,10 +609,10 @@ void EscenaTitol::dibuixar() { sdl_.obte_renderer(), lletres_attack_[i].forma, pos_shadow, - 0.0f, + 0.0F, Defaults::Title::Layout::LOGO_SCALE, true, - 1.0f, // progress = 1.0 (totalment visible) + 1.0F, // progress = 1.0 (totalment visible) SHADOW_BRIGHTNESS); } } @@ -625,10 +625,10 @@ void EscenaTitol::dibuixar() { sdl_.obte_renderer(), lletra.forma, lletra.posicio, - 0.0f, + 0.0F, Defaults::Title::Layout::LOGO_SCALE, true, - 1.0f // Brillantor completa + 1.0F // Brillantor completa ); } @@ -638,10 +638,10 @@ void EscenaTitol::dibuixar() { sdl_.obte_renderer(), lletra.forma, lletra.posicio, - 0.0f, + 0.0F, Defaults::Title::Layout::LOGO_SCALE, true, - 1.0f // Brillantor completa + 1.0F // Brillantor completa ); } @@ -654,15 +654,15 @@ void EscenaTitol::dibuixar() { bool mostrar_text = true; if (estat_actual_ == EstatTitol::PLAYER_JOIN_PHASE) { // Parpelleig: sin oscil·la entre -1 i 1, volem ON quan > 0 - float fase = temps_acumulat_ * BLINK_FREQUENCY * 2.0f * 3.14159f; // 2π × freq × temps - mostrar_text = (std::sin(fase) > 0.0f); + float fase = temps_acumulat_ * BLINK_FREQUENCY * 2.0F * 3.14159F; // 2π × freq × temps + mostrar_text = (std::sin(fase) > 0.0F); } if (mostrar_text) { const std::string main_text = "PRESS START TO PLAY"; const float escala_main = Defaults::Title::Layout::PRESS_START_SCALE; - float centre_x = Defaults::Game::WIDTH / 2.0f; + float centre_x = Defaults::Game::WIDTH / 2.0F; float centre_y = Defaults::Game::HEIGHT * Defaults::Title::Layout::PRESS_START_POS; text_.render_centered(main_text, {centre_x, centre_y}, escala_main, spacing); @@ -690,7 +690,7 @@ void EscenaTitol::dibuixar() { float y_line2 = y_line1 + copy_height + line_spacing; // Línea 2 debajo de línea 1 // Renderitzar línees centrades - float centre_x = Defaults::Game::WIDTH / 2.0f; + float centre_x = Defaults::Game::WIDTH / 2.0F; text_.render_centered(copyright_original, {centre_x, y_line1}, escala_copy, spacing); text_.render_centered(copyright_port, {centre_x, y_line2}, escala_copy, spacing); diff --git a/source/game/escenes/escena_titol.hpp b/source/game/escenes/escena_titol.hpp index 3d2c6b5..8f27887 100644 --- a/source/game/escenes/escena_titol.hpp +++ b/source/game/escenes/escena_titol.hpp @@ -75,31 +75,31 @@ class EscenaTitol { float factor_lerp_; // Factor de lerp actual (0.0 → 1.0) // Constants - static constexpr float BRIGHTNESS_STARFIELD = 1.2f; // Brightness del starfield (>1.0 = més brillant) - static constexpr float DURACIO_FADE_IN = 3.0f; // Duració del fade-in del starfield (1.5 segons) - static constexpr float DURACIO_INIT = 4.0f; // Duració de l'estat INIT (2 segons) - static constexpr float DURACIO_TRANSITION = 2.5f; // Duració de la transició (1.5 segons) - static constexpr float ESPAI_ENTRE_LLETRES = 10.0f; // Espai entre lletres - static constexpr float BLINK_FREQUENCY = 3.0f; // Freqüència de parpelleig (3 Hz) - static constexpr float DURACIO_BLACK_SCREEN = 2.0f; // Duració pantalla negra (2 segons) + static constexpr float BRIGHTNESS_STARFIELD = 1.2F; // Brightness del starfield (>1.0 = més brillant) + static constexpr float DURACIO_FADE_IN = 3.0F; // Duració del fade-in del starfield (1.5 segons) + static constexpr float DURACIO_INIT = 4.0F; // Duració de l'estat INIT (2 segons) + static constexpr float DURACIO_TRANSITION = 2.5F; // Duració de la transició (1.5 segons) + static constexpr float ESPAI_ENTRE_LLETRES = 10.0F; // Espai entre lletres + static constexpr float BLINK_FREQUENCY = 3.0F; // Freqüència de parpelleig (3 Hz) + static constexpr float DURACIO_BLACK_SCREEN = 2.0F; // Duració pantalla negra (2 segons) static constexpr int MUSIC_FADE = 1500; // Duracio del fade de la musica del titol al començar a jugar // Constants d'animació del logo - static constexpr float ORBIT_AMPLITUDE_X = 4.0f; // Amplitud oscil·lació horitzontal (píxels) - static constexpr float ORBIT_AMPLITUDE_Y = 3.0f; // Amplitud oscil·lació vertical (píxels) - static constexpr float ORBIT_FREQUENCY_X = 0.8f; // Velocitat oscil·lació horitzontal (Hz) - static constexpr float ORBIT_FREQUENCY_Y = 1.2f; // Velocitat oscil·lació vertical (Hz) - static constexpr float ORBIT_PHASE_OFFSET = 1.57f; // Desfasament entre X i Y (90° per circular) + static constexpr float ORBIT_AMPLITUDE_X = 4.0F; // Amplitud oscil·lació horitzontal (píxels) + static constexpr float ORBIT_AMPLITUDE_Y = 3.0F; // Amplitud oscil·lació vertical (píxels) + static constexpr float ORBIT_FREQUENCY_X = 0.8F; // Velocitat oscil·lació horitzontal (Hz) + static constexpr float ORBIT_FREQUENCY_Y = 1.2F; // Velocitat oscil·lació vertical (Hz) + static constexpr float ORBIT_PHASE_OFFSET = 1.57F; // Desfasament entre X i Y (90° per circular) // Constants d'ombra del logo - static constexpr float SHADOW_DELAY = 0.5f; // Retard temporal de l'ombra (segons) - static constexpr float SHADOW_BRIGHTNESS = 0.4f; // Multiplicador de brillantor de l'ombra (0.0-1.0) - static constexpr float SHADOW_OFFSET_X = 2.0f; // Offset espacial X fix (píxels) - static constexpr float SHADOW_OFFSET_Y = 2.0f; // Offset espacial Y fix (píxels) + static constexpr float SHADOW_DELAY = 0.5F; // Retard temporal de l'ombra (segons) + static constexpr float SHADOW_BRIGHTNESS = 0.4F; // Multiplicador de brillantor de l'ombra (0.0-1.0) + static constexpr float SHADOW_OFFSET_X = 2.0F; // Offset espacial X fix (píxels) + static constexpr float SHADOW_OFFSET_Y = 2.0F; // Offset espacial Y fix (píxels) // Temporització de l'arrencada de l'animació - static constexpr float DELAY_INICI_ANIMACIO = 10.0f; // 10s estàtic abans d'animar - static constexpr float DURACIO_LERP = 2.0f; // 2s per arribar a amplitud completa + static constexpr float DELAY_INICI_ANIMACIO = 10.0F; // 10s estàtic abans d'animar + static constexpr float DURACIO_LERP = 2.0F; // 2s per arribar a amplitud completa // Mètodes privats void actualitzar(float delta_time); diff --git a/source/game/options.cpp b/source/game/options.cpp index 40b0127..2251b2d 100644 --- a/source/game/options.cpp +++ b/source/game/options.cpp @@ -261,7 +261,7 @@ static void loadWindowConfigFromYaml(const fkyaml::node& yaml) { if (win.contains("zoom_factor")) { try { auto val = win["zoom_factor"].get_value(); - window.zoom_factor = (val >= Defaults::Window::MIN_ZOOM && val <= 10.0f) + window.zoom_factor = (val >= Defaults::Window::MIN_ZOOM && val <= 10.0F) ? val : Defaults::Window::BASE_ZOOM; } catch (...) { @@ -396,7 +396,7 @@ static void loadAudioConfigFromYaml(const fkyaml::node& yaml) { if (aud.contains("volume")) { try { float val = aud["volume"].get_value(); - audio.volume = (val >= 0.0f && val <= 1.0f) ? val : Defaults::Audio::VOLUME; + audio.volume = (val >= 0.0F && val <= 1.0F) ? val : Defaults::Audio::VOLUME; } catch (...) { audio.volume = Defaults::Audio::VOLUME; } @@ -416,7 +416,7 @@ static void loadAudioConfigFromYaml(const fkyaml::node& yaml) { if (mus.contains("volume")) { try { float val = mus["volume"].get_value(); - audio.music.volume = (val >= 0.0f && val <= 1.0f) ? val : Defaults::Music::VOLUME; + audio.music.volume = (val >= 0.0F && val <= 1.0F) ? val : Defaults::Music::VOLUME; } catch (...) { audio.music.volume = Defaults::Music::VOLUME; } @@ -437,7 +437,7 @@ static void loadAudioConfigFromYaml(const fkyaml::node& yaml) { if (snd.contains("volume")) { try { float val = snd["volume"].get_value(); - audio.sound.volume = (val >= 0.0f && val <= 1.0f) ? val : Defaults::Sound::VOLUME; + audio.sound.volume = (val >= 0.0F && val <= 1.0F) ? val : Defaults::Sound::VOLUME; } catch (...) { audio.sound.volume = Defaults::Sound::VOLUME; } diff --git a/source/game/options.hpp b/source/game/options.hpp index 3d74cd7..d218863 100644 --- a/source/game/options.hpp +++ b/source/game/options.hpp @@ -12,16 +12,16 @@ struct Window { int width{640}; int height{480}; bool fullscreen{false}; - float zoom_factor{1.0f}; // Zoom level (0.5x to max_zoom) + float zoom_factor{1.0F}; // Zoom level (0.5x to max_zoom) }; struct Physics { - float rotation_speed{3.14f}; // rad/s - float acceleration{400.0f}; // px/s² - float max_velocity{120.0f}; // px/s - float friction{20.0f}; // px/s² - float enemy_speed{2.0f}; // unitats/frame - float bullet_speed{6.0f}; // unitats/frame + float rotation_speed{3.14F}; // rad/s + float acceleration{400.0F}; // px/s² + float max_velocity{120.0F}; // px/s + float friction{20.0F}; // px/s² + float enemy_speed{2.0F}; // unitats/frame + float bullet_speed{6.0F}; // unitats/frame }; struct Gameplay { @@ -35,19 +35,19 @@ struct Rendering { struct Music { bool enabled{true}; - float volume{0.8f}; + float volume{0.8F}; }; struct Sound { bool enabled{true}; - float volume{1.0f}; + float volume{1.0F}; }; struct Audio { Music music{}; Sound sound{}; bool enabled{true}; - float volume{1.0f}; + float volume{1.0F}; }; // Controles de jugadors diff --git a/source/game/stage_system/spawn_controller.cpp b/source/game/stage_system/spawn_controller.cpp index dcacd53..892894f 100644 --- a/source/game/stage_system/spawn_controller.cpp +++ b/source/game/stage_system/spawn_controller.cpp @@ -10,7 +10,7 @@ namespace StageSystem { SpawnController::SpawnController() : config_(nullptr), - temps_transcorregut_(0.0f), + temps_transcorregut_(0.0F), index_spawn_actual_(0), ship_position_(nullptr) {} @@ -33,7 +33,7 @@ void SpawnController::iniciar() { void SpawnController::reset() { spawn_queue_.clear(); - temps_transcorregut_ = 0.0f; + temps_transcorregut_ = 0.0F; index_spawn_actual_ = 0; } diff --git a/source/game/stage_system/stage_loader.cpp b/source/game/stage_system/stage_loader.cpp index 99f6dbe..11934c6 100644 --- a/source/game/stage_system/stage_loader.cpp +++ b/source/game/stage_system/stage_loader.cpp @@ -192,13 +192,13 @@ bool StageLoader::parse_multipliers(const fkyaml::node& yaml, MultiplicadorsDifi mult.tracking_strength = yaml["tracking_strength"].get_value(); // Validar rangs raonables - if (mult.velocitat < 0.1f || mult.velocitat > 5.0f) { + if (mult.velocitat < 0.1F || mult.velocitat > 5.0F) { std::cerr << "[StageLoader] Warning: speed_multiplier fora de rang (0.1-5.0)" << std::endl; } - if (mult.rotacio < 0.1f || mult.rotacio > 5.0f) { + if (mult.rotacio < 0.1F || mult.rotacio > 5.0F) { std::cerr << "[StageLoader] Warning: rotation_multiplier fora de rang (0.1-5.0)" << std::endl; } - if (mult.tracking_strength < 0.0f || mult.tracking_strength > 2.0f) { + if (mult.tracking_strength < 0.0F || mult.tracking_strength > 2.0F) { std::cerr << "[StageLoader] Warning: tracking_strength fora de rang (0.0-2.0)" << std::endl; } diff --git a/source/game/stage_system/stage_manager.cpp b/source/game/stage_system/stage_manager.cpp index aa4be38..0993564 100644 --- a/source/game/stage_system/stage_manager.cpp +++ b/source/game/stage_system/stage_manager.cpp @@ -14,7 +14,7 @@ StageManager::StageManager(const ConfigSistemaStages* config) : config_(config), estat_(EstatStage::LEVEL_START), stage_actual_(1), - timer_transicio_(0.0f) { + timer_transicio_(0.0F) { if (!config_) { std::cerr << "[StageManager] Error: config és null" << std::endl; } @@ -58,7 +58,7 @@ void StageManager::stage_completat() { bool StageManager::tot_completat() const { return stage_actual_ >= config_->metadata.total_stages && estat_ == EstatStage::LEVEL_COMPLETED && - timer_transicio_ <= 0.0f; + timer_transicio_ <= 0.0F; } const ConfigStage* StageManager::get_config_actual() const { @@ -110,7 +110,7 @@ void StageManager::canviar_estat(EstatStage nou_estat) { void StageManager::processar_init_hud(float delta_time) { timer_transicio_ -= delta_time; - if (timer_transicio_ <= 0.0f) { + if (timer_transicio_ <= 0.0F) { canviar_estat(EstatStage::LEVEL_START); } } @@ -118,7 +118,7 @@ void StageManager::processar_init_hud(float delta_time) { void StageManager::processar_level_start(float delta_time) { timer_transicio_ -= delta_time; - if (timer_transicio_ <= 0.0f) { + if (timer_transicio_ <= 0.0F) { canviar_estat(EstatStage::PLAYING); } } @@ -134,7 +134,7 @@ void StageManager::processar_playing(float delta_time, bool pausar_spawn) { void StageManager::processar_level_completed(float delta_time) { timer_transicio_ -= delta_time; - if (timer_transicio_ <= 0.0f) { + if (timer_transicio_ <= 0.0F) { // Advance to next stage stage_actual_++; diff --git a/source/game/title/ship_animator.cpp b/source/game/title/ship_animator.cpp index 3adeb37..6268738 100644 --- a/source/game/title/ship_animator.cpp +++ b/source/game/title/ship_animator.cpp @@ -59,11 +59,11 @@ void ShipAnimator::dibuixar() const { renderer_, nau.forma, nau.posicio_actual, - 0.0f, // angle (rotació 2D no utilitzada) + 0.0F, // angle (rotació 2D no utilitzada) nau.escala_actual, true, // dibuixar - 1.0f, // progress (sempre visible) - 1.0f // brightness (brillantor màxima) + 1.0F, // progress (sempre visible) + 1.0F // brightness (brillantor màxima) ); } } @@ -73,14 +73,14 @@ void ShipAnimator::start_entry_animation() { // Configurar nau P1 per a l'animació d'entrada naus_[0].estat = EstatNau::ENTERING; - naus_[0].temps_estat = 0.0f; + naus_[0].temps_estat = 0.0F; naus_[0].posicio_inicial = calcular_posicio_fora_pantalla(CLOCK_8_ANGLE); naus_[0].posicio_actual = naus_[0].posicio_inicial; naus_[0].escala_actual = naus_[0].escala_inicial; // Configurar nau P2 per a l'animació d'entrada naus_[1].estat = EstatNau::ENTERING; - naus_[1].temps_estat = 0.0f; + naus_[1].temps_estat = 0.0F; naus_[1].posicio_inicial = calcular_posicio_fora_pantalla(CLOCK_4_ANGLE); naus_[1].posicio_actual = naus_[1].posicio_inicial; naus_[1].escala_actual = naus_[1].escala_inicial; @@ -91,7 +91,7 @@ void ShipAnimator::trigger_exit_animation() { for (auto& nau : naus_) { // Canviar estat a EXITING nau.estat = EstatNau::EXITING; - nau.temps_estat = 0.0f; + nau.temps_estat = 0.0F; // Preservar posició actual (pot estar a mig camí si START es prem durant ENTERING) nau.posicio_inicial = nau.posicio_actual; @@ -105,8 +105,8 @@ void ShipAnimator::skip_to_floating_state() { // Posar ambdues naus directament en estat FLOATING for (auto& nau : naus_) { nau.estat = EstatNau::FLOATING; - nau.temps_estat = 0.0f; - nau.fase_oscilacio = 0.0f; + nau.temps_estat = 0.0F; + nau.fase_oscilacio = 0.0F; // Posar en posició objectiu (sense animació) nau.posicio_actual = nau.posicio_objectiu; @@ -133,7 +133,7 @@ void ShipAnimator::trigger_exit_animation_for_player(int jugador_id) { if (nau.jugador_id == jugador_id) { // Canviar estat a EXITING només per aquesta nau nau.estat = EstatNau::EXITING; - nau.temps_estat = 0.0f; + nau.temps_estat = 0.0F; // Preservar posició actual (pot estar a mig camí si START es prem durant ENTERING) nau.posicio_inicial = nau.posicio_actual; @@ -177,7 +177,7 @@ void ShipAnimator::actualitzar_entering(NauTitol& nau, float delta_time) { // Càlcul del progrés (restant el delay) float elapsed = nau.temps_estat - nau.entry_delay; - float progress = std::min(1.0f, elapsed / ENTRY_DURATION); + float progress = std::min(1.0F, elapsed / ENTRY_DURATION); // Aplicar easing (ease_out_quad per arribada suau) float eased_progress = Easing::ease_out_quad(progress); @@ -192,8 +192,8 @@ void ShipAnimator::actualitzar_entering(NauTitol& nau, float delta_time) { // Transicionar a FLOATING quan completi if (elapsed >= ENTRY_DURATION) { nau.estat = EstatNau::FLOATING; - nau.temps_estat = 0.0f; - nau.fase_oscilacio = 0.0f; // Reiniciar fase d'oscil·lació + nau.temps_estat = 0.0F; + nau.fase_oscilacio = 0.0F; // Reiniciar fase d'oscil·lació } } @@ -205,8 +205,8 @@ void ShipAnimator::actualitzar_floating(NauTitol& nau, float delta_time) { nau.fase_oscilacio += delta_time; // Oscil·lació sinusoïdal X/Y (paràmetres específics per nau) - float offset_x = nau.amplitude_x * std::sin(2.0f * Defaults::Math::PI * nau.frequency_x * nau.fase_oscilacio); - float offset_y = nau.amplitude_y * std::sin(2.0f * Defaults::Math::PI * nau.frequency_y * nau.fase_oscilacio + FLOAT_PHASE_OFFSET); + float offset_x = nau.amplitude_x * std::sin(2.0F * Defaults::Math::PI * nau.frequency_x * nau.fase_oscilacio); + float offset_y = nau.amplitude_y * std::sin(2.0F * Defaults::Math::PI * nau.frequency_y * nau.fase_oscilacio + FLOAT_PHASE_OFFSET); // Aplicar oscil·lació a la posició objectiu nau.posicio_actual.x = nau.posicio_objectiu.x + offset_x; @@ -222,7 +222,7 @@ void ShipAnimator::actualitzar_exiting(NauTitol& nau, float delta_time) { nau.temps_estat += delta_time; // Calcular progrés (0.0 → 1.0) - float progress = std::min(1.0f, nau.temps_estat / EXIT_DURATION); + float progress = std::min(1.0F, nau.temps_estat / EXIT_DURATION); // Aplicar easing (ease_in_quad per acceleració cap al punt de fuga) float eased_progress = Easing::ease_in_quad(progress); @@ -236,10 +236,10 @@ void ShipAnimator::actualitzar_exiting(NauTitol& nau, float delta_time) { nau.posicio_actual.y = Easing::lerp(nau.posicio_inicial.y, punt_fuga.y, eased_progress); // Escala redueix a 0 (simula Z → infinit) - nau.escala_actual = nau.escala_objectiu * (1.0f - eased_progress); + nau.escala_actual = nau.escala_objectiu * (1.0F - eased_progress); // Marcar invisible quan l'animació completi - if (progress >= 1.0f) { + if (progress >= 1.0F) { nau.visible = false; } } @@ -250,7 +250,7 @@ void ShipAnimator::configurar_nau_p1(NauTitol& nau) { // Estat inicial: FLOATING (per test estàtic) nau.estat = EstatNau::FLOATING; - nau.temps_estat = 0.0f; + nau.temps_estat = 0.0F; // Posicions (clock 8, bottom-left) nau.posicio_objectiu = {P1_TARGET_X(), P1_TARGET_Y()}; @@ -265,7 +265,7 @@ void ShipAnimator::configurar_nau_p1(NauTitol& nau) { nau.escala_inicial = ENTRY_SCALE_START; // Flotació - nau.fase_oscilacio = 0.0f; + nau.fase_oscilacio = 0.0F; // Paràmetres d'entrada nau.entry_delay = P1_ENTRY_DELAY; @@ -285,7 +285,7 @@ void ShipAnimator::configurar_nau_p2(NauTitol& nau) { // Estat inicial: FLOATING (per test estàtic) nau.estat = EstatNau::FLOATING; - nau.temps_estat = 0.0f; + nau.temps_estat = 0.0F; // Posicions (clock 4, bottom-right) nau.posicio_objectiu = {P2_TARGET_X(), P2_TARGET_Y()}; @@ -300,7 +300,7 @@ void ShipAnimator::configurar_nau_p2(NauTitol& nau) { nau.escala_inicial = ENTRY_SCALE_START; // Flotació - nau.fase_oscilacio = 0.0f; + nau.fase_oscilacio = 0.0F; // Paràmetres d'entrada nau.entry_delay = P2_ENTRY_DELAY; @@ -323,8 +323,8 @@ Punt ShipAnimator::calcular_posicio_fora_pantalla(float angle_rellotge) const { // ENTRY_OFFSET es calcula automàticament: (SHIP_MAX_RADIUS * ENTRY_SCALE_START) + ENTRY_OFFSET_MARGIN float extended_radius = CLOCK_RADIUS + ENTRY_OFFSET; - float x = Defaults::Game::WIDTH / 2.0f + extended_radius * std::cos(angle_rellotge); - float y = Defaults::Game::HEIGHT / 2.0f + extended_radius * std::sin(angle_rellotge); + float x = Defaults::Game::WIDTH / 2.0F + extended_radius * std::cos(angle_rellotge); + float y = Defaults::Game::HEIGHT / 2.0F + extended_radius * std::sin(angle_rellotge); return {x, y}; } diff --git a/source/legacy/.clang-format b/source/legacy/.clang-format new file mode 100644 index 0000000..47a38a9 --- /dev/null +++ b/source/legacy/.clang-format @@ -0,0 +1,2 @@ +DisableFormat: true +SortIncludes: Never diff --git a/source/legacy/.clang-tidy b/source/legacy/.clang-tidy new file mode 100644 index 0000000..bbae176 --- /dev/null +++ b/source/legacy/.clang-tidy @@ -0,0 +1,4 @@ +# source/external/.clang-tidy +Checks: '-*' +WarningsAsErrors: '' +HeaderFilterRegex: '' \ No newline at end of file diff --git a/source/legacy/asteroids.cpp b/source/legacy/asteroids.cpp index 171bb31..464815d 100644 --- a/source/legacy/asteroids.cpp +++ b/source/legacy/asteroids.cpp @@ -59,13 +59,13 @@ std::vector bales(MAX_BALES); virt : ^pvirt; procedure volca; -var i : word; +var i ; word; begin for i:=1 to 38400 do mem[$A000:i]:=mem[seg(virt^):i]; end; procedure crear_poligon_regular(var pol : poligon; n : byte; r : real); -var i : word; +var i ; word; act, interval : real; aux : ipunt; begin {getmem(pol.ipunts,{n*464000);}