7ee359b910
Sweep final del naming a CamelCase/camelBack/lower_case:
Fitxers renombrats:
- effects/gestor_puntuacio_flotant.{hpp,cpp} -> floating_score_manager.{hpp,cpp}
- effects/puntuacio_flotant.hpp -> floating_score.hpp
Tipus (CamelCase):
- GestorPuntuacioFlotant -> FloatingScoreManager
- PuntuacioFlotant -> FloatingScore
- ConfigStage -> StageConfig
- ConfigSistemaStages -> StageSystemConfig
- NauTitol -> TitleShip
- EstatNau -> ShipState
Metodes publics (camelBack):
- obte_renderer -> getRenderer
- get_num_actius -> getActiveCount
- calcular_direccio_explosio -> computeExplosionDirection
- trobar_slot_lliure -> findFreeSlot
- explotar -> explode
- reiniciar -> reset
- es_valida -> isValid
- parsejar_fitxer -> parseFile
- carregar -> load
- crear_explosio -> createExplosion
- registrar_puntuacio -> registerScore
- construir_marcador -> buildScoreboard
- render_centered -> renderCentered
Camps struct publics (snake_case):
- actiu/actius -> active
- rotacio -> rotation, rotacio_visual -> visual_rotation
- acceleracio -> acceleration
- velocitat -> velocity
- escala/escala_inicial/objectiu/actual -> scale/initial_scale/...
- posicio/posicio_inicial/objectiu/actual -> position/initial_position/...
- fase_oscilacio -> oscillation_phase
- temps_estat -> state_time
- jugador_id -> player_id
- estat -> state
- brillantor -> brightness
- tipus -> type
Camps privats (sufix _):
- naus_ -> ships_, orni_ -> enemies_, bales_ -> bullets_
- gestor_puntuacio_ -> floating_score_manager_
- punt_mort_ -> death_position_, punt_spawn_ -> spawn_position_
- itocado_per_jugador_ -> hit_timer_per_player_
- vides_per_jugador_ -> lives_per_player_
- puntuacio_per_jugador_ -> score_per_player_
- estat_game_over_ -> game_over_state_
- continues_usados_ -> continues_used_
Constants:
- MARGE_ESQ/DRET/DALT/BAIX -> MARGIN_LEFT/RIGHT/TOP/BOTTOM
Variables locals i parametres comuns (snake_case):
- nau -> ship, enemic -> enemy, bala -> bullet
- forma -> shape, punt(s) -> point(s)
- jugador -> player, partida -> match
- temps -> time, missatge -> message
Diff: 59 fitxers, +1000/-1000 (simetric). Compila i enllaça.
Pendents per a futures fases (no bloquejants):
- Comentaris de capçalera en catala -> castella
- Variables locals/parametres minoritaris en catala
- Include guards (queden alguns #ifndef en lloc de #pragma once)
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ó
|
|
|
|
struct Window {
|
|
int width{640};
|
|
int height{480};
|
|
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ó 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 amb pollo (no utilitzat en orni, però necessari per Input)
|
|
inline KeyboardControls keyboard_controls{};
|
|
inline GamepadControls gamepad_controls{};
|
|
|
|
inline std::string config_file_path{}; // Establert per setConfigFile()
|
|
|
|
// Funcions públiques
|
|
|
|
void init(); // Inicialitzar amb valors per defecte
|
|
void setConfigFile(
|
|
const std::string& path); // Establir ruta del fitxer de config
|
|
auto loadFromFile() -> bool; // Carregar config YAML
|
|
auto saveToFile() -> bool; // Guardar config YAML
|
|
|
|
} // namespace Options
|