62 lines
2.3 KiB
C++
62 lines
2.3 KiB
C++
#pragma once
|
|
|
|
#include "core/defaults.hpp"
|
|
|
|
// Aliases per a backward compatibility amb codi existent
|
|
// Permet usar Constants::MARGE_ESQ en lloc de Defaults::Game::MARGIN_LEFT
|
|
|
|
namespace Constants {
|
|
// Marges de l'àrea de joc (derivats de Defaults::Zones::GAME)
|
|
constexpr int MARGE_ESQ = static_cast<int>(Defaults::Zones::PLAYAREA.x);
|
|
constexpr int MARGE_DRET =
|
|
static_cast<int>(Defaults::Zones::PLAYAREA.x + Defaults::Zones::PLAYAREA.w);
|
|
constexpr int MARGE_DALT = static_cast<int>(Defaults::Zones::PLAYAREA.y);
|
|
constexpr int MARGE_BAIX =
|
|
static_cast<int>(Defaults::Zones::PLAYAREA.y + Defaults::Zones::PLAYAREA.h);
|
|
|
|
// Límits de polígons i objectes
|
|
constexpr int MAX_IPUNTS = Defaults::Entities::MAX_IPUNTS;
|
|
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 bool dins_zona_joc(float x, float y) {
|
|
const SDL_FPoint punt = {x, y};
|
|
return SDL_PointInRectFloat(&punt, &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'entitat)
|
|
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 centre de l'àrea de joc
|
|
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
|