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:
+17
-30
@@ -2,45 +2,32 @@
|
||||
|
||||
#include "core/defaults.hpp"
|
||||
|
||||
// Aliases para backward compatibility con codi existent
|
||||
// Permet usar Constants::MARGIN_LEFT en lloc de Defaults::Game::MARGIN_LEFT
|
||||
// Aliases utilitzats per simplificar lectures freqüents de Defaults::
|
||||
|
||||
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;
|
||||
|
||||
// Límits de objectes
|
||||
constexpr int MAX_ORNIS = Defaults::Entities::MAX_ORNIS;
|
||||
constexpr int MAX_BALES = Defaults::Entities::MAX_BALES;
|
||||
// Matemàtiques
|
||||
constexpr float PI = Defaults::Math::PI;
|
||||
|
||||
// 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 isInPlayArea(float x, float y) -> bool {
|
||||
// Helpers per comprovar límits de zona
|
||||
inline auto isInPlayArea(float x, float y) -> bool {
|
||||
const SDL_FPoint POINT = {x, y};
|
||||
return SDL_PointInRectFloat(&POINT, &Defaults::Zones::PLAYAREA);
|
||||
}
|
||||
}
|
||||
|
||||
inline void getPlayAreaBounds(float& min_x, float& max_x, float& min_y, float& max_y) {
|
||||
inline void getPlayAreaBounds(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 getSafePlayAreaBounds(float radi, float& min_x, float& max_x, float& min_y, float& max_y) {
|
||||
// Obtenir límits segurs (compensant radi de l'entidad)
|
||||
inline void getSafePlayAreaBounds(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
|
||||
|
||||
@@ -48,12 +35,12 @@ inline void getSafePlayAreaBounds(float radi, float& min_x, float& max_x, float&
|
||||
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) {
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user