refactor: esborrar aliases morts de game/constants.hpp (#24)

Esborrats:
- Constants::MARGIN_LEFT/RIGHT/TOP/BOTTOM (zero callers; tots els
  call-sites llegeixen Defaults::Zones::PLAYAREA directament).
- Constants::VELOCITAT i VELOCITAT_MAX (zero callers; eren els últims
  lectors de Defaults::Physics::ENEMY_SPEED/BULLET_SPEED).

Es mantenen MAX_ORNIS, MAX_BALES (sí usats a game_scene.hpp) i PI,
més els helpers de zona.

Habilita el hallazgo #25 (eliminar Defaults::Physics::ENEMY_SPEED /
BULLET_SPEED / VELOCITY_SCALE) — ja sense lectors.

Hallazgo #24 de CODE_REVIEW.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-20 18:18:12 +02:00
parent 11e9d6569b
commit a0c1c8342f
+33 -46
View File
@@ -2,58 +2,45 @@
#include "core/defaults.hpp" #include "core/defaults.hpp"
// Aliases para backward compatibility con codi existent // Aliases utilitzats per simplificar lectures freqüents de Defaults::
// Permet usar Constants::MARGIN_LEFT en lloc de Defaults::Game::MARGIN_LEFT
namespace Constants { namespace Constants {
// Márgenes de l'àrea de juego (derivats de Defaults::Zones::GAME) // Límits de objectes
constexpr int MARGIN_LEFT = static_cast<int>(Defaults::Zones::PLAYAREA.x); constexpr int MAX_ORNIS = Defaults::Entities::MAX_ORNIS;
constexpr int MARGIN_RIGHT = constexpr int MAX_BALES = Defaults::Entities::MAX_BALES;
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 // Matemàtiques
constexpr int MAX_ORNIS = Defaults::Entities::MAX_ORNIS; constexpr float PI = Defaults::Math::PI;
constexpr int MAX_BALES = Defaults::Entities::MAX_BALES;
// Velocitats (valors legacy del codi Pascal) // Helpers per comprovar límits de zona
constexpr int VELOCITAT = static_cast<int>(Defaults::Physics::ENEMY_SPEED); inline auto isInPlayArea(float x, float y) -> bool {
constexpr int VELOCITAT_MAX = static_cast<int>(Defaults::Physics::BULLET_SPEED); const SDL_FPoint POINT = {x, y};
return SDL_PointInRectFloat(&POINT, &Defaults::Zones::PLAYAREA);
}
// Matemàtiques inline void getPlayAreaBounds(float& min_x, float& max_x, float& min_y, float& max_y) {
constexpr float PI = Defaults::Math::PI; 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;
}
// Helpers per comprovar límits de zona // Obtenir límits segurs (compensant radi de l'entidad)
inline auto isInPlayArea(float x, float y) -> bool { inline void getSafePlayAreaBounds(float radi, float& min_x, float& max_x, float& min_y, float& max_y) {
const SDL_FPoint POINT = {x, y}; const auto& zona = Defaults::Zones::PLAYAREA;
return SDL_PointInRectFloat(&POINT, &Defaults::Zones::PLAYAREA); constexpr float MARGE_SEGURETAT = 10.0F; // Safety margin
}
inline void getPlayAreaBounds(float& min_x, float& max_x, float& min_y, float& max_y) { min_x = zona.x + radi + MARGE_SEGURETAT;
const auto& zona = Defaults::Zones::PLAYAREA; max_x = zona.x + zona.w - radi - MARGE_SEGURETAT;
min_x = zona.x; min_y = zona.y + radi + MARGE_SEGURETAT;
max_x = zona.x + zona.w; max_y = zona.y + zona.h - radi - MARGE_SEGURETAT;
min_y = zona.y; }
max_y = zona.y + zona.h;
}
// Obtenir límits segurs (compensant radi de l'entidad) // Obtenir centro de l'àrea de juego
inline void getSafePlayAreaBounds(float radi, float& min_x, float& max_x, float& min_y, float& max_y) { inline void getPlayAreaCenter(float& centre_x, float& centre_y) {
const auto& zona = Defaults::Zones::PLAYAREA; const auto& zona = Defaults::Zones::PLAYAREA;
constexpr float MARGE_SEGURETAT = 10.0F; // Safety margin centre_x = zona.x + (zona.w / 2.0F);
centre_y = zona.y + (zona.h / 2.0F);
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 getPlayAreaCenter(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 } // namespace Constants