aa0abd9ae1
defaults.hpp tenia 527 línies amb 17 namespaces de dominis distints (Window, Game, Zones, Entities, Palette, Ship, Physics, Math, Brightness, Rendering, Audio, Music, Sound, Controls, Enemies, Title, FloatingScore). 22 .cpp/.hpp l'incloïen, així que tocar una constant forçava recompilar pràcticament tot. Es divideix en 15 subfitxers (un per namespace, fusionant Music/Sound a audio.hpp i unificant els dos blocs Game duplicats en un sol): defaults/window.hpp defaults/audio.hpp defaults/game.hpp defaults/controls.hpp defaults/zones.hpp defaults/enemies.hpp defaults/entities.hpp defaults/title.hpp defaults/palette.hpp defaults/floating_score.hpp defaults/ship.hpp defaults/math.hpp defaults/physics.hpp defaults/brightness.hpp defaults/rendering.hpp Cross-deps explícites (#include en lloc d'order-of-declaration): zones.hpp -> game.hpp (per Game::WIDTH/HEIGHT) enemies.hpp -> entities.hpp (per SHIP_RADIUS) title.hpp -> game.hpp, math.hpp + <cmath> defaults.hpp queda com a umbrella que inclou els 15 subfitxers. Els 22 includers existents no requereixen cap canvi. Codi nou pot incloure el subfitxer concret per millorar la compilació incremental. Hallazgos #22 i #30 de CODE_REVIEW.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
92 lines
4.2 KiB
C++
92 lines
4.2 KiB
C++
// game.hpp - Dimensions del joc i regles de partida (vides, durades, colisions)
|
|
// © 2026 JailDesigner
|
|
|
|
#pragma once
|
|
|
|
namespace Defaults::Game {
|
|
|
|
// Dimensiones base del juego (coordenadas lógicas, 16:9)
|
|
constexpr int WIDTH = 1280;
|
|
constexpr int HEIGHT = 720;
|
|
|
|
// Regles de partida
|
|
constexpr int STARTING_LIVES = 3; // Initial lives
|
|
constexpr float DEATH_DURATION = 3.0F; // Seconds of death animation
|
|
constexpr float GAME_OVER_DURATION = 5.0F; // Seconds to display game over
|
|
constexpr float COLLISION_SHIP_ENEMY_AMPLIFIER = 0.80F; // 80% hitbox (generous)
|
|
constexpr float COLLISION_BULLET_ENEMY_AMPLIFIER = 1.15F; // 115% hitbox (generous)
|
|
|
|
// Friendly fire system
|
|
constexpr bool FRIENDLY_FIRE_ENABLED = true; // Activar friendly fire
|
|
constexpr float COLLISION_BULLET_PLAYER_AMPLIFIER = 1.0F; // Hitbox exacto (100%)
|
|
constexpr float BULLET_GRACE_PERIOD = 0.2F; // Inmunidad post-disparo (s)
|
|
|
|
// Transición LEVEL_START (mensajes aleatorios PRE-level)
|
|
constexpr float LEVEL_START_DURATION = 3.0F; // Duración total
|
|
constexpr float LEVEL_START_TYPING_RATIO = 0.3F; // 30% escribiendo, 70% mostrando
|
|
|
|
// Transición LEVEL_COMPLETED (mensaje "GOOD JOB COMMANDER!")
|
|
constexpr float LEVEL_COMPLETED_DURATION = 3.0F; // Duración total
|
|
constexpr float LEVEL_COMPLETED_TYPING_RATIO = 0.0F; // 0.0 = sin typewriter (directo)
|
|
|
|
// Transición INIT_HUD (animación inicial del HUD)
|
|
constexpr float INIT_HUD_DURATION = 3.0F; // Duración total del estado
|
|
|
|
// Ratios de animación (inicio y fin como porcentajes del tiempo total)
|
|
// RECT (rectángulo de márgenes)
|
|
constexpr float INIT_HUD_RECT_RATIO_INIT = 0.30F;
|
|
constexpr float INIT_HUD_RECT_RATIO_END = 0.85F;
|
|
|
|
// SCORE (marcador de puntuación)
|
|
constexpr float INIT_HUD_SCORE_RATIO_INIT = 0.60F;
|
|
constexpr float INIT_HUD_SCORE_RATIO_END = 0.90F;
|
|
|
|
// SHIP1 (nave player 1)
|
|
constexpr float INIT_HUD_SHIP1_RATIO_INIT = 0.0F;
|
|
constexpr float INIT_HUD_SHIP1_RATIO_END = 1.0F;
|
|
|
|
// SHIP2 (nave player 2)
|
|
constexpr float INIT_HUD_SHIP2_RATIO_INIT = 0.20F;
|
|
constexpr float INIT_HUD_SHIP2_RATIO_END = 1.0F;
|
|
|
|
// Posición inicial de la nave en INIT_HUD (75% de altura de zona de juego)
|
|
constexpr float INIT_HUD_SHIP_START_Y_RATIO = 0.75F; // 75% desde el top de PLAYAREA
|
|
|
|
// Spawn positions (distribución horizontal para 2 jugadores)
|
|
constexpr float P1_SPAWN_X_RATIO = 0.33F; // 33% desde izquierda
|
|
constexpr float P2_SPAWN_X_RATIO = 0.67F; // 67% desde izquierda
|
|
constexpr float SPAWN_Y_RATIO = 0.75F; // 75% desde arriba
|
|
|
|
// Continue system behavior
|
|
constexpr int CONTINUE_COUNT_START = 9; // Countdown starts at 9
|
|
constexpr float CONTINUE_TICK_DURATION = 1.0F; // Seconds per countdown tick
|
|
constexpr int MAX_CONTINUES = 3; // Maximum continues per game
|
|
constexpr bool INFINITE_CONTINUES = false; // If true, unlimited continues
|
|
|
|
// Continue screen visual configuration
|
|
namespace ContinueScreen {
|
|
// "CONTINUE" text
|
|
constexpr float CONTINUE_TEXT_SCALE = 2.0F; // Text size
|
|
constexpr float CONTINUE_TEXT_Y_RATIO = 0.30F; // 35% from top of PLAYAREA
|
|
|
|
// Countdown number (9, 8, 7...)
|
|
constexpr float COUNTER_TEXT_SCALE = 4.0F; // Text size (large)
|
|
constexpr float COUNTER_TEXT_Y_RATIO = 0.50F; // 50% from top of PLAYAREA
|
|
|
|
// "CONTINUES LEFT: X" text
|
|
constexpr float INFO_TEXT_SCALE = 0.7F; // Text size (small)
|
|
constexpr float INFO_TEXT_Y_RATIO = 0.75F; // 65% from top of PLAYAREA
|
|
} // namespace ContinueScreen
|
|
|
|
// Game Over screen visual configuration
|
|
namespace GameOverScreen {
|
|
constexpr float TEXT_SCALE = 2.0F; // "GAME OVER" text size
|
|
constexpr float TEXT_SPACING = 4.0F; // Character spacing
|
|
} // namespace GameOverScreen
|
|
|
|
// Stage message configuration (LEVEL_START, LEVEL_COMPLETED)
|
|
constexpr float STAGE_MESSAGE_Y_RATIO = 0.25F; // 25% from top of PLAYAREA
|
|
constexpr float STAGE_MESSAGE_MAX_WIDTH_RATIO = 0.9F; // 90% of PLAYAREA width
|
|
|
|
} // namespace Defaults::Game
|