bbbb8d47ae
Identifier-naming: rename de métodos públicos y cross-file al inglés
(camelBack), traducción de campos y locales en el proceso (TitleShip,
StageManager, SpawnController, ShipAnimator, helpers de PlayArea, etc.).
Refactor por cognitive-complexity (>25): GameScene::draw (59→3) con 9
helpers de estado, PhysicsWorld::resolveBodyCollisions (35→5) extrayendo
resolveBodyPair, Options::load{Window,Physics,Audio}ConfigFromYaml
(32/49/57→5/2/3) con templates readField, TitleScene::update (68→4) con
5 sub-pasos por estado + handleSkipInput/handleStartInput +
triggerExitForJoinedPlayers, DebrisManager::explode (39→3) con
extractSegments/spawnDebris/applyAngularVelocity/applyVisualRotation.
use-anyofallof: bucles → std::ranges::any_of/all_of en Input,
ShipAnimator y SpawnController.
readability-static-accessed-through-instance: Director::run y
VectorText::getTextWidth/Height invocados por clase.
readability-convert-member-functions-to-static: ResourcePack::decryptData.
unused-includes: eliminación de <utility>, <cstdint>, <vector>,
<iostream>, defaults.hpp y otros no usados directamente en headers y
unidades de traducción. Restablecido core/defaults.hpp en title_scene.cpp
(falsa "unused" del header).
Bug fix: eliminado isActive() duplicado en Bullet (redeclaración tras
rename de esta_activa→isActive que chocaba con el override de Entity).
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 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) {
|
|
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) {
|
|
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 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
|