Lint: rename de helpers file-static y constexpr locales
Tanda local de identifier-naming: ningún símbolo cross-file, todo contenido en su propio TU. De paso traduce los catalán/spanish a inglés allá donde aplica. - shape_renderer.cpp: apply_3d_rotation → apply3dRotation, transform_point → transformPoint, perspective_factor → PERSPECTIVE_FACTOR (constexpr). - debris_manager.cpp: transform_point → transformPoint (otro file-static con el mismo nombre, no comparte símbolo con shape_renderer). - logo_scene.cpp: calcular_progress_letra → computeLetterProgress. - vector_text.cpp: char_width/char_height → BASE_CHAR_WIDTH/BASE_CHAR_HEIGHT (el sufijo BASE_ evita el conflicto con la macro CHAR_WIDTH de Windows headers que clang-tidy detectó). - floating_score_manager.cpp::draw: constexpr scale/spacing → SCALE/SPACING. - game_scene.cpp::dibuixar_missatge_stage: escala_base/spacing → BASE_SCALE/SPACING (constexpr locales). - game_scene.cpp::dibuixar_continue: constexpr spacing → SPACING. - game_scene.cpp en stepGameOver: constexpr scale/spacing → SCALE/SPACING. - ship_animator.cpp::actualizar_exiting: constexpr Vec2 punt_fuga → VANISHING_POINT. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
424d0d2b89
commit
1214599c4c
8 files changed
+42
-42
No files matched your search
@@ -16,7 +16,7 @@ namespace Effects {
|
||||
|
||||
// Helper: transformar point con rotación, scale i traslación
|
||||
// (Copiat de shape_renderer.cpp:12-34)
|
||||
static auto transform_point(const Vec2& point, const Vec2& shape_centre, const Vec2& position, float angle, float scale) -> Vec2 {
|
||||
static auto transformPoint(const Vec2& point, const Vec2& shape_centre, const Vec2& position, float angle, float scale) -> Vec2 {
|
||||
// 1. Centrar el point respecte al centro de la shape
|
||||
float centered_x = point.x - shape_centre.x;
|
||||
float centered_y = point.y - shape_centre.y;
|
||||
@@ -86,9 +86,9 @@ void DebrisManager::explode(const std::shared_ptr<Graphics::Shape>& shape,
|
||||
for (const auto& [local_p1, local_p2] : segments) {
|
||||
// 1. Transformar points locals → coordenades mundials
|
||||
Vec2 world_p1 =
|
||||
transform_point(local_p1, shape_centre, centro, angle, scale);
|
||||
transformPoint(local_p1, shape_centre, centro, angle, scale);
|
||||
Vec2 world_p2 =
|
||||
transform_point(local_p2, shape_centre, centro, angle, scale);
|
||||
transformPoint(local_p2, shape_centre, centro, angle, scale);
|
||||
|
||||
// 2. Trobar slot lliure
|
||||
Debris* debris = findFreeSlot();
|
||||
|
||||
@@ -64,10 +64,10 @@ void FloatingScoreManager::draw() {
|
||||
}
|
||||
|
||||
// Renderizar centrat con brightness (fade)
|
||||
constexpr float scale = Defaults::FloatingScore::SCALE;
|
||||
constexpr float spacing = Defaults::FloatingScore::SPACING;
|
||||
constexpr float SCALE = Defaults::FloatingScore::SCALE;
|
||||
constexpr float SPACING = Defaults::FloatingScore::SPACING;
|
||||
|
||||
text_.renderCentered(pf.text, pf.position, scale, spacing, pf.brightness);
|
||||
text_.renderCentered(pf.text, pf.position, SCALE, SPACING, pf.brightness);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -528,15 +528,15 @@ void GameScene::draw() {
|
||||
|
||||
// Draw centered "GAME OVER" text
|
||||
const std::string game_over_text = "GAME OVER";
|
||||
constexpr float scale = Defaults::Game::GameOverScreen::TEXT_SCALE;
|
||||
constexpr float spacing = Defaults::Game::GameOverScreen::TEXT_SPACING;
|
||||
constexpr float SCALE = Defaults::Game::GameOverScreen::TEXT_SCALE;
|
||||
constexpr float SPACING = Defaults::Game::GameOverScreen::TEXT_SPACING;
|
||||
|
||||
// Calcular centro de l'àrea de juego 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);
|
||||
|
||||
text_.renderCentered(game_over_text, {.x = centre_x, .y = centre_y}, scale, spacing);
|
||||
text_.renderCentered(game_over_text, {.x = centre_x, .y = centre_y}, SCALE, SPACING);
|
||||
|
||||
dibuixar_marcador();
|
||||
return;
|
||||
@@ -790,8 +790,8 @@ auto GameScene::buildScoreboard() const -> std::string {
|
||||
// [NEW] Stage system helper methods
|
||||
|
||||
void GameScene::dibuixar_missatge_stage(const std::string& message) {
|
||||
constexpr float escala_base = 1.0F;
|
||||
constexpr float spacing = 2.0F;
|
||||
constexpr float BASE_SCALE = 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;
|
||||
@@ -834,15 +834,15 @@ void GameScene::dibuixar_missatge_stage(const std::string& message) {
|
||||
// ===================================================
|
||||
|
||||
// Calculate text width at base scale (using FULL message for position calculation)
|
||||
float text_width_at_base = text_.get_text_width(message, escala_base, spacing);
|
||||
float text_width_at_base = text_.get_text_width(message, BASE_SCALE, SPACING);
|
||||
|
||||
// Auto-scale if text exceeds max width
|
||||
float scale = (text_width_at_base <= max_width)
|
||||
? escala_base
|
||||
? BASE_SCALE
|
||||
: max_width / text_width_at_base;
|
||||
|
||||
// Recalculate dimensions with final scale (using FULL message for centering)
|
||||
float full_text_width = text_.get_text_width(message, scale, spacing);
|
||||
float full_text_width = text_.get_text_width(message, scale, SPACING);
|
||||
float text_height = text_.get_text_height(scale);
|
||||
|
||||
// Calculate position as if FULL text was there (for fixed position typewriter)
|
||||
@@ -851,7 +851,7 @@ void GameScene::dibuixar_missatge_stage(const std::string& message) {
|
||||
|
||||
// Render only the partial message (typewriter effect)
|
||||
Vec2 pos = {.x = x, .y = y};
|
||||
text_.render(partial_message, pos, scale, spacing);
|
||||
text_.render(partial_message, pos, scale, SPACING);
|
||||
}
|
||||
|
||||
// ========================================
|
||||
@@ -910,7 +910,7 @@ void GameScene::disparar_bala(uint8_t player_id) {
|
||||
|
||||
void GameScene::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";
|
||||
@@ -920,7 +920,7 @@ void GameScene::dibuixar_continue() {
|
||||
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_.renderCentered(continue_text, {.x = centre_x, .y = centre_y_continue}, escala_continue, spacing);
|
||||
text_.renderCentered(continue_text, {.x = centre_x, .y = centre_y_continue}, escala_continue, SPACING);
|
||||
|
||||
// Countdown number (using constants)
|
||||
const std::string counter_str = std::to_string(continue_counter_);
|
||||
@@ -929,7 +929,7 @@ void GameScene::dibuixar_continue() {
|
||||
|
||||
float centre_y_counter = play_area.y + (play_area.h * y_ratio_counter);
|
||||
|
||||
text_.renderCentered(counter_str, {.x = centre_x, .y = centre_y_counter}, escala_counter, spacing);
|
||||
text_.renderCentered(counter_str, {.x = centre_x, .y = centre_y_counter}, escala_counter, SPACING);
|
||||
|
||||
// "CONTINUES LEFT" (conditional + using constants)
|
||||
if (!Defaults::Game::INFINITE_CONTINUES) {
|
||||
@@ -939,7 +939,7 @@ void GameScene::dibuixar_continue() {
|
||||
|
||||
float centre_y_info = play_area.y + (play_area.h * y_ratio_info);
|
||||
|
||||
text_.renderCentered(continues_text, {.x = centre_x, .y = centre_y_info}, escala_info, spacing);
|
||||
text_.renderCentered(continues_text, {.x = centre_x, .y = centre_y_info}, escala_info, SPACING);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ using Option = SceneContext::Option;
|
||||
|
||||
// Helper: calcular el progrés individual de una lletra
|
||||
// en función del progrés global (efecte seqüencial)
|
||||
static auto calcular_progress_letra(size_t letra_index, size_t num_letras, float global_progress, float threshold) -> float {
|
||||
static auto computeLetterProgress(size_t letra_index, size_t num_letras, float global_progress, float threshold) -> float {
|
||||
if (num_letras == 0) {
|
||||
return 1.0F;
|
||||
}
|
||||
@@ -232,7 +232,7 @@ void LogoScene::update(float delta_time) {
|
||||
|
||||
for (size_t i = 0; i < lletres_.size() && i < so_reproduit_.size(); i++) {
|
||||
if (!so_reproduit_[i]) {
|
||||
float letra_progress = calcular_progress_letra(
|
||||
float letra_progress = computeLetterProgress(
|
||||
i,
|
||||
lletres_.size(),
|
||||
global_progress,
|
||||
@@ -300,7 +300,7 @@ void LogoScene::draw() {
|
||||
for (size_t i = 0; i < lletres_.size(); i++) {
|
||||
const auto& lletra = lletres_[i];
|
||||
|
||||
float letra_progress = calcular_progress_letra(
|
||||
float letra_progress = computeLetterProgress(
|
||||
i,
|
||||
lletres_.size(),
|
||||
global_progress,
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace StageSystem {
|
||||
|
||||
// Estats del stage system
|
||||
enum class EstatStage {
|
||||
enum class EstatStage : std::uint8_t {
|
||||
INIT_HUD, // Animación inicial del HUD (3s)
|
||||
LEVEL_START, // Pantalla "ENEMY INCOMING" (3s)
|
||||
PLAYING, // Gameplay normal
|
||||
|
||||
@@ -233,12 +233,12 @@ void ShipAnimator::actualitzar_exiting(TitleShip& ship, float delta_time) {
|
||||
float eased_progress = Easing::ease_in_quad(progress);
|
||||
|
||||
// Vec2 de fuga (centro del starfield)
|
||||
constexpr Vec2 punt_fuga{.x = VANISHING_POINT_X, .y = VANISHING_POINT_Y};
|
||||
constexpr Vec2 VANISHING_POINT{.x = VANISHING_POINT_X, .y = VANISHING_POINT_Y};
|
||||
|
||||
// Lerp posición hacia el point de fuga (preservar posición inicial actual)
|
||||
// Nota: initial_position conté la posición on estava cuando es va activar EXITING
|
||||
ship.current_position.x = Easing::lerp(ship.initial_position.x, punt_fuga.x, eased_progress);
|
||||
ship.current_position.y = Easing::lerp(ship.initial_position.y, punt_fuga.y, eased_progress);
|
||||
ship.current_position.x = Easing::lerp(ship.initial_position.x, VANISHING_POINT.x, eased_progress);
|
||||
ship.current_position.y = Easing::lerp(ship.initial_position.y, VANISHING_POINT.y, eased_progress);
|
||||
|
||||
// Escala redueix a 0 (simula Z → infinit)
|
||||
ship.current_scale = ship.target_scale * (1.0F - eased_progress);
|
||||
|
||||
Reference in new issue
Block a user