Files
orni_attack/source/game/options.hpp

72 lines
1.6 KiB
C++

#pragma once
#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};
};
// 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{};
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