c80212adb9
Tanda de identifier-naming de variables y constantes locales a funciones
o archivos. Ninguno cross-file (los símbolos públicos quedan para una
pasada manual con VS Code).
- audio_adapter.cpp: path → PATH (const local en 3 funciones).
- vector_text.cpp: symbols → SYMBOLS, char_width_scaled → CHAR_WIDTH_SCALED,
char_height_scaled → CHAR_HEIGHT_SCALED, spacing_scaled → SPACING_SCALED
(const locales en render/renderCentered/get_text_width).
- physics_world.cpp: acceleration → ACCELERATION (const local en update).
- constants.hpp::dins_zona_joc: point → POINT.
- game_scene.cpp:
- stepGameOver: game_over_text → GAME_OVER_TEXT.
- dibuixar_marcador: scale/spacing → SCALE/SPACING (const), y la ref
local 'scoreboard' (const SDL_FRect&) → 'scoreboard_zone' para no
colisionar con Defaults::Zones::SCOREBOARD (las refs no son
"constant" según el .clang-tidy y deben ser lower_case).
- dibuixar_missatge_stage: max_width → MAX_WIDTH (const local).
- dibuixar_continue: continue_text/counter_str/continues_text →
UPPER_CASE.
- title_scene.cpp::draw (sección MAIN): spacing → SPACING, main_text →
MAIN_TEXT, escala_main → MAIN_SCALE.
- shape_renderer.cpp: const Vec2& SHAPE_CENTRE → shape_centre (es ref,
no constant).
- collision_system.cpp: const Vec2& POS_ENEMIC → enemy_pos (ref + traducción).
- init_hud_animator.cpp: refs ZONA → zone (en 2 funciones), SCOREBOARD →
scoreboard_zone (sin colisionar con Defaults::Zones::SCOREBOARD).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
60 lines
2.2 KiB
C++
60 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include "core/defaults.hpp"
|
|
|
|
// Aliases para backward compatibility con codi existent
|
|
// Permet usar Constants::MARGIN_LEFT en lloc de Defaults::Game::MARGIN_LEFT
|
|
|
|
namespace Constants {
|
|
// Márgenes de l'àrea de juego (derivats de Defaults::Zones::GAME)
|
|
constexpr int MARGIN_LEFT = static_cast<int>(Defaults::Zones::PLAYAREA.x);
|
|
constexpr int MARGIN_RIGHT =
|
|
static_cast<int>(Defaults::Zones::PLAYAREA.x + Defaults::Zones::PLAYAREA.w);
|
|
constexpr int MARGIN_TOP = static_cast<int>(Defaults::Zones::PLAYAREA.y);
|
|
constexpr int MARGIN_BOTTOM =
|
|
static_cast<int>(Defaults::Zones::PLAYAREA.y + Defaults::Zones::PLAYAREA.h);
|
|
|
|
// Límits de objectes
|
|
constexpr int MAX_ORNIS = Defaults::Entities::MAX_ORNIS;
|
|
constexpr int MAX_BALES = Defaults::Entities::MAX_BALES;
|
|
|
|
// Velocitats (valors legacy del codi Pascal)
|
|
constexpr int VELOCITAT = static_cast<int>(Defaults::Physics::ENEMY_SPEED);
|
|
constexpr int VELOCITAT_MAX = static_cast<int>(Defaults::Physics::BULLET_SPEED);
|
|
|
|
// Matemàtiques
|
|
constexpr float PI = Defaults::Math::PI;
|
|
|
|
// Helpers per comprovar límits de zona
|
|
inline auto dins_zona_joc(float x, float y) -> bool {
|
|
const SDL_FPoint POINT = {x, y};
|
|
return SDL_PointInRectFloat(&POINT, &Defaults::Zones::PLAYAREA);
|
|
}
|
|
|
|
inline void obtenir_limits_zona(float& min_x, float& max_x, float& min_y, float& max_y) {
|
|
const auto& zona = Defaults::Zones::PLAYAREA;
|
|
min_x = zona.x;
|
|
max_x = zona.x + zona.w;
|
|
min_y = zona.y;
|
|
max_y = zona.y + zona.h;
|
|
}
|
|
|
|
// Obtenir límits segurs (compensant radi de l'entidad)
|
|
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
|
|
|
|
min_x = zona.x + radi + MARGE_SEGURETAT;
|
|
max_x = zona.x + zona.w - radi - MARGE_SEGURETAT;
|
|
min_y = zona.y + radi + MARGE_SEGURETAT;
|
|
max_y = zona.y + zona.h - radi - MARGE_SEGURETAT;
|
|
}
|
|
|
|
// Obtenir centro de l'àrea de juego
|
|
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);
|
|
}
|
|
} // namespace Constants
|