a4f6a5514f
El juego pasa de 4:3 a 16:9. Solo se tocan las constantes raíz:
todo lo demás (PLAYAREA, SCOREBOARD, CENTER_X/Y, P1/P2_TARGET,
VANISHING_POINT, etc.) se deriva de Game::WIDTH/HEIGHT y se
recalcula automáticamente.
Decisión del usuario: priorizar la base técnica sobre el feeling
del juego. Las velocidades, masas, radios de colisión y tamaños
de shape se mantienen sin cambios — la nave se verá más pequeña
en relación al área de juego y habrá más espacio. El tuning
jugable se hará tras completar la migración (post-Fase 7 GPU).
Cambios:
- Defaults::Window::WIDTH/HEIGHT: 640/480 -> 1280/720
- Defaults::Window::MIN_WIDTH/MIN_HEIGHT: 320/240 -> 640/360 (16:9)
- Defaults::Game::WIDTH/HEIGHT: 640/480 -> 1280/720
- Options::Window defaults: width{640}/height{480} -> 1280/720
- logo_scene.cpp: PANTALLA_ANCHO/ALTO ya no hardcoded;
deriva de Defaults::Game (era 640/480 magic numbers)
- Comentarios obsoletos limpiados en defaults.hpp
(// w = 640.0, // 320.0f, etc.)
- Catalán residual traducido (marges->márgenes, percentatges->porcentajes,
Àrea->Área, contenidor->contenedor, automàtic->automático)
Verificado: el ShipAnimator del título usa CENTER_X / CENTER_Y /
P1_TARGET_X/Y / VANISHING_POINT_X/Y, todos derivados de Game::WIDTH
y Game::HEIGHT. Se reposicionan automáticamente. CLOCK_RADIUS=150
se mantiene (escala relativa al centro).
PostFase: con 1280x720 el bug del HUD en ventana puede haber
cambiado de síntomas. Verificar visualmente cuando se haga la prueba.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
122 lines
3.2 KiB
C++
122 lines
3.2 KiB
C++
#pragma once
|
|
|
|
#include <SDL3/SDL.h> // Para SDL_Scancode
|
|
|
|
#include <string>
|
|
|
|
namespace Options {
|
|
|
|
// Estructures de configuración
|
|
|
|
struct Window {
|
|
int width{1280};
|
|
int height{720};
|
|
bool fullscreen{false};
|
|
float zoom_factor{1.0F}; // Zoom level (0.5x to max_zoom)
|
|
};
|
|
|
|
struct Physics {
|
|
float rotation_speed{3.14F}; // rad/s
|
|
float acceleration{400.0F}; // px/s²
|
|
float max_velocity{120.0F}; // px/s
|
|
float friction{20.0F}; // px/s²
|
|
float enemy_speed{2.0F}; // unitats/frame
|
|
float bullet_speed{6.0F}; // unitats/frame
|
|
};
|
|
|
|
struct Gameplay {
|
|
int max_enemies{15};
|
|
int max_bullets{3};
|
|
};
|
|
|
|
struct Rendering {
|
|
int vsync{1}; // 0=disabled, 1=enabled
|
|
};
|
|
|
|
struct Music {
|
|
bool enabled{true};
|
|
float volume{0.8F};
|
|
};
|
|
|
|
struct Sound {
|
|
bool enabled{true};
|
|
float volume{1.0F};
|
|
};
|
|
|
|
struct Audio {
|
|
Music music{};
|
|
Sound sound{};
|
|
bool enabled{true};
|
|
float volume{1.0F};
|
|
};
|
|
|
|
// Controles de jugadors
|
|
|
|
struct KeyboardControls {
|
|
SDL_Scancode key_left{SDL_SCANCODE_LEFT};
|
|
SDL_Scancode key_right{SDL_SCANCODE_RIGHT};
|
|
SDL_Scancode key_thrust{SDL_SCANCODE_UP};
|
|
SDL_Scancode key_shoot{SDL_SCANCODE_SPACE};
|
|
SDL_Scancode key_start{SDL_SCANCODE_1};
|
|
};
|
|
|
|
struct GamepadControls {
|
|
int button_left{SDL_GAMEPAD_BUTTON_DPAD_LEFT};
|
|
int button_right{SDL_GAMEPAD_BUTTON_DPAD_RIGHT};
|
|
int button_thrust{SDL_GAMEPAD_BUTTON_WEST}; // X button
|
|
int button_shoot{SDL_GAMEPAD_BUTTON_SOUTH}; // A button
|
|
};
|
|
|
|
struct PlayerControls {
|
|
KeyboardControls keyboard{};
|
|
GamepadControls gamepad{};
|
|
std::string gamepad_name; // Buit = auto-assignar per índex
|
|
};
|
|
|
|
// Variables globals (inline per evitar ODR violations)
|
|
|
|
inline std::string version{}; // Versión del config per validació
|
|
inline bool console{false}; // Eixida de debug
|
|
inline Window window{};
|
|
inline Physics physics{};
|
|
inline Gameplay gameplay{};
|
|
inline Rendering rendering{};
|
|
inline Audio audio{};
|
|
|
|
// Controles per player
|
|
inline PlayerControls player1{
|
|
.keyboard =
|
|
{.key_left = SDL_SCANCODE_LEFT,
|
|
.key_right = SDL_SCANCODE_RIGHT,
|
|
.key_thrust = SDL_SCANCODE_UP,
|
|
.key_shoot = SDL_SCANCODE_SPACE,
|
|
.key_start = SDL_SCANCODE_1},
|
|
.gamepad_name = "" // Primer gamepad disponible
|
|
};
|
|
|
|
inline PlayerControls player2{
|
|
.keyboard =
|
|
{.key_left = SDL_SCANCODE_A,
|
|
.key_right = SDL_SCANCODE_D,
|
|
.key_thrust = SDL_SCANCODE_W,
|
|
.key_shoot = SDL_SCANCODE_LSHIFT,
|
|
.key_start = SDL_SCANCODE_2},
|
|
.gamepad_name = "" // Segon gamepad disponible
|
|
};
|
|
|
|
// Per compatibilitat con pollo (no utilitzat en orni, pero necessari per Input)
|
|
inline KeyboardControls keyboard_controls{};
|
|
inline GamepadControls gamepad_controls{};
|
|
|
|
inline std::string config_file_path{}; // Establert per setConfigFile()
|
|
|
|
// Funciones públiques
|
|
|
|
void init(); // Inicialitzar con valors per defecte
|
|
void setConfigFile(
|
|
const std::string& path); // Establir ruta del file de config
|
|
auto loadFromFile() -> bool; // Carregar config YAML
|
|
auto saveToFile() -> bool; // Guardar config YAML
|
|
|
|
} // namespace Options
|