HC-03: geometria del mapa traslladada de map.hpp al YAML de la piràmide

El bloc `geometry:` de pyramid.yaml porta les 9 constants base (grid, sarc,
pitch, HUD, murs); els derivats (corridor, board, origin, playfield) es
recalculen al `Map::loadFrom()`. `constexpr` passa a `const` on calia i
els membres estàtics adopten snake_case. Desbloqueja la iteració
"pirámide a pirámide" sense recompilar.
This commit is contained in:
JailDesigner committed 2026-04-20 17:32:56 +02:00
1 parent b895475716
commit e6c7f0dcfb
6 files changed
+153 -83

No files matched your search

+12 -12
View File
@@ -78,12 +78,12 @@ void Player::update(float delta_time) {
// Límits de la zona jugable: la caixa de col·lisió no pot eixir del
// playfield (muros). El cap del sprite sí pot sobresortir per damunt.
constexpr auto MIN_X = static_cast<float>(Map::PLAYFIELD_X - COLLISION_X_OFFSET);
constexpr auto MAX_X = static_cast<float>(
Map::PLAYFIELD_X + Map::PLAYFIELD_W - COLLISION_X_OFFSET - COLLISION_SIZE);
constexpr auto MIN_Y = static_cast<float>(Map::PLAYFIELD_Y - COLLISION_Y_OFFSET);
constexpr auto MAX_Y = static_cast<float>(
Map::PLAYFIELD_Y + Map::PLAYFIELD_H - COLLISION_Y_OFFSET - COLLISION_SIZE);
const auto MIN_X = static_cast<float>(Map::playfield_x - COLLISION_X_OFFSET);
const auto MAX_X = static_cast<float>(
Map::playfield_x + Map::playfield_w - COLLISION_X_OFFSET - COLLISION_SIZE);
const auto MIN_Y = static_cast<float>(Map::playfield_y - COLLISION_Y_OFFSET);
const auto MAX_Y = static_cast<float>(
Map::playfield_y + Map::playfield_h - COLLISION_Y_OFFSET - COLLISION_SIZE);
setPosX(std::clamp(getPosX(), MIN_X, MAX_X));
setPosY(std::clamp(getPosY(), MIN_Y, MAX_Y));
}
@@ -100,14 +100,14 @@ auto Player::baseBox() const -> SDL_FRect {
void Player::snapToHorizontalLane(float delta_time) {
// Lanes en posY: base + i·PITCH_Y per a i ∈ [0, GRID_ROWS]. Correspon a
// la caixa de col·lisió ocupant exactament un passadís horitzontal.
constexpr auto BASE = static_cast<float>(Map::PLAYFIELD_Y - COLLISION_Y_OFFSET);
constexpr auto PITCH = static_cast<float>(Map::PITCH_Y);
const auto BASE = static_cast<float>(Map::playfield_y - COLLISION_Y_OFFSET);
const auto PITCH = static_cast<float>(Map::pitch_y);
constexpr auto THRESHOLD = static_cast<float>(COLLISION_SIZE) / 2.0F;
const auto IDX = std::clamp(
static_cast<int>(std::round((getPosY() - BASE) / PITCH)),
0,
Map::GRID_ROWS);
Map::grid_rows);
const float LANE = BASE + (static_cast<float>(IDX) * PITCH);
const float DY = LANE - getPosY();
@@ -120,14 +120,14 @@ void Player::snapToHorizontalLane(float delta_time) {
}
void Player::snapToVerticalLane(float delta_time) {
constexpr auto BASE = static_cast<float>(Map::PLAYFIELD_X - COLLISION_X_OFFSET);
constexpr auto PITCH = static_cast<float>(Map::PITCH_X);
const auto BASE = static_cast<float>(Map::playfield_x - COLLISION_X_OFFSET);
const auto PITCH = static_cast<float>(Map::pitch_x);
constexpr auto THRESHOLD = static_cast<float>(COLLISION_SIZE) / 2.0F;
const auto IDX = std::clamp(
static_cast<int>(std::round((getPosX() - BASE) / PITCH)),
0,
Map::GRID_COLS);
Map::grid_cols);
const float LANE = BASE + (static_cast<float>(IDX) * PITCH);
const float DX = LANE - getPosX();