Lint: clang-tidy --fix mecánico (trailing return, default member init, auto, enum size)
Pase automático de clang-tidy --fix sobre el conjunto de checks que son puro transform de sintaxis y no rompen API. Invocado con --format-style=none para que clang-tidy NO arrastre clang-format sobre las líneas tocadas (evita la regla NamespaceIndentation: All del .clang-format reformateando solo trozos del archivo). Checks aplicados: - modernize-use-trailing-return-type (193 hits): 'int foo()' → 'auto foo() -> int'. Estilo coherente con la convención del proyecto. - modernize-use-default-member-init (36 hits): inicialización de miembros pasa de la lista del constructor a la declaración. Reduce duplicación cuando hay varios constructores con los mismos defaults. - modernize-use-auto (6 hits): tipos largos sustituidos por auto donde el tipo es evidente del contexto (new T, dynamic_cast, etc). - modernize-use-starts-ends-with (2 hits): s.rfind(x) == 0 → s.starts_with(x), aprovechando C++20. - performance-enum-size (10 hits): enums pequeños declaran tipo subyacente (uint8_t / similar) para reducir tamaño y precisar layout. NO aplicado en este pase (riesgo de cambios semánticos o de API): - readability-identifier-naming (renames pueden romper callsites parciales) - readability-convert-member-functions-to-static (cambia firma) - readability-use-anyofallof (reescribe loops, side effects) - readability-function-cognitive-complexity (requiere refactor manual) - bugs reales (bugprone-*, clang-diagnostic-*) → uno a uno Cambios manuales asociados: - SDLManager::clear() ahora devuelve bool: propaga el resultado de beginFrame al caller para que Director::runFrameLoop salte draw+present cuando la swapchain no esté disponible (ventana minimizada). Antes la función ignoraba el [[nodiscard]] del beginFrame y los vértices se acumulaban en el batch sin nadie que los consumiera. - vector_text.cpp: borrada la línea suelta "// Test pre-commit hook" que quedó como cruft. clang-tidy crashea en LLVM 19.1 con performance-noexcept-move-constructor (recursión infinita en ExceptionSpecAnalyzer al procesar std::set); check deshabilitado en .clang-tidy con comentario explicativo. Build limpio, smoke test OK. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,11 @@ Checks:
|
|||||||
- -bugprone-easily-swappable-parameters
|
- -bugprone-easily-swappable-parameters
|
||||||
- -bugprone-narrowing-conversions
|
- -bugprone-narrowing-conversions
|
||||||
- -modernize-avoid-c-arrays
|
- -modernize-avoid-c-arrays
|
||||||
|
# performance-noexcept-move-constructor crashea clang-tidy (LLVM 19.1)
|
||||||
|
# con recursión infinita en ExceptionSpecAnalyzer::analyzeRecord cuando
|
||||||
|
# analiza ciertas instanciaciones de std::set. No es un falso positivo
|
||||||
|
# sobre nuestro código: el check ni siquiera llega a evaluar el patrón.
|
||||||
|
- -performance-noexcept-move-constructor
|
||||||
|
|
||||||
WarningsAsErrors: '*'
|
WarningsAsErrors: '*'
|
||||||
# Headers nostres (excloem source/external/ que conté dependències de tercers no editables)
|
# Headers nostres (excloem source/external/ que conté dependències de tercers no editables)
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ namespace {
|
|||||||
|
|
||||||
// Cachés locales: indexados por nombre lógico ("title.ogg", "effects/laser_shoot.wav", etc.)
|
// Cachés locales: indexados por nombre lógico ("title.ogg", "effects/laser_shoot.wav", etc.)
|
||||||
// Mantienen ownership con unique_ptr; se liberan al salir del programa.
|
// Mantienen ownership con unique_ptr; se liberan al salir del programa.
|
||||||
std::unordered_map<std::string, std::unique_ptr<Ja::Music>>& musicCache() {
|
auto musicCache() -> std::unordered_map<std::string, std::unique_ptr<Ja::Music>>& {
|
||||||
static std::unordered_map<std::string, std::unique_ptr<Ja::Music>> cache;
|
static std::unordered_map<std::string, std::unique_ptr<Ja::Music>> cache;
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<std::string, std::unique_ptr<Ja::Sound>>& soundCache() {
|
auto soundCache() -> std::unordered_map<std::string, std::unique_ptr<Ja::Sound>>& {
|
||||||
static std::unordered_map<std::string, std::unique_ptr<Ja::Sound>> cache;
|
static std::unordered_map<std::string, std::unique_ptr<Ja::Sound>> cache;
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
@@ -36,12 +36,12 @@ std::unordered_map<std::string, std::unique_ptr<Ja::Sound>>& soundCache() {
|
|||||||
// "title.ogg" -> "music/title.ogg"
|
// "title.ogg" -> "music/title.ogg"
|
||||||
// "music/title.ogg" -> "music/title.ogg"
|
// "music/title.ogg" -> "music/title.ogg"
|
||||||
// "effects/laser.wav" -> "sounds/effects/laser.wav"
|
// "effects/laser.wav" -> "sounds/effects/laser.wav"
|
||||||
std::string normalizeMusicPath(const std::string& name) {
|
auto normalizeMusicPath(const std::string& name) -> std::string {
|
||||||
return (name.rfind("music/", 0) == 0) ? name : "music/" + name;
|
return (name.starts_with("music/")) ? name : "music/" + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string normalizeSoundPath(const std::string& name) {
|
auto normalizeSoundPath(const std::string& name) -> std::string {
|
||||||
return (name.rfind("sounds/", 0) == 0) ? name : "sounds/" + name;
|
return (name.starts_with("sounds/")) ? name : "sounds/" + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -439,16 +439,16 @@ constexpr float CENTER_Y = Game::HEIGHT / 2.0F; // auto-derivado de Game::HEIGH
|
|||||||
// Posicions target (calculades dinàmicament des dels parámetros base)
|
// Posicions target (calculades dinàmicament des dels parámetros base)
|
||||||
// Nota: std::cos/sin no són constexpr en C++20, pero funcionen en runtime
|
// Nota: std::cos/sin no són constexpr en C++20, pero funcionen en runtime
|
||||||
// Les funciones inline són optimitzades por el compilador (zero overhead)
|
// Les funciones inline són optimitzades por el compilador (zero overhead)
|
||||||
inline float P1_TARGET_X() {
|
inline auto P1_TARGET_X() -> float {
|
||||||
return CENTER_X + (CLOCK_RADIUS * std::cos(CLOCK_8_ANGLE));
|
return CENTER_X + (CLOCK_RADIUS * std::cos(CLOCK_8_ANGLE));
|
||||||
}
|
}
|
||||||
inline float P1_TARGET_Y() {
|
inline auto P1_TARGET_Y() -> float {
|
||||||
return CENTER_Y + ((Game::HEIGHT / 2.0F) * TARGET_Y_RATIO);
|
return CENTER_Y + ((Game::HEIGHT / 2.0F) * TARGET_Y_RATIO);
|
||||||
}
|
}
|
||||||
inline float P2_TARGET_X() {
|
inline auto P2_TARGET_X() -> float {
|
||||||
return CENTER_X + (CLOCK_RADIUS * std::cos(CLOCK_4_ANGLE));
|
return CENTER_X + (CLOCK_RADIUS * std::cos(CLOCK_4_ANGLE));
|
||||||
}
|
}
|
||||||
inline float P2_TARGET_Y() {
|
inline auto P2_TARGET_Y() -> float {
|
||||||
return CENTER_Y + ((Game::HEIGHT / 2.0F) * TARGET_Y_RATIO);
|
return CENTER_Y + ((Game::HEIGHT / 2.0F) * TARGET_Y_RATIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,21 +30,21 @@ class Entity {
|
|||||||
virtual void init() = 0;
|
virtual void init() = 0;
|
||||||
virtual void update(float delta_time) = 0;
|
virtual void update(float delta_time) = 0;
|
||||||
virtual void draw() const = 0;
|
virtual void draw() const = 0;
|
||||||
[[nodiscard]] virtual bool isActive() const = 0;
|
[[nodiscard]] virtual auto isActive() const -> bool = 0;
|
||||||
|
|
||||||
// Sincronización post-física (override opcional).
|
// Sincronización post-física (override opcional).
|
||||||
// Llamado por GameScene tras world.update(). Default: no-op.
|
// Llamado por GameScene tras world.update(). Default: no-op.
|
||||||
virtual void postUpdate(float /*delta_time*/) {}
|
virtual void postUpdate(float /*delta_time*/) {}
|
||||||
|
|
||||||
// Interfaz de colisión (override opcional)
|
// Interfaz de colisión (override opcional)
|
||||||
[[nodiscard]] virtual float getCollisionRadius() const { return 0.0F; }
|
[[nodiscard]] virtual auto getCollisionRadius() const -> float { return 0.0F; }
|
||||||
[[nodiscard]] virtual bool isCollidable() const { return false; }
|
[[nodiscard]] virtual auto isCollidable() const -> bool { return false; }
|
||||||
|
|
||||||
// Getters comunes (inline, sin overhead)
|
// Getters comunes (inline, sin overhead)
|
||||||
[[nodiscard]] const Vec2& getCenter() const { return center_; }
|
[[nodiscard]] auto getCenter() const -> const Vec2& { return center_; }
|
||||||
[[nodiscard]] float getAngle() const { return angle_; }
|
[[nodiscard]] auto getAngle() const -> float { return angle_; }
|
||||||
[[nodiscard]] float getBrightness() const { return brightness_; }
|
[[nodiscard]] auto getBrightness() const -> float { return brightness_; }
|
||||||
[[nodiscard]] const std::shared_ptr<Graphics::Shape>& getShape() const { return shape_; }
|
[[nodiscard]] auto getShape() const -> const std::shared_ptr<Graphics::Shape>& { return shape_; }
|
||||||
|
|
||||||
// Acceso al cuerpo físico (Fase 6+). El PhysicsWorld lo registra
|
// Acceso al cuerpo físico (Fase 6+). El PhysicsWorld lo registra
|
||||||
// por puntero; la entidad lo configura en init().
|
// por puntero; la entidad lo configura en init().
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ namespace Graphics {
|
|||||||
|
|
||||||
Shape::Shape(const std::string& filepath)
|
Shape::Shape(const std::string& filepath)
|
||||||
: center_({.x = 0.0F, .y = 0.0F}),
|
: center_({.x = 0.0F, .y = 0.0F}),
|
||||||
escala_defecte_(1.0F),
|
|
||||||
nom_("unnamed") {
|
nom_("unnamed") {
|
||||||
load(filepath);
|
load(filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Shape::load(const std::string& filepath) {
|
auto Shape::load(const std::string& filepath) -> bool {
|
||||||
// Llegir file
|
// Llegir file
|
||||||
std::ifstream file(filepath);
|
std::ifstream file(filepath);
|
||||||
if (!file.is_open()) {
|
if (!file.is_open()) {
|
||||||
@@ -35,7 +35,7 @@ bool Shape::load(const std::string& filepath) {
|
|||||||
return parseFile(contingut);
|
return parseFile(contingut);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Shape::parseFile(const std::string& contingut) {
|
auto Shape::parseFile(const std::string& contingut) -> bool {
|
||||||
std::istringstream iss(contingut);
|
std::istringstream iss(contingut);
|
||||||
std::string line;
|
std::string line;
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ bool Shape::parseFile(const std::string& contingut) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper: trim whitespace
|
// Helper: trim whitespace
|
||||||
std::string Shape::trim(const std::string& str) const {
|
auto Shape::trim(const std::string& str) const -> std::string {
|
||||||
const char* whitespace = " \t\n\r";
|
const char* whitespace = " \t\n\r";
|
||||||
size_t start = str.find_first_not_of(whitespace);
|
size_t start = str.find_first_not_of(whitespace);
|
||||||
if (start == std::string::npos) {
|
if (start == std::string::npos) {
|
||||||
@@ -101,8 +101,8 @@ std::string Shape::trim(const std::string& str) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper: starts_with
|
// Helper: starts_with
|
||||||
bool Shape::starts_with(const std::string& str,
|
auto Shape::starts_with(const std::string& str,
|
||||||
const std::string& prefix) const {
|
const std::string& prefix) const -> bool {
|
||||||
if (str.length() < prefix.length()) {
|
if (str.length() < prefix.length()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ bool Shape::starts_with(const std::string& str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper: extract value after ':'
|
// Helper: extract value after ':'
|
||||||
std::string Shape::extract_value(const std::string& line) const {
|
auto Shape::extract_value(const std::string& line) const -> std::string {
|
||||||
size_t colon = line.find(':');
|
size_t colon = line.find(':');
|
||||||
if (colon == std::string::npos) {
|
if (colon == std::string::npos) {
|
||||||
return "";
|
return "";
|
||||||
@@ -134,7 +134,7 @@ void Shape::parse_center(const std::string& value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper: parse points "x1,y1 x2,y2 x3,y3"
|
// Helper: parse points "x1,y1 x2,y2 x3,y3"
|
||||||
std::vector<Vec2> Shape::parse_points(const std::string& str) const {
|
auto Shape::parse_points(const std::string& str) const -> std::vector<Vec2> {
|
||||||
std::vector<Vec2> points;
|
std::vector<Vec2> points;
|
||||||
std::istringstream iss(trim(str));
|
std::istringstream iss(trim(str));
|
||||||
std::string pair;
|
std::string pair;
|
||||||
|
|||||||
@@ -30,18 +30,18 @@ class Shape {
|
|||||||
explicit Shape(const std::string& filepath);
|
explicit Shape(const std::string& filepath);
|
||||||
|
|
||||||
// Carregar shape desde file .shp
|
// Carregar shape desde file .shp
|
||||||
bool load(const std::string& filepath);
|
auto load(const std::string& filepath) -> bool;
|
||||||
|
|
||||||
// Parsejar shape desde buffer de memòria (per al sistema de recursos)
|
// Parsejar shape desde buffer de memòria (per al sistema de recursos)
|
||||||
bool parseFile(const std::string& contingut);
|
auto parseFile(const std::string& contingut) -> bool;
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
[[nodiscard]] const std::vector<ShapePrimitive>& get_primitives() const {
|
[[nodiscard]] auto get_primitives() const -> const std::vector<ShapePrimitive>& {
|
||||||
return primitives_;
|
return primitives_;
|
||||||
}
|
}
|
||||||
[[nodiscard]] const Vec2& getCenter() const { return center_; }
|
[[nodiscard]] auto getCenter() const -> const Vec2& { return center_; }
|
||||||
[[nodiscard]] float get_escala_defecte() const { return escala_defecte_; }
|
[[nodiscard]] auto get_escala_defecte() const -> float { return escala_defecte_; }
|
||||||
[[nodiscard]] bool isValid() const { return !primitives_.empty(); }
|
[[nodiscard]] auto isValid() const -> bool { return !primitives_.empty(); }
|
||||||
|
|
||||||
// Info de depuració
|
// Info de depuració
|
||||||
[[nodiscard]] auto getName() const -> const std::string& { return nom_; }
|
[[nodiscard]] auto getName() const -> const std::string& { return nom_; }
|
||||||
@@ -55,11 +55,11 @@ class Shape {
|
|||||||
std::string nom_; // Nom de la shape (per depuració)
|
std::string nom_; // Nom de la shape (per depuració)
|
||||||
|
|
||||||
// Helpers privats per parsejar
|
// Helpers privats per parsejar
|
||||||
[[nodiscard]] std::string trim(const std::string& str) const;
|
[[nodiscard]] auto trim(const std::string& str) const -> std::string;
|
||||||
[[nodiscard]] bool starts_with(const std::string& str, const std::string& prefix) const;
|
[[nodiscard]] auto starts_with(const std::string& str, const std::string& prefix) const -> bool;
|
||||||
[[nodiscard]] std::string extract_value(const std::string& line) const;
|
[[nodiscard]] auto extract_value(const std::string& line) const -> std::string;
|
||||||
void parse_center(const std::string& value);
|
void parse_center(const std::string& value);
|
||||||
[[nodiscard]] std::vector<Vec2> parse_points(const std::string& str) const;
|
[[nodiscard]] auto parse_points(const std::string& str) const -> std::vector<Vec2>;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Graphics
|
} // namespace Graphics
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace Graphics {
|
|||||||
std::unordered_map<std::string, std::shared_ptr<Shape>> ShapeLoader::cache_;
|
std::unordered_map<std::string, std::shared_ptr<Shape>> ShapeLoader::cache_;
|
||||||
std::string ShapeLoader::base_path_ = "data/shapes/";
|
std::string ShapeLoader::base_path_ = "data/shapes/";
|
||||||
|
|
||||||
std::shared_ptr<Shape> ShapeLoader::load(const std::string& filename) {
|
auto ShapeLoader::load(const std::string& filename) -> std::shared_ptr<Shape> {
|
||||||
// Check cache first
|
// Check cache first
|
||||||
auto it = cache_.find(filename);
|
auto it = cache_.find(filename);
|
||||||
if (it != cache_.end()) {
|
if (it != cache_.end()) {
|
||||||
@@ -66,9 +66,9 @@ void ShapeLoader::clear_cache() {
|
|||||||
cache_.clear();
|
cache_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ShapeLoader::get_cache_size() { return cache_.size(); }
|
auto ShapeLoader::get_cache_size() -> size_t { return cache_.size(); }
|
||||||
|
|
||||||
std::string ShapeLoader::resolve_path(const std::string& filename) {
|
auto ShapeLoader::resolve_path(const std::string& filename) -> std::string {
|
||||||
// Si es un path absolut (comença con '/'), usar-lo directament
|
// Si es un path absolut (comença con '/'), usar-lo directament
|
||||||
if (!filename.empty() && filename[0] == '/') {
|
if (!filename.empty() && filename[0] == '/') {
|
||||||
return filename;
|
return filename;
|
||||||
|
|||||||
@@ -20,20 +20,20 @@ class ShapeLoader {
|
|||||||
// Carregar shape desde file (con caché)
|
// Carregar shape desde file (con caché)
|
||||||
// Retorna punter compartit (nullptr si error)
|
// Retorna punter compartit (nullptr si error)
|
||||||
// Exemple: load("ship.shp") → busca a "data/shapes/ship.shp"
|
// Exemple: load("ship.shp") → busca a "data/shapes/ship.shp"
|
||||||
static std::shared_ptr<Shape> load(const std::string& filename);
|
static auto load(const std::string& filename) -> std::shared_ptr<Shape>;
|
||||||
|
|
||||||
// Netejar caché (útil per debug/recàrrega)
|
// Netejar caché (útil per debug/recàrrega)
|
||||||
static void clear_cache();
|
static void clear_cache();
|
||||||
|
|
||||||
// Estadístiques (debug)
|
// Estadístiques (debug)
|
||||||
static size_t get_cache_size();
|
static auto get_cache_size() -> size_t;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::unordered_map<std::string, std::shared_ptr<Shape>> cache_;
|
static std::unordered_map<std::string, std::shared_ptr<Shape>> cache_;
|
||||||
static std::string base_path_; // "data/shapes/"
|
static std::string base_path_; // "data/shapes/"
|
||||||
|
|
||||||
// Helpers privats
|
// Helpers privats
|
||||||
static std::string resolve_path(const std::string& filename);
|
static auto resolve_path(const std::string& filename) -> std::string;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Graphics
|
} // namespace Graphics
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ void Starfield::inicialitzar_estrella(Estrella& estrella) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verificar si una estrella está fuera de l'àrea
|
// Verificar si una estrella está fuera de l'àrea
|
||||||
bool Starfield::fora_area(const Estrella& estrella) const {
|
auto Starfield::fora_area(const Estrella& estrella) const -> bool {
|
||||||
return (estrella.position.x < area_.x ||
|
return (estrella.position.x < area_.x ||
|
||||||
estrella.position.x > area_.x + area_.w ||
|
estrella.position.x > area_.x + area_.w ||
|
||||||
estrella.position.y < area_.y ||
|
estrella.position.y < area_.y ||
|
||||||
@@ -89,7 +89,7 @@ bool Starfield::fora_area(const Estrella& estrella) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calcular scale dinàmica segons distancia del centro
|
// Calcular scale dinàmica segons distancia del centro
|
||||||
float Starfield::calcular_escala(const Estrella& estrella) const {
|
auto Starfield::calcular_escala(const Estrella& estrella) const -> float {
|
||||||
const CapaConfig& capa = capes_[estrella.capa];
|
const CapaConfig& capa = capes_[estrella.capa];
|
||||||
|
|
||||||
// Interpolació lineal basada en distancia del centro
|
// Interpolació lineal basada en distancia del centro
|
||||||
@@ -99,7 +99,7 @@ float Starfield::calcular_escala(const Estrella& estrella) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calcular brightness dinàmica segons distancia del centro
|
// Calcular brightness dinàmica segons distancia del centro
|
||||||
float Starfield::calcular_brightness(const Estrella& estrella) const {
|
auto Starfield::calcular_brightness(const Estrella& estrella) const -> float {
|
||||||
// Interpolació lineal: estrelles properes (vora) més brillants
|
// Interpolació lineal: estrelles properes (vora) més brillants
|
||||||
// distancia_centre: 0.0 (centro, llunyanes) → 1.0 (vora, properes)
|
// distancia_centre: 0.0 (centro, llunyanes) → 1.0 (vora, properes)
|
||||||
float brightness_base = Defaults::Brightness::STARFIELD_MIN +
|
float brightness_base = Defaults::Brightness::STARFIELD_MIN +
|
||||||
|
|||||||
@@ -59,13 +59,13 @@ class Starfield {
|
|||||||
void inicialitzar_estrella(Estrella& estrella) const;
|
void inicialitzar_estrella(Estrella& estrella) const;
|
||||||
|
|
||||||
// Verificar si una estrella está fuera de l'àrea
|
// Verificar si una estrella está fuera de l'àrea
|
||||||
[[nodiscard]] bool fora_area(const Estrella& estrella) const;
|
[[nodiscard]] auto fora_area(const Estrella& estrella) const -> bool;
|
||||||
|
|
||||||
// Calcular scale dinàmica segons distancia del centro
|
// Calcular scale dinàmica segons distancia del centro
|
||||||
[[nodiscard]] float calcular_escala(const Estrella& estrella) const;
|
[[nodiscard]] auto calcular_escala(const Estrella& estrella) const -> float;
|
||||||
|
|
||||||
// Calcular brightness dinàmica segons distancia del centro
|
// Calcular brightness dinàmica segons distancia del centro
|
||||||
[[nodiscard]] float calcular_brightness(const Estrella& estrella) const;
|
[[nodiscard]] auto calcular_brightness(const Estrella& estrella) const -> float;
|
||||||
|
|
||||||
// Dades
|
// Dades
|
||||||
std::vector<Estrella> estrelles_;
|
std::vector<Estrella> estrelles_;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
// vector_text.cpp - Implementació del sistema de text vectorial
|
// vector_text.cpp - Implementació del sistema de text vectorial
|
||||||
// © 2026 JailDesigner
|
// © 2026 JailDesigner
|
||||||
// Test pre-commit hook
|
|
||||||
|
|
||||||
#include "core/graphics/vector_text.hpp"
|
#include "core/graphics/vector_text.hpp"
|
||||||
|
|
||||||
@@ -80,7 +79,7 @@ void VectorText::load_charset() {
|
|||||||
<< '\n';
|
<< '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string VectorText::get_shape_filename(char c) const {
|
auto VectorText::get_shape_filename(char c) const -> std::string {
|
||||||
// Mapeo carácter → nombre de archivo (con prefix "font/")
|
// Mapeo carácter → nombre de archivo (con prefix "font/")
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '0':
|
case '0':
|
||||||
@@ -177,7 +176,7 @@ std::string VectorText::get_shape_filename(char c) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VectorText::is_supported(char c) const {
|
auto VectorText::is_supported(char c) const -> bool {
|
||||||
return chars_.contains(c);
|
return chars_.contains(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +250,7 @@ void VectorText::renderCentered(const std::string& text, const Vec2& centre_punt
|
|||||||
render(text, posicio_esquerra, scale, spacing, brightness);
|
render(text, posicio_esquerra, scale, spacing, brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
float VectorText::get_text_width(const std::string& text, float scale, float spacing) const {
|
auto VectorText::get_text_width(const std::string& text, float scale, float spacing) const -> float {
|
||||||
if (text.empty()) {
|
if (text.empty()) {
|
||||||
return 0.0F;
|
return 0.0F;
|
||||||
}
|
}
|
||||||
@@ -278,7 +277,7 @@ float VectorText::get_text_width(const std::string& text, float scale, float spa
|
|||||||
return (visual_chars * char_width_scaled) + ((visual_chars - 1) * spacing_scaled);
|
return (visual_chars * char_width_scaled) + ((visual_chars - 1) * spacing_scaled);
|
||||||
}
|
}
|
||||||
|
|
||||||
float VectorText::get_text_height(float scale) const {
|
auto VectorText::get_text_height(float scale) const -> float {
|
||||||
return char_height * scale;
|
return char_height * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,20 +38,20 @@ class VectorText {
|
|||||||
void renderCentered(const std::string& text, const Vec2& centre_punt, float scale = 1.0F, float spacing = 2.0F, float brightness = 1.0F) const;
|
void renderCentered(const std::string& text, const Vec2& centre_punt, float scale = 1.0F, float spacing = 2.0F, float brightness = 1.0F) const;
|
||||||
|
|
||||||
// Calcular ancho total de un string (útil para centrado)
|
// Calcular ancho total de un string (útil para centrado)
|
||||||
[[nodiscard]] float get_text_width(const std::string& text, float scale = 1.0F, float spacing = 2.0F) const;
|
[[nodiscard]] auto get_text_width(const std::string& text, float scale = 1.0F, float spacing = 2.0F) const -> float;
|
||||||
|
|
||||||
// Calcular altura del texto (útil para centrado vertical)
|
// Calcular altura del texto (útil para centrado vertical)
|
||||||
[[nodiscard]] float get_text_height(float scale = 1.0F) const;
|
[[nodiscard]] auto get_text_height(float scale = 1.0F) const -> float;
|
||||||
|
|
||||||
// Verificar si un carácter está soportado
|
// Verificar si un carácter está soportado
|
||||||
[[nodiscard]] bool is_supported(char c) const;
|
[[nodiscard]] auto is_supported(char c) const -> bool;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Rendering::Renderer* renderer_;
|
Rendering::Renderer* renderer_;
|
||||||
std::unordered_map<char, std::shared_ptr<Shape>> chars_;
|
std::unordered_map<char, std::shared_ptr<Shape>> chars_;
|
||||||
|
|
||||||
void load_charset();
|
void load_charset();
|
||||||
[[nodiscard]] std::string get_shape_filename(char c) const;
|
[[nodiscard]] auto get_shape_filename(char c) const -> std::string;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Graphics
|
} // namespace Graphics
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ void setForceHidden(bool force) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isForceHidden() {
|
auto isForceHidden() -> bool {
|
||||||
return force_hidden;
|
return force_hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,5 +13,5 @@ void updateCursorVisibility();
|
|||||||
|
|
||||||
// Control de visibilidad forzada (para modo pantalla completa)
|
// Control de visibilidad forzada (para modo pantalla completa)
|
||||||
void setForceHidden(bool force); // Activar/desactivar ocultación forzada
|
void setForceHidden(bool force); // Activar/desactivar ocultación forzada
|
||||||
bool isForceHidden(); // Consultar estado actual
|
auto isForceHidden() -> bool; // Consultar estado actual
|
||||||
} // namespace Mouse
|
} // namespace Mouse
|
||||||
|
|||||||
@@ -8,21 +8,21 @@ namespace Easing {
|
|||||||
// Ease-out quadratic: empieza rápido, desacelera suavemente
|
// Ease-out quadratic: empieza rápido, desacelera suavemente
|
||||||
// t = progreso normalizado [0.0 - 1.0]
|
// t = progreso normalizado [0.0 - 1.0]
|
||||||
// retorna value interpolado [0.0 - 1.0]
|
// retorna value interpolado [0.0 - 1.0]
|
||||||
inline float ease_out_quad(float t) {
|
inline auto ease_out_quad(float t) -> float {
|
||||||
return 1.0F - ((1.0F - t) * (1.0F - t));
|
return 1.0F - ((1.0F - t) * (1.0F - t));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ease-in quadratic: empieza lento, acelera
|
// Ease-in quadratic: empieza lento, acelera
|
||||||
// t = progreso normalizado [0.0 - 1.0]
|
// t = progreso normalizado [0.0 - 1.0]
|
||||||
// retorna value interpolado [0.0 - 1.0]
|
// retorna value interpolado [0.0 - 1.0]
|
||||||
inline float ease_in_quad(float t) {
|
inline auto ease_in_quad(float t) -> float {
|
||||||
return t * t;
|
return t * t;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ease-in-out quadratic: acelera al inicio, desacelera al final
|
// Ease-in-out quadratic: acelera al inicio, desacelera al final
|
||||||
// t = progreso normalizado [0.0 - 1.0]
|
// t = progreso normalizado [0.0 - 1.0]
|
||||||
// retorna value interpolado [0.0 - 1.0]
|
// retorna value interpolado [0.0 - 1.0]
|
||||||
inline float ease_in_out_quad(float t) {
|
inline auto ease_in_out_quad(float t) -> float {
|
||||||
return (t < 0.5F)
|
return (t < 0.5F)
|
||||||
? 2.0F * t * t
|
? 2.0F * t * t
|
||||||
: 1.0F - ((-2.0F * t + 2.0F) * (-2.0F * t + 2.0F) / 2.0F);
|
: 1.0F - ((-2.0F * t + 2.0F) * (-2.0F * t + 2.0F) / 2.0F);
|
||||||
@@ -31,13 +31,13 @@ inline float ease_in_out_quad(float t) {
|
|||||||
// Ease-out cubic: desaceleración más suave que quadratic
|
// Ease-out cubic: desaceleración más suave que quadratic
|
||||||
// t = progreso normalizado [0.0 - 1.0]
|
// t = progreso normalizado [0.0 - 1.0]
|
||||||
// retorna value interpolado [0.0 - 1.0]
|
// retorna value interpolado [0.0 - 1.0]
|
||||||
inline float ease_out_cubic(float t) {
|
inline auto ease_out_cubic(float t) -> float {
|
||||||
float t1 = 1.0F - t;
|
float t1 = 1.0F - t;
|
||||||
return 1.0F - (t1 * t1 * t1);
|
return 1.0F - (t1 * t1 * t1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interpolación lineal básica (para referencia)
|
// Interpolación lineal básica (para referencia)
|
||||||
inline float lerp(float start, float end, float t) {
|
inline auto lerp(float start, float end, float t) -> float {
|
||||||
return start + ((end - start) * t);
|
return start + ((end - start) * t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
namespace Physics {
|
namespace Physics {
|
||||||
|
|
||||||
// Comprobación genèrica de colisión entre dues entidades
|
// Comprobación genèrica de colisión entre dues entidades
|
||||||
inline bool check_collision(const Entities::Entity& a, const Entities::Entity& b, float amplifier = 1.0F) {
|
inline auto check_collision(const Entities::Entity& a, const Entities::Entity& b, float amplifier = 1.0F) -> bool {
|
||||||
// Comprovar si ambdós són col·lisionables
|
// Comprovar si ambdós són col·lisionables
|
||||||
if (!a.isCollidable() || !b.isCollidable()) {
|
if (!a.isCollidable() || !b.isCollidable()) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -11,20 +11,20 @@ namespace Rendering {
|
|||||||
extern float g_current_scale_factor;
|
extern float g_current_scale_factor;
|
||||||
|
|
||||||
// Transforma coordenada lógica a física con arrodoniment
|
// Transforma coordenada lógica a física con arrodoniment
|
||||||
inline int transform_x(int logical_x, float scale) {
|
inline auto transform_x(int logical_x, float scale) -> int {
|
||||||
return static_cast<int>(std::round(logical_x * scale));
|
return static_cast<int>(std::round(logical_x * scale));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int transform_y(int logical_y, float scale) {
|
inline auto transform_y(int logical_y, float scale) -> int {
|
||||||
return static_cast<int>(std::round(logical_y * scale));
|
return static_cast<int>(std::round(logical_y * scale));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Variant que usa el factor de scale global
|
// Variant que usa el factor de scale global
|
||||||
inline int transform_x(int logical_x) {
|
inline auto transform_x(int logical_x) -> int {
|
||||||
return transform_x(logical_x, g_current_scale_factor);
|
return transform_x(logical_x, g_current_scale_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int transform_y(int logical_y) {
|
inline auto transform_y(int logical_y) -> int {
|
||||||
return transform_y(logical_y, g_current_scale_factor);
|
return transform_y(logical_y, g_current_scale_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -239,8 +239,8 @@ void GpuFrameRenderer::flushBatch() {
|
|||||||
|
|
||||||
SDL_GPUDevice* dev = device_.get();
|
SDL_GPUDevice* dev = device_.get();
|
||||||
|
|
||||||
const uint32_t VBO_SIZE = static_cast<uint32_t>(vertices_.size() * sizeof(LineVertex));
|
const auto VBO_SIZE = static_cast<uint32_t>(vertices_.size() * sizeof(LineVertex));
|
||||||
const uint32_t IBO_SIZE = static_cast<uint32_t>(indices_.size() * sizeof(uint16_t));
|
const auto IBO_SIZE = static_cast<uint32_t>(indices_.size() * sizeof(uint16_t));
|
||||||
|
|
||||||
SDL_GPUBufferCreateInfo vbo_info{};
|
SDL_GPUBufferCreateInfo vbo_info{};
|
||||||
vbo_info.usage = SDL_GPU_BUFFERUSAGE_VERTEX;
|
vbo_info.usage = SDL_GPU_BUFFERUSAGE_VERTEX;
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ void linea(Renderer* renderer,
|
|||||||
|
|
||||||
// Coords lógicas (1280×720). El shader hace el mapeo a NDC; el viewport
|
// Coords lógicas (1280×720). El shader hace el mapeo a NDC; el viewport
|
||||||
// del SDLManager hace el letterbox a píxeles físicos.
|
// del SDLManager hace el letterbox a píxeles físicos.
|
||||||
const float FX1 = static_cast<float>(x1);
|
const auto FX1 = static_cast<float>(x1);
|
||||||
const float FY1 = static_cast<float>(y1);
|
const auto FY1 = static_cast<float>(y1);
|
||||||
const float FX2 = static_cast<float>(x2);
|
const auto FX2 = static_cast<float>(x2);
|
||||||
const float FY2 = static_cast<float>(y2);
|
const auto FY2 = static_cast<float>(y2);
|
||||||
|
|
||||||
// color.alpha==0 → usar color global (verde fósforo). alpha>0 → color directo.
|
// color.alpha==0 → usar color global (verde fósforo). alpha>0 → color directo.
|
||||||
const SDL_Color SOURCE = (color.a > 0) ? color : g_current_line_color;
|
const SDL_Color SOURCE = (color.a > 0) ? color : g_current_line_color;
|
||||||
|
|||||||
@@ -316,14 +316,18 @@ auto SDLManager::handleWindowEvent(const SDL_Event& event) -> bool {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLManager::clear(uint8_t r, uint8_t g, uint8_t b) {
|
auto SDLManager::clear(uint8_t r, uint8_t g, uint8_t b) -> bool {
|
||||||
// El fondo lo dibuja ahora el shader de postpro (background pulse). El
|
// El fondo lo dibuja ahora el shader de postpro (background pulse). El
|
||||||
// offscreen se limpia en negro dentro de beginFrame. Los argumentos r/g/b
|
// offscreen se limpia en negro dentro de beginFrame. Los argumentos r/g/b
|
||||||
// se mantienen por compatibilidad de API.
|
// se mantienen por compatibilidad de API.
|
||||||
(void)r;
|
(void)r;
|
||||||
(void)g;
|
(void)g;
|
||||||
(void)b;
|
(void)b;
|
||||||
gpu_renderer_.beginFrame(0.0F, 0.0F, 0.0F);
|
// beginFrame devuelve false si la swapchain no está disponible (ventana
|
||||||
|
// minimizada, por ejemplo). Propagamos el bool al caller para que pueda
|
||||||
|
// saltarse draw+present ese frame; si no, los vértices se acumulan en
|
||||||
|
// el batch interno sin que nadie los consuma.
|
||||||
|
return gpu_renderer_.beginFrame(0.0F, 0.0F, 0.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLManager::present() {
|
void SDLManager::present() {
|
||||||
|
|||||||
@@ -31,8 +31,10 @@ class SDLManager {
|
|||||||
void toggleVSync(); // F4
|
void toggleVSync(); // F4
|
||||||
auto handleWindowEvent(const SDL_Event& event) -> bool; // Per a SDL_EVENT_WINDOW_RESIZED
|
auto handleWindowEvent(const SDL_Event& event) -> bool; // Per a SDL_EVENT_WINDOW_RESIZED
|
||||||
|
|
||||||
// Funciones principals (renderizado)
|
// Funciones principals (renderizado).
|
||||||
void clear(uint8_t r = 0, uint8_t g = 0, uint8_t b = 0);
|
// clear() devuelve false si la swapchain no está disponible (p.ej.
|
||||||
|
// ventana minimizada). El caller debe saltarse draw+present ese frame.
|
||||||
|
[[nodiscard]] auto clear(uint8_t r = 0, uint8_t g = 0, uint8_t b = 0) -> bool;
|
||||||
void present();
|
void present();
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
namespace Rendering {
|
namespace Rendering {
|
||||||
|
|
||||||
// Helper: aplicar rotación 3D a un point 2D (assumeix Z=0)
|
// Helper: aplicar rotación 3D a un point 2D (assumeix Z=0)
|
||||||
static Vec2 apply_3d_rotation(float x, float y, const Rotation3D& rot) {
|
static auto apply_3d_rotation(float x, float y, const Rotation3D& rot) -> Vec2 {
|
||||||
float z = 0.0F; // Todos los points 2D comencen a Z=0
|
float z = 0.0F; // Todos los points 2D comencen a Z=0
|
||||||
|
|
||||||
// Pitch (rotación eix X): cabeceo arriba/baix
|
// Pitch (rotación eix X): cabeceo arriba/baix
|
||||||
@@ -42,7 +42,7 @@ static Vec2 apply_3d_rotation(float x, float y, const Rotation3D& rot) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper: transformar un point con rotación, scale i traslación
|
// Helper: transformar un point con rotación, scale i traslación
|
||||||
static Vec2 transform_point(const Vec2& point, const Vec2& shape_centre, const Vec2& position, float angle, float scale, const Rotation3D* rotation_3d) {
|
static auto transform_point(const Vec2& point, const Vec2& shape_centre, const Vec2& position, float angle, float scale, const Rotation3D* rotation_3d) -> Vec2 {
|
||||||
// 1. Centrar el point respecte al centro de la shape
|
// 1. Centrar el point respecte al centro de la shape
|
||||||
float centered_x = point.x - shape_centre.x;
|
float centered_x = point.x - shape_centre.x;
|
||||||
float centered_y = point.y - shape_centre.y;
|
float centered_y = point.y - shape_centre.y;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ struct Rotation3D {
|
|||||||
yaw(y),
|
yaw(y),
|
||||||
roll(r) {}
|
roll(r) {}
|
||||||
|
|
||||||
[[nodiscard]] bool has_rotation() const {
|
[[nodiscard]] auto has_rotation() const -> bool {
|
||||||
return pitch != 0.0F || yaw != 0.0F || roll != 0.0F;
|
return pitch != 0.0F || yaw != 0.0F || roll != 0.0F;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,12 +11,12 @@
|
|||||||
namespace Resource::Helper {
|
namespace Resource::Helper {
|
||||||
|
|
||||||
// Inicialitzar el sistema de recursos
|
// Inicialitzar el sistema de recursos
|
||||||
bool initializeResourceSystem(const std::string& pack_file, bool fallback) {
|
auto initializeResourceSystem(const std::string& pack_file, bool fallback) -> bool {
|
||||||
return Loader::get().initialize(pack_file, fallback);
|
return Loader::get().initialize(pack_file, fallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Carregar un file
|
// Carregar un file
|
||||||
std::vector<uint8_t> loadFile(const std::string& filepath) {
|
auto loadFile(const std::string& filepath) -> std::vector<uint8_t> {
|
||||||
// Normalitzar la ruta
|
// Normalitzar la ruta
|
||||||
std::string normalized = normalizePath(filepath);
|
std::string normalized = normalizePath(filepath);
|
||||||
|
|
||||||
@@ -25,14 +25,14 @@ std::vector<uint8_t> loadFile(const std::string& filepath) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprovar si existeix un file
|
// Comprovar si existeix un file
|
||||||
bool fileExists(const std::string& filepath) {
|
auto fileExists(const std::string& filepath) -> bool {
|
||||||
std::string normalized = normalizePath(filepath);
|
std::string normalized = normalizePath(filepath);
|
||||||
return Loader::get().resourceExists(normalized);
|
return Loader::get().resourceExists(normalized);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtenir ruta normalitzada per al paquet
|
// Obtenir ruta normalitzada per al paquet
|
||||||
// Elimina prefixos "data/", rutes absolutes, etc.
|
// Elimina prefixos "data/", rutes absolutes, etc.
|
||||||
std::string getPackPath(const std::string& asset_path) {
|
auto getPackPath(const std::string& asset_path) -> std::string {
|
||||||
std::string path = asset_path;
|
std::string path = asset_path;
|
||||||
|
|
||||||
// Eliminar rutes absolutes (detectar / o C:\ al principi)
|
// Eliminar rutes absolutes (detectar / o C:\ al principi)
|
||||||
@@ -69,12 +69,12 @@ std::string getPackPath(const std::string& asset_path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Normalitzar ruta (alias de getPackPath)
|
// Normalitzar ruta (alias de getPackPath)
|
||||||
std::string normalizePath(const std::string& path) {
|
auto normalizePath(const std::string& path) -> std::string {
|
||||||
return getPackPath(path);
|
return getPackPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprovar si hay paquet carregat
|
// Comprovar si hay paquet carregat
|
||||||
bool isPackLoaded() {
|
auto isPackLoaded() -> bool {
|
||||||
return Loader::get().isPackLoaded();
|
return Loader::get().isPackLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,17 +11,17 @@
|
|||||||
namespace Resource::Helper {
|
namespace Resource::Helper {
|
||||||
|
|
||||||
// Inicialización del sistema
|
// Inicialización del sistema
|
||||||
bool initializeResourceSystem(const std::string& pack_file, bool fallback);
|
auto initializeResourceSystem(const std::string& pack_file, bool fallback) -> bool;
|
||||||
|
|
||||||
// Càrrega de archivos
|
// Càrrega de archivos
|
||||||
std::vector<uint8_t> loadFile(const std::string& filepath);
|
auto loadFile(const std::string& filepath) -> std::vector<uint8_t>;
|
||||||
bool fileExists(const std::string& filepath);
|
auto fileExists(const std::string& filepath) -> bool;
|
||||||
|
|
||||||
// Normalització de rutes
|
// Normalització de rutes
|
||||||
std::string getPackPath(const std::string& asset_path);
|
auto getPackPath(const std::string& asset_path) -> std::string;
|
||||||
std::string normalizePath(const std::string& path);
|
auto normalizePath(const std::string& path) -> std::string;
|
||||||
|
|
||||||
// Estat
|
// Estat
|
||||||
bool isPackLoaded();
|
auto isPackLoaded() -> bool;
|
||||||
|
|
||||||
} // namespace Resource::Helper
|
} // namespace Resource::Helper
|
||||||
|
|||||||
@@ -10,13 +10,13 @@
|
|||||||
namespace Resource {
|
namespace Resource {
|
||||||
|
|
||||||
// Singleton
|
// Singleton
|
||||||
Loader& Loader::get() {
|
auto Loader::get() -> Loader& {
|
||||||
static Loader instance;
|
static Loader instance;
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inicialitzar el sistema de recursos
|
// Inicialitzar el sistema de recursos
|
||||||
bool Loader::initialize(const std::string& pack_file, bool enable_fallback) {
|
auto Loader::initialize(const std::string& pack_file, bool enable_fallback) -> bool {
|
||||||
fallback_enabled_ = enable_fallback;
|
fallback_enabled_ = enable_fallback;
|
||||||
|
|
||||||
// Intentar load el paquet
|
// Intentar load el paquet
|
||||||
@@ -39,7 +39,7 @@ bool Loader::initialize(const std::string& pack_file, bool enable_fallback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carregar un recurs
|
// Carregar un recurs
|
||||||
std::vector<uint8_t> Loader::loadResource(const std::string& filename) {
|
auto Loader::loadResource(const std::string& filename) -> std::vector<uint8_t> {
|
||||||
// Intentar load del paquet primer
|
// Intentar load del paquet primer
|
||||||
if (pack_) {
|
if (pack_) {
|
||||||
if (pack_->hasResource(filename)) {
|
if (pack_->hasResource(filename)) {
|
||||||
@@ -68,7 +68,7 @@ std::vector<uint8_t> Loader::loadResource(const std::string& filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprovar si existeix un recurs
|
// Comprovar si existeix un recurs
|
||||||
bool Loader::resourceExists(const std::string& filename) {
|
auto Loader::resourceExists(const std::string& filename) -> bool {
|
||||||
// Comprovar al paquet
|
// Comprovar al paquet
|
||||||
if (pack_ && pack_->hasResource(filename)) {
|
if (pack_ && pack_->hasResource(filename)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -84,7 +84,7 @@ bool Loader::resourceExists(const std::string& filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validar el paquet
|
// Validar el paquet
|
||||||
bool Loader::validatePack() {
|
auto Loader::validatePack() -> bool {
|
||||||
if (!pack_) {
|
if (!pack_) {
|
||||||
std::cerr << "[ResourceLoader] Advertència: no hay paquet carregat per validar\n";
|
std::cerr << "[ResourceLoader] Advertència: no hay paquet carregat per validar\n";
|
||||||
return false;
|
return false;
|
||||||
@@ -94,7 +94,7 @@ bool Loader::validatePack() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprovar si hay paquet carregat
|
// Comprovar si hay paquet carregat
|
||||||
bool Loader::isPackLoaded() const {
|
auto Loader::isPackLoaded() const -> bool {
|
||||||
return pack_ != nullptr;
|
return pack_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ auto Loader::getBasePath() const -> const std::string& {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carregar des del sistema de archivos (fallback)
|
// Carregar des del sistema de archivos (fallback)
|
||||||
std::vector<uint8_t> Loader::loadFromFilesystem(const std::string& filename) {
|
auto Loader::loadFromFilesystem(const std::string& filename) -> std::vector<uint8_t> {
|
||||||
// The filename is already normalized (e.g., "shapes/logo/letra_j.shp")
|
// The filename is already normalized (e.g., "shapes/logo/letra_j.shp")
|
||||||
// We need to prepend base_path + "data/"
|
// We need to prepend base_path + "data/"
|
||||||
std::string fullpath;
|
std::string fullpath;
|
||||||
|
|||||||
@@ -16,18 +16,18 @@ namespace Resource {
|
|||||||
class Loader {
|
class Loader {
|
||||||
public:
|
public:
|
||||||
// Singleton
|
// Singleton
|
||||||
static Loader& get();
|
static auto get() -> Loader&;
|
||||||
|
|
||||||
// Inicialización
|
// Inicialización
|
||||||
bool initialize(const std::string& pack_file, bool enable_fallback);
|
auto initialize(const std::string& pack_file, bool enable_fallback) -> bool;
|
||||||
|
|
||||||
// Càrrega de recursos
|
// Càrrega de recursos
|
||||||
std::vector<uint8_t> loadResource(const std::string& filename);
|
auto loadResource(const std::string& filename) -> std::vector<uint8_t>;
|
||||||
bool resourceExists(const std::string& filename);
|
auto resourceExists(const std::string& filename) -> bool;
|
||||||
|
|
||||||
// Validació
|
// Validació
|
||||||
bool validatePack();
|
auto validatePack() -> bool;
|
||||||
[[nodiscard]] bool isPackLoaded() const;
|
[[nodiscard]] auto isPackLoaded() const -> bool;
|
||||||
|
|
||||||
// Estat
|
// Estat
|
||||||
void setBasePath(const std::string& path);
|
void setBasePath(const std::string& path);
|
||||||
@@ -35,7 +35,7 @@ class Loader {
|
|||||||
|
|
||||||
// No es pot copiar ni moure
|
// No es pot copiar ni moure
|
||||||
Loader(const Loader&) = delete;
|
Loader(const Loader&) = delete;
|
||||||
Loader& operator=(const Loader&) = delete;
|
auto operator=(const Loader&) -> Loader& = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Loader() = default;
|
Loader() = default;
|
||||||
@@ -47,7 +47,7 @@ class Loader {
|
|||||||
std::string base_path_;
|
std::string base_path_;
|
||||||
|
|
||||||
// Funciones auxiliars
|
// Funciones auxiliars
|
||||||
std::vector<uint8_t> loadFromFilesystem(const std::string& filename);
|
auto loadFromFilesystem(const std::string& filename) -> std::vector<uint8_t>;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Resource
|
} // namespace Resource
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
namespace Resource {
|
namespace Resource {
|
||||||
|
|
||||||
// Calcular checksum CRC32 simplificat
|
// Calcular checksum CRC32 simplificat
|
||||||
uint32_t Pack::calculateChecksum(const std::vector<uint8_t>& data) const {
|
auto Pack::calculateChecksum(const std::vector<uint8_t>& data) const -> uint32_t {
|
||||||
uint32_t checksum = 0x12345678;
|
uint32_t checksum = 0x12345678;
|
||||||
for (unsigned char byte : data) {
|
for (unsigned char byte : data) {
|
||||||
checksum = ((checksum << 5) + checksum) + byte;
|
checksum = ((checksum << 5) + checksum) + byte;
|
||||||
@@ -35,7 +35,7 @@ void Pack::decryptData(std::vector<uint8_t>& data, const std::string& key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Llegir file complet a memòria
|
// Llegir file complet a memòria
|
||||||
std::vector<uint8_t> Pack::readFile(const std::string& filepath) {
|
auto Pack::readFile(const std::string& filepath) -> std::vector<uint8_t> {
|
||||||
std::ifstream file(filepath, std::ios::binary | std::ios::ate);
|
std::ifstream file(filepath, std::ios::binary | std::ios::ate);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
std::cerr << "[ResourcePack] Error: no es pot obrir " << filepath << '\n';
|
std::cerr << "[ResourcePack] Error: no es pot obrir " << filepath << '\n';
|
||||||
@@ -55,7 +55,7 @@ std::vector<uint8_t> Pack::readFile(const std::string& filepath) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Añadir un file individual al paquet
|
// Añadir un file individual al paquet
|
||||||
bool Pack::addFile(const std::string& filepath, const std::string& pack_name) {
|
auto Pack::addFile(const std::string& filepath, const std::string& pack_name) -> bool {
|
||||||
auto file_data = readFile(filepath);
|
auto file_data = readFile(filepath);
|
||||||
if (file_data.empty()) {
|
if (file_data.empty()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -78,8 +78,8 @@ bool Pack::addFile(const std::string& filepath, const std::string& pack_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Añadir todos los archivos de un directori recursivament
|
// Añadir todos los archivos de un directori recursivament
|
||||||
bool Pack::addDirectory(const std::string& dir_path,
|
auto Pack::addDirectory(const std::string& dir_path,
|
||||||
const std::string& base_path) {
|
const std::string& base_path) -> bool {
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
if (!fs::exists(dir_path) || !fs::is_directory(dir_path)) {
|
if (!fs::exists(dir_path) || !fs::is_directory(dir_path)) {
|
||||||
@@ -117,7 +117,7 @@ bool Pack::addDirectory(const std::string& dir_path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Guardar paquet a disc
|
// Guardar paquet a disc
|
||||||
bool Pack::savePack(const std::string& pack_file) {
|
auto Pack::savePack(const std::string& pack_file) -> bool {
|
||||||
std::ofstream file(pack_file, std::ios::binary);
|
std::ofstream file(pack_file, std::ios::binary);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
std::cerr << "[ResourcePack] Error: no es pot crear " << pack_file << '\n';
|
std::cerr << "[ResourcePack] Error: no es pot crear " << pack_file << '\n';
|
||||||
@@ -161,7 +161,7 @@ bool Pack::savePack(const std::string& pack_file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carregar paquet desde disc
|
// Carregar paquet desde disc
|
||||||
bool Pack::loadPack(const std::string& pack_file) {
|
auto Pack::loadPack(const std::string& pack_file) -> bool {
|
||||||
std::ifstream file(pack_file, std::ios::binary);
|
std::ifstream file(pack_file, std::ios::binary);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
std::cerr << "[ResourcePack] Error: no es pot obrir " << pack_file << '\n';
|
std::cerr << "[ResourcePack] Error: no es pot obrir " << pack_file << '\n';
|
||||||
@@ -226,7 +226,7 @@ bool Pack::loadPack(const std::string& pack_file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtenir un recurs del paquet
|
// Obtenir un recurs del paquet
|
||||||
std::vector<uint8_t> Pack::getResource(const std::string& filename) {
|
auto Pack::getResource(const std::string& filename) -> std::vector<uint8_t> {
|
||||||
auto it = resources_.find(filename);
|
auto it = resources_.find(filename);
|
||||||
if (it == resources_.end()) {
|
if (it == resources_.end()) {
|
||||||
std::cerr << "[ResourcePack] Error: recurs no trobat: " << filename << '\n';
|
std::cerr << "[ResourcePack] Error: recurs no trobat: " << filename << '\n';
|
||||||
@@ -257,12 +257,12 @@ std::vector<uint8_t> Pack::getResource(const std::string& filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprovar si existeix un recurs
|
// Comprovar si existeix un recurs
|
||||||
bool Pack::hasResource(const std::string& filename) const {
|
auto Pack::hasResource(const std::string& filename) const -> bool {
|
||||||
return resources_.contains(filename);
|
return resources_.contains(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtenir list de todos los recursos
|
// Obtenir list de todos los recursos
|
||||||
std::vector<std::string> Pack::getResourceList() const {
|
auto Pack::getResourceList() const -> std::vector<std::string> {
|
||||||
std::vector<std::string> list;
|
std::vector<std::string> list;
|
||||||
list.reserve(resources_.size());
|
list.reserve(resources_.size());
|
||||||
|
|
||||||
@@ -275,7 +275,7 @@ std::vector<std::string> Pack::getResourceList() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validar integritat del paquet
|
// Validar integritat del paquet
|
||||||
bool Pack::validatePack() const {
|
auto Pack::validatePack() const -> bool {
|
||||||
bool valid = true;
|
bool valid = true;
|
||||||
|
|
||||||
for (const auto& [name, entry] : resources_) {
|
for (const auto& [name, entry] : resources_) {
|
||||||
|
|||||||
@@ -32,20 +32,20 @@ class Pack {
|
|||||||
~Pack() = default;
|
~Pack() = default;
|
||||||
|
|
||||||
// Añadir archivos al paquet
|
// Añadir archivos al paquet
|
||||||
bool addFile(const std::string& filepath, const std::string& pack_name);
|
auto addFile(const std::string& filepath, const std::string& pack_name) -> bool;
|
||||||
bool addDirectory(const std::string& dir_path, const std::string& base_path = "");
|
auto addDirectory(const std::string& dir_path, const std::string& base_path = "") -> bool;
|
||||||
|
|
||||||
// Guardar i load paquets
|
// Guardar i load paquets
|
||||||
bool savePack(const std::string& pack_file);
|
auto savePack(const std::string& pack_file) -> bool;
|
||||||
bool loadPack(const std::string& pack_file);
|
auto loadPack(const std::string& pack_file) -> bool;
|
||||||
|
|
||||||
// Accés a recursos
|
// Accés a recursos
|
||||||
std::vector<uint8_t> getResource(const std::string& filename);
|
auto getResource(const std::string& filename) -> std::vector<uint8_t>;
|
||||||
[[nodiscard]] bool hasResource(const std::string& filename) const;
|
[[nodiscard]] auto hasResource(const std::string& filename) const -> bool;
|
||||||
[[nodiscard]] std::vector<std::string> getResourceList() const;
|
[[nodiscard]] auto getResourceList() const -> std::vector<std::string>;
|
||||||
|
|
||||||
// Validació
|
// Validació
|
||||||
[[nodiscard]] bool validatePack() const;
|
[[nodiscard]] auto validatePack() const -> bool;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Constants
|
// Constants
|
||||||
@@ -58,8 +58,8 @@ class Pack {
|
|||||||
std::vector<uint8_t> data_;
|
std::vector<uint8_t> data_;
|
||||||
|
|
||||||
// Funciones auxiliars
|
// Funciones auxiliars
|
||||||
std::vector<uint8_t> readFile(const std::string& filepath);
|
auto readFile(const std::string& filepath) -> std::vector<uint8_t>;
|
||||||
[[nodiscard]] uint32_t calculateChecksum(const std::vector<uint8_t>& data) const;
|
[[nodiscard]] auto calculateChecksum(const std::vector<uint8_t>& data) const -> uint32_t;
|
||||||
void encryptData(std::vector<uint8_t>& data, const std::string& key);
|
void encryptData(std::vector<uint8_t>& data, const std::string& key);
|
||||||
void decryptData(std::vector<uint8_t>& data, const std::string& key);
|
void decryptData(std::vector<uint8_t>& data, const std::string& key);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,15 +23,8 @@ constexpr float FPS_UPDATE_INTERVAL = 0.5F;
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
DebugOverlay::DebugOverlay(Rendering::Renderer* renderer)
|
DebugOverlay::DebugOverlay(Rendering::Renderer* renderer)
|
||||||
: text_(renderer),
|
: text_(renderer)
|
||||||
#ifdef _DEBUG
|
{}
|
||||||
visible_(true),
|
|
||||||
#else
|
|
||||||
visible_(false),
|
|
||||||
#endif
|
|
||||||
fps_accumulator_(0.0F),
|
|
||||||
fps_frame_count_(0),
|
|
||||||
fps_display_(0) {}
|
|
||||||
|
|
||||||
void DebugOverlay::update(float delta_time) {
|
void DebugOverlay::update(float delta_time) {
|
||||||
fps_accumulator_ += delta_time;
|
fps_accumulator_ += delta_time;
|
||||||
|
|||||||
@@ -27,12 +27,12 @@ class DebugOverlay {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Graphics::VectorText text_;
|
Graphics::VectorText text_;
|
||||||
bool visible_;
|
bool visible_{true};
|
||||||
|
|
||||||
// FPS counter — se actualiza cada FPS_UPDATE_INTERVAL segundos.
|
// FPS counter — se actualiza cada FPS_UPDATE_INTERVAL segundos.
|
||||||
float fps_accumulator_;
|
float fps_accumulator_{0.0F};
|
||||||
int fps_frame_count_;
|
int fps_frame_count_{0};
|
||||||
int fps_display_;
|
int fps_display_{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace System
|
} // namespace System
|
||||||
|
|||||||
@@ -327,7 +327,12 @@ void Director::runFrameLoop(Scene& scene, SDLManager& sdl, SceneContext& context
|
|||||||
debug_overlay.update(delta_time);
|
debug_overlay.update(delta_time);
|
||||||
Audio::update();
|
Audio::update();
|
||||||
|
|
||||||
sdl.clear(0, 0, 0);
|
// Si la swapchain no está disponible (ventana minimizada, etc.),
|
||||||
|
// saltarse draw+present ese frame: dibujar dejaría vértices
|
||||||
|
// colgando en el batch interno sin nadie que los presente.
|
||||||
|
if (!sdl.clear(0, 0, 0)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
sdl.updateRenderingContext();
|
sdl.updateRenderingContext();
|
||||||
scene.draw();
|
scene.draw();
|
||||||
debug_overlay.draw(); // siempre on top de la escena
|
debug_overlay.draw(); // siempre on top de la escena
|
||||||
|
|||||||
@@ -19,29 +19,29 @@ struct MatchConfig {
|
|||||||
// Métodos auxiliars
|
// Métodos auxiliars
|
||||||
|
|
||||||
// Retorna true si solo hay un player active
|
// Retorna true si solo hay un player active
|
||||||
[[nodiscard]] bool es_un_jugador() const {
|
[[nodiscard]] auto es_un_jugador() const -> bool {
|
||||||
return (jugador1_actiu && !jugador2_actiu) ||
|
return (jugador1_actiu && !jugador2_actiu) ||
|
||||||
(!jugador1_actiu && jugador2_actiu);
|
(!jugador1_actiu && jugador2_actiu);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retorna true si hay dos jugadors active
|
// Retorna true si hay dos jugadors active
|
||||||
[[nodiscard]] bool son_dos_jugadors() const {
|
[[nodiscard]] auto son_dos_jugadors() const -> bool {
|
||||||
return jugador1_actiu && jugador2_actiu;
|
return jugador1_actiu && jugador2_actiu;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retorna true si no hay sin player active
|
// Retorna true si no hay sin player active
|
||||||
[[nodiscard]] bool cap_jugador() const {
|
[[nodiscard]] auto cap_jugador() const -> bool {
|
||||||
return !jugador1_actiu && !jugador2_actiu;
|
return !jugador1_actiu && !jugador2_actiu;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compte de jugadors active (0, 1 o 2)
|
// Compte de jugadors active (0, 1 o 2)
|
||||||
[[nodiscard]] uint8_t compte_jugadors() const {
|
[[nodiscard]] auto compte_jugadors() const -> uint8_t {
|
||||||
return (jugador1_actiu ? 1 : 0) + (jugador2_actiu ? 1 : 0);
|
return (jugador1_actiu ? 1 : 0) + (jugador2_actiu ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retorna l'ID de l'únic player active (0 o 1)
|
// Retorna l'ID de l'únic player active (0 o 1)
|
||||||
// Solo vàlid si es_un_jugador() retorna true
|
// Solo vàlid si es_un_jugador() retorna true
|
||||||
[[nodiscard]] uint8_t id_unic_jugador() const {
|
[[nodiscard]] auto id_unic_jugador() const -> uint8_t {
|
||||||
if (jugador1_actiu && !jugador2_actiu) {
|
if (jugador1_actiu && !jugador2_actiu) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ using SceneType = SceneContext::SceneType;
|
|||||||
|
|
||||||
namespace GlobalEvents {
|
namespace GlobalEvents {
|
||||||
|
|
||||||
bool handle(const SDL_Event& event, SDLManager& sdl, SceneContext& context) {
|
auto handle(const SDL_Event& event, SDLManager& sdl, SceneContext& context) -> bool {
|
||||||
// 1. Permitir que Input procese el evento (para hotplug de gamepads)
|
// 1. Permitir que Input procese el evento (para hotplug de gamepads)
|
||||||
auto event_msg = Input::get()->handleEvent(event);
|
auto event_msg = Input::get()->handleEvent(event);
|
||||||
if (!event_msg.empty()) {
|
if (!event_msg.empty()) {
|
||||||
|
|||||||
@@ -15,5 +15,5 @@ class SceneContext;
|
|||||||
namespace GlobalEvents {
|
namespace GlobalEvents {
|
||||||
// Processa events globals (F1/F2/F3/ESC/QUIT)
|
// Processa events globals (F1/F2/F3/ESC/QUIT)
|
||||||
// Retorna true si l'event ha state processat y no necesario seguir processant-lo
|
// Retorna true si l'event ha state processat y no necesario seguir processant-lo
|
||||||
bool handle(const SDL_Event& event, SDLManager& sdl, SceneManager::SceneContext& context);
|
auto handle(const SDL_Event& event, SDLManager& sdl, SceneManager::SceneContext& context) -> bool;
|
||||||
} // namespace GlobalEvents
|
} // namespace GlobalEvents
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class SceneContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtenir configuración de match (consumit per GameScene)
|
// Obtenir configuración de match (consumit per GameScene)
|
||||||
[[nodiscard]] const GameConfig::MatchConfig& getMatchConfig() const {
|
[[nodiscard]] auto getMatchConfig() const -> const GameConfig::MatchConfig& {
|
||||||
return match_config_;
|
return match_config_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ void initializePathSystem(const char* argv0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtenir el directori de l'executable
|
// Obtenir el directori de l'executable
|
||||||
std::string getExecutableDirectory() {
|
auto getExecutableDirectory() -> std::string {
|
||||||
if (executable_directory_.empty()) {
|
if (executable_directory_.empty()) {
|
||||||
std::cerr << "[PathUtils] ADVERTÈNCIA: Sistema de rutes no inicialitzat\n";
|
std::cerr << "[PathUtils] ADVERTÈNCIA: Sistema de rutes no inicialitzat\n";
|
||||||
return ".";
|
return ".";
|
||||||
@@ -46,7 +46,7 @@ std::string getExecutableDirectory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Detectar si estem dins un bundle de macOS
|
// Detectar si estem dins un bundle de macOS
|
||||||
bool isMacOSBundle() {
|
auto isMacOSBundle() -> bool {
|
||||||
#ifdef MACOS_BUNDLE
|
#ifdef MACOS_BUNDLE
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
@@ -58,7 +58,7 @@ bool isMacOSBundle() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtenir la ruta base dels recursos
|
// Obtenir la ruta base dels recursos
|
||||||
std::string getResourceBasePath() {
|
auto getResourceBasePath() -> std::string {
|
||||||
std::string exe_dir = getExecutableDirectory();
|
std::string exe_dir = getExecutableDirectory();
|
||||||
|
|
||||||
if (isMacOSBundle()) {
|
if (isMacOSBundle()) {
|
||||||
@@ -70,7 +70,7 @@ std::string getResourceBasePath() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Normalitzar ruta (convertir barres, etc.)
|
// Normalitzar ruta (convertir barres, etc.)
|
||||||
std::string normalizePath(const std::string& path) {
|
auto normalizePath(const std::string& path) -> std::string {
|
||||||
std::string normalized = path;
|
std::string normalized = path;
|
||||||
|
|
||||||
// Convertir barres invertides a normals
|
// Convertir barres invertides a normals
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ namespace Utils {
|
|||||||
void initializePathSystem(const char* argv0);
|
void initializePathSystem(const char* argv0);
|
||||||
|
|
||||||
// Obtenció de rutes
|
// Obtenció de rutes
|
||||||
std::string getExecutableDirectory();
|
auto getExecutableDirectory() -> std::string;
|
||||||
std::string getResourceBasePath();
|
auto getResourceBasePath() -> std::string;
|
||||||
|
|
||||||
// Detecció de plataforma
|
// Detecció de plataforma
|
||||||
bool isMacOSBundle();
|
auto isMacOSBundle() -> bool;
|
||||||
|
|
||||||
// Normalització
|
// Normalització
|
||||||
std::string normalizePath(const std::string& path);
|
auto normalizePath(const std::string& path) -> std::string;
|
||||||
|
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ constexpr int VELOCITAT_MAX = static_cast<int>(Defaults::Physics::BULLET_SPEED);
|
|||||||
constexpr float PI = Defaults::Math::PI;
|
constexpr float PI = Defaults::Math::PI;
|
||||||
|
|
||||||
// Helpers per comprovar límits de zona
|
// Helpers per comprovar límits de zona
|
||||||
inline bool dins_zona_joc(float x, float y) {
|
inline auto dins_zona_joc(float x, float y) -> bool {
|
||||||
const SDL_FPoint point = {x, y};
|
const SDL_FPoint point = {x, y};
|
||||||
return SDL_PointInRectFloat(&point, &Defaults::Zones::PLAYAREA);
|
return SDL_PointInRectFloat(&point, &Defaults::Zones::PLAYAREA);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace Effects {
|
|||||||
|
|
||||||
// Helper: transformar point con rotación, scale i traslación
|
// Helper: transformar point con rotación, scale i traslación
|
||||||
// (Copiat de shape_renderer.cpp:12-34)
|
// (Copiat de shape_renderer.cpp:12-34)
|
||||||
static Vec2 transform_point(const Vec2& point, const Vec2& shape_centre, const Vec2& position, float angle, float scale) {
|
static auto transform_point(const Vec2& point, const Vec2& shape_centre, const Vec2& position, float angle, float scale) -> Vec2 {
|
||||||
// 1. Centrar el point respecte al centro de la shape
|
// 1. Centrar el point respecte al centro de la shape
|
||||||
float centered_x = point.x - shape_centre.x;
|
float centered_x = point.x - shape_centre.x;
|
||||||
float centered_y = point.y - shape_centre.y;
|
float centered_y = point.y - shape_centre.y;
|
||||||
@@ -320,7 +320,7 @@ void DebrisManager::draw() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Debris* DebrisManager::findFreeSlot() {
|
auto DebrisManager::findFreeSlot() -> Debris* {
|
||||||
for (auto& debris : debris_pool_) {
|
for (auto& debris : debris_pool_) {
|
||||||
if (!debris.active) {
|
if (!debris.active) {
|
||||||
return &debris;
|
return &debris;
|
||||||
@@ -329,9 +329,9 @@ Debris* DebrisManager::findFreeSlot() {
|
|||||||
return nullptr; // Pool ple
|
return nullptr; // Pool ple
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2 DebrisManager::computeExplosionDirection(const Vec2& p1,
|
auto DebrisManager::computeExplosionDirection(const Vec2& p1,
|
||||||
const Vec2& p2,
|
const Vec2& p2,
|
||||||
const Vec2& centre_objecte) const {
|
const Vec2& centre_objecte) const -> Vec2 {
|
||||||
// 1. Calcular centro del segment
|
// 1. Calcular centro del segment
|
||||||
float centro_seg_x = (p1.x + p2.x) / 2.0F;
|
float centro_seg_x = (p1.x + p2.x) / 2.0F;
|
||||||
float centro_seg_y = (p1.y + p2.y) / 2.0F;
|
float centro_seg_y = (p1.y + p2.y) / 2.0F;
|
||||||
@@ -372,7 +372,7 @@ void DebrisManager::reset() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DebrisManager::getActiveCount() const {
|
auto DebrisManager::getActiveCount() const -> int {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (const auto& debris : debris_pool_) {
|
for (const auto& debris : debris_pool_) {
|
||||||
if (debris.active) {
|
if (debris.active) {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class DebrisManager {
|
|||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
// Obtenir número de fragments active
|
// Obtenir número de fragments active
|
||||||
[[nodiscard]] int getActiveCount() const;
|
[[nodiscard]] auto getActiveCount() const -> int;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Rendering::Renderer* renderer_;
|
Rendering::Renderer* renderer_;
|
||||||
@@ -67,10 +67,10 @@ class DebrisManager {
|
|||||||
std::array<Debris, MAX_DEBRIS> debris_pool_;
|
std::array<Debris, MAX_DEBRIS> debris_pool_;
|
||||||
|
|
||||||
// Trobar primer slot inactiu
|
// Trobar primer slot inactiu
|
||||||
Debris* findFreeSlot();
|
auto findFreeSlot() -> Debris*;
|
||||||
|
|
||||||
// Calcular direcció de explosión (radial, des del centro hacia el segment)
|
// Calcular direcció de explosión (radial, des del centro hacia el segment)
|
||||||
[[nodiscard]] Vec2 computeExplosionDirection(const Vec2& p1, const Vec2& p2, const Vec2& centre_objecte) const;
|
[[nodiscard]] auto computeExplosionDirection(const Vec2& p1, const Vec2& p2, const Vec2& centre_objecte) const -> Vec2;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Effects
|
} // namespace Effects
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ void FloatingScoreManager::reset() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FloatingScoreManager::getActiveCount() const {
|
auto FloatingScoreManager::getActiveCount() const -> int {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (const auto& pf : pool_) {
|
for (const auto& pf : pool_) {
|
||||||
if (pf.active) {
|
if (pf.active) {
|
||||||
@@ -87,7 +87,7 @@ int FloatingScoreManager::getActiveCount() const {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
FloatingScore* FloatingScoreManager::findFreeSlot() {
|
auto FloatingScoreManager::findFreeSlot() -> FloatingScore* {
|
||||||
for (auto& pf : pool_) {
|
for (auto& pf : pool_) {
|
||||||
if (!pf.active) {
|
if (!pf.active) {
|
||||||
return &pf;
|
return &pf;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class FloatingScoreManager {
|
|||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
// Obtenir número active (debug)
|
// Obtenir número active (debug)
|
||||||
[[nodiscard]] int getActiveCount() const;
|
[[nodiscard]] auto getActiveCount() const -> int;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Graphics::VectorText text_; // Sistema de text vectorial
|
Graphics::VectorText text_; // Sistema de text vectorial
|
||||||
@@ -49,7 +49,7 @@ class FloatingScoreManager {
|
|||||||
std::array<FloatingScore, MAX_PUNTUACIONS> pool_;
|
std::array<FloatingScore, MAX_PUNTUACIONS> pool_;
|
||||||
|
|
||||||
// Trobar primer slot inactiu
|
// Trobar primer slot inactiu
|
||||||
FloatingScore* findFreeSlot();
|
auto findFreeSlot() -> FloatingScore*;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Effects
|
} // namespace Effects
|
||||||
|
|||||||
@@ -23,10 +23,8 @@ constexpr float BULLET_SPEED = 140.0F;
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Bullet::Bullet(Rendering::Renderer* renderer)
|
Bullet::Bullet(Rendering::Renderer* renderer)
|
||||||
: Entity(renderer),
|
: Entity(renderer)
|
||||||
esta_(false),
|
{
|
||||||
owner_id_(0),
|
|
||||||
grace_timer_(0.0F) {
|
|
||||||
// Brightness específico para balas
|
// Brightness específico para balas
|
||||||
brightness_ = Defaults::Brightness::BALA;
|
brightness_ = Defaults::Brightness::BALA;
|
||||||
|
|
||||||
|
|||||||
@@ -40,15 +40,9 @@ auto velocityToAngle(const Vec2& velocity) -> float {
|
|||||||
|
|
||||||
Enemy::Enemy(Rendering::Renderer* renderer)
|
Enemy::Enemy(Rendering::Renderer* renderer)
|
||||||
: Entity(renderer),
|
: Entity(renderer),
|
||||||
drotacio_(0.0F),
|
|
||||||
rotacio_(0.0F),
|
tracking_strength_(0.5F)
|
||||||
esta_(false),
|
{
|
||||||
type_(EnemyType::PENTAGON),
|
|
||||||
tracking_timer_(0.0F),
|
|
||||||
ship_position_(nullptr),
|
|
||||||
tracking_strength_(0.5F),
|
|
||||||
direction_change_timer_(0.0F),
|
|
||||||
timer_invulnerabilitat_(0.0F) {
|
|
||||||
brightness_ = Defaults::Brightness::ENEMIC;
|
brightness_ = Defaults::Brightness::ENEMIC;
|
||||||
|
|
||||||
// Configuración del cuerpo físico — defaults para enemy genérico.
|
// Configuración del cuerpo físico — defaults para enemy genérico.
|
||||||
|
|||||||
@@ -20,9 +20,8 @@
|
|||||||
#include "game/constants.hpp"
|
#include "game/constants.hpp"
|
||||||
|
|
||||||
Ship::Ship(Rendering::Renderer* renderer, const char* shape_file)
|
Ship::Ship(Rendering::Renderer* renderer, const char* shape_file)
|
||||||
: Entity(renderer),
|
: Entity(renderer)
|
||||||
is_hit_(false),
|
{
|
||||||
invulnerable_timer_(0.0F) {
|
|
||||||
// Brightness específico para naves
|
// Brightness específico para naves
|
||||||
brightness_ = Defaults::Brightness::NAU;
|
brightness_ = Defaults::Brightness::NAU;
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ GameScene::GameScene(SDLManager& sdl, SceneContext& context)
|
|||||||
context_(context),
|
context_(context),
|
||||||
debris_manager_(sdl.getRenderer()),
|
debris_manager_(sdl.getRenderer()),
|
||||||
floating_score_manager_(sdl.getRenderer()),
|
floating_score_manager_(sdl.getRenderer()),
|
||||||
text_(sdl.getRenderer()),
|
text_(sdl.getRenderer())
|
||||||
init_hud_rect_sound_played_(false) {
|
{
|
||||||
// Recuperar configuración de match des del context
|
// Recuperar configuración de match des del context
|
||||||
match_config_ = context_.getMatchConfig();
|
match_config_ = context_.getMatchConfig();
|
||||||
|
|
||||||
@@ -748,7 +748,7 @@ void GameScene::dibuixar_marcador() {
|
|||||||
text_.renderCentered(text, {.x = centre_x, .y = centre_y}, scale, spacing);
|
text_.renderCentered(text, {.x = centre_x, .y = centre_y}, scale, spacing);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GameScene::buildScoreboard() const {
|
auto GameScene::buildScoreboard() const -> std::string {
|
||||||
// Puntuación P1 (6 dígits) - mostrar zeros si inactiu
|
// Puntuación P1 (6 dígits) - mostrar zeros si inactiu
|
||||||
std::string score_p1;
|
std::string score_p1;
|
||||||
std::string vides_p1;
|
std::string vides_p1;
|
||||||
@@ -858,7 +858,7 @@ void GameScene::dibuixar_missatge_stage(const std::string& message) {
|
|||||||
// Helper methods for 2-player support
|
// Helper methods for 2-player support
|
||||||
// ========================================
|
// ========================================
|
||||||
|
|
||||||
Vec2 GameScene::obtenir_punt_spawn(uint8_t player_id) const {
|
auto GameScene::obtenir_punt_spawn(uint8_t player_id) const -> Vec2 {
|
||||||
const SDL_FRect& zona = Defaults::Zones::PLAYAREA;
|
const SDL_FRect& zona = Defaults::Zones::PLAYAREA;
|
||||||
|
|
||||||
float x_ratio;
|
float x_ratio;
|
||||||
|
|||||||
@@ -82,14 +82,14 @@ class GameScene final : public Scene {
|
|||||||
std::unique_ptr<StageSystem::StageManager> stage_manager_;
|
std::unique_ptr<StageSystem::StageManager> stage_manager_;
|
||||||
|
|
||||||
// Control de sons de animación INIT_HUD
|
// Control de sons de animación INIT_HUD
|
||||||
bool init_hud_rect_sound_played_; // Flag para evitar repetir sonido del rectángulo
|
bool init_hud_rect_sound_played_{false}; // Flag para evitar repetir sonido del rectángulo
|
||||||
|
|
||||||
// Funciones privades
|
// Funciones privades
|
||||||
void tocado(uint8_t player_id);
|
void tocado(uint8_t player_id);
|
||||||
void dibuixar_marges() const; // Dibuixar vores de la zona de juego
|
void dibuixar_marges() const; // Dibuixar vores de la zona de juego
|
||||||
void dibuixar_marcador(); // Dibuixar marcador de puntuación
|
void dibuixar_marcador(); // Dibuixar marcador de puntuación
|
||||||
void disparar_bala(uint8_t player_id); // Shoot bullet from player
|
void disparar_bala(uint8_t player_id); // Shoot bullet from player
|
||||||
[[nodiscard]] Vec2 obtenir_punt_spawn(uint8_t player_id) const; // Get spawn position for player
|
[[nodiscard]] auto obtenir_punt_spawn(uint8_t player_id) const -> Vec2; // Get spawn position for player
|
||||||
|
|
||||||
// [NEW] Continue & Join system
|
// [NEW] Continue & Join system
|
||||||
void unir_jugador(uint8_t player_id); // Join inactive player mid-game
|
void unir_jugador(uint8_t player_id); // Join inactive player mid-game
|
||||||
@@ -99,7 +99,7 @@ class GameScene final : public Scene {
|
|||||||
void dibuixar_missatge_stage(const std::string& message);
|
void dibuixar_missatge_stage(const std::string& message);
|
||||||
|
|
||||||
// [NEW] Función helper del marcador
|
// [NEW] Función helper del marcador
|
||||||
[[nodiscard]] std::string buildScoreboard() const;
|
[[nodiscard]] auto buildScoreboard() const -> std::string;
|
||||||
|
|
||||||
// Sub-pasos de update() (descompuestos en Fase 9d para reducir
|
// Sub-pasos de update() (descompuestos en Fase 9d para reducir
|
||||||
// complejidad cognitiva; cada uno es responsable de una sección).
|
// complejidad cognitiva; cada uno es responsable de una sección).
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ using Option = SceneContext::Option;
|
|||||||
|
|
||||||
// Helper: calcular el progrés individual de una lletra
|
// Helper: calcular el progrés individual de una lletra
|
||||||
// en función del progrés global (efecte seqüencial)
|
// en función del progrés global (efecte seqüencial)
|
||||||
static float calcular_progress_letra(size_t letra_index, size_t num_letras, float global_progress, float threshold) {
|
static auto calcular_progress_letra(size_t letra_index, size_t num_letras, float global_progress, float threshold) -> float {
|
||||||
if (num_letras == 0) {
|
if (num_letras == 0) {
|
||||||
return 1.0F;
|
return 1.0F;
|
||||||
}
|
}
|
||||||
@@ -46,11 +46,9 @@ static float calcular_progress_letra(size_t letra_index, size_t num_letras, floa
|
|||||||
LogoScene::LogoScene(SDLManager& sdl, SceneContext& context)
|
LogoScene::LogoScene(SDLManager& sdl, SceneContext& context)
|
||||||
: sdl_(sdl),
|
: sdl_(sdl),
|
||||||
context_(context),
|
context_(context),
|
||||||
estat_actual_(AnimationState::PRE_ANIMATION),
|
|
||||||
temps_estat_actual_(0.0F),
|
debris_manager_(std::make_unique<Effects::DebrisManager>(sdl.getRenderer()))
|
||||||
debris_manager_(std::make_unique<Effects::DebrisManager>(sdl.getRenderer())),
|
{
|
||||||
lletra_explosio_index_(0),
|
|
||||||
temps_des_ultima_explosio_(0.0F) {
|
|
||||||
std::cout << "SceneType Logo: Inicialitzant...\n";
|
std::cout << "SceneType Logo: Inicialitzant...\n";
|
||||||
|
|
||||||
// Consumir opciones (LOGO no processa opciones actualment)
|
// Consumir opciones (LOGO no processa opciones actualment)
|
||||||
@@ -181,7 +179,7 @@ void LogoScene::canviar_estat(AnimationState nou_estat) {
|
|||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LogoScene::totes_lletres_completes() const {
|
auto LogoScene::totes_lletres_completes() const -> bool {
|
||||||
// Cuando global_progress = 1.0, todas las lletres tenen letra_progress = 1.0
|
// Cuando global_progress = 1.0, todas las lletres tenen letra_progress = 1.0
|
||||||
return temps_estat_actual_ >= DURACIO_ZOOM;
|
return temps_estat_actual_ >= DURACIO_ZOOM;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,16 +42,16 @@ class LogoScene final : public Scene {
|
|||||||
|
|
||||||
SDLManager& sdl_;
|
SDLManager& sdl_;
|
||||||
SceneManager::SceneContext& context_;
|
SceneManager::SceneContext& context_;
|
||||||
AnimationState estat_actual_; // Estat actual de la màquina
|
AnimationState estat_actual_{AnimationState::PRE_ANIMATION}; // Estat actual de la màquina
|
||||||
float
|
float
|
||||||
temps_estat_actual_; // Temps en l'state actual (reset en cada transición)
|
temps_estat_actual_{0.0F}; // Temps en l'state actual (reset en cada transición)
|
||||||
|
|
||||||
// Gestor de fragments de explosions
|
// Gestor de fragments de explosions
|
||||||
std::unique_ptr<Effects::DebrisManager> debris_manager_;
|
std::unique_ptr<Effects::DebrisManager> debris_manager_;
|
||||||
|
|
||||||
// Seguiment de explosions seqüencials
|
// Seguiment de explosions seqüencials
|
||||||
size_t lletra_explosio_index_; // Índex de la següent lletra a explode
|
size_t lletra_explosio_index_{0}; // Índex de la següent lletra a explode
|
||||||
float temps_des_ultima_explosio_; // Temps desde l'última explosión
|
float temps_des_ultima_explosio_{0.0F}; // Temps desde l'última explosión
|
||||||
std::vector<size_t> ordre_explosio_; // Ordre aleatori de índexs de lletres
|
std::vector<size_t> ordre_explosio_; // Ordre aleatori de índexs de lletres
|
||||||
|
|
||||||
// Estructura para cada lletra del logo
|
// Estructura para cada lletra del logo
|
||||||
@@ -90,5 +90,5 @@ class LogoScene final : public Scene {
|
|||||||
|
|
||||||
// Métodos de gestió de estats
|
// Métodos de gestió de estats
|
||||||
void canviar_estat(AnimationState nou_estat);
|
void canviar_estat(AnimationState nou_estat);
|
||||||
[[nodiscard]] bool totes_lletres_completes() const;
|
[[nodiscard]] auto totes_lletres_completes() const -> bool;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,13 +25,8 @@ using Option = SceneContext::Option;
|
|||||||
TitleScene::TitleScene(SDLManager& sdl, SceneContext& context)
|
TitleScene::TitleScene(SDLManager& sdl, SceneContext& context)
|
||||||
: sdl_(sdl),
|
: sdl_(sdl),
|
||||||
context_(context),
|
context_(context),
|
||||||
text_(sdl.getRenderer()),
|
text_(sdl.getRenderer())
|
||||||
estat_actual_(TitleState::STARFIELD_FADE_IN),
|
{
|
||||||
temps_acumulat_(0.0F),
|
|
||||||
temps_animacio_(0.0F),
|
|
||||||
temps_estat_main_(0.0F),
|
|
||||||
animacio_activa_(false),
|
|
||||||
factor_lerp_(0.0F) {
|
|
||||||
std::cout << "SceneType Titol: Inicialitzant...\n";
|
std::cout << "SceneType Titol: Inicialitzant...\n";
|
||||||
|
|
||||||
// Inicialitzar configuración de match (sin player active per defecte)
|
// Inicialitzar configuración de match (sin player active per defecte)
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ class TitleScene final : public Scene {
|
|||||||
Graphics::VectorText text_; // Sistema de text vectorial
|
Graphics::VectorText text_; // Sistema de text vectorial
|
||||||
std::unique_ptr<Graphics::Starfield> starfield_; // Camp de estrelles de fons
|
std::unique_ptr<Graphics::Starfield> starfield_; // Camp de estrelles de fons
|
||||||
std::unique_ptr<Title::ShipAnimator> ship_animator_; // Naves 3D flotantes
|
std::unique_ptr<Title::ShipAnimator> ship_animator_; // Naves 3D flotantes
|
||||||
TitleState estat_actual_; // Estat actual de la màquina
|
TitleState estat_actual_{TitleState::STARFIELD_FADE_IN}; // Estat actual de la màquina
|
||||||
float temps_acumulat_; // Temps acumulat per l'state INIT
|
float temps_acumulat_{0.0F}; // Temps acumulat per l'state INIT
|
||||||
|
|
||||||
// Lletres del título "ORNI ATTACK!"
|
// Lletres del título "ORNI ATTACK!"
|
||||||
std::vector<LetraLogo> lletres_orni_; // Lletres de "ORNI" (línia 1)
|
std::vector<LetraLogo> lletres_orni_; // Lletres de "ORNI" (línia 1)
|
||||||
@@ -74,14 +74,14 @@ class TitleScene final : public Scene {
|
|||||||
std::vector<LetraLogo> lletres_jailgames_;
|
std::vector<LetraLogo> lletres_jailgames_;
|
||||||
|
|
||||||
// Estat de animación del logo
|
// Estat de animación del logo
|
||||||
float temps_animacio_; // Temps acumulat per animación orbital
|
float temps_animacio_{0.0F}; // Temps acumulat per animación orbital
|
||||||
std::vector<Vec2> posicions_originals_orni_; // Posicions originals de "ORNI"
|
std::vector<Vec2> posicions_originals_orni_; // Posicions originals de "ORNI"
|
||||||
std::vector<Vec2> posicions_originals_attack_; // Posicions originals de "ATTACK!"
|
std::vector<Vec2> posicions_originals_attack_; // Posicions originals de "ATTACK!"
|
||||||
|
|
||||||
// Estat de arrencada de l'animación
|
// Estat de arrencada de l'animación
|
||||||
float temps_estat_main_; // Temps acumulat en state MAIN
|
float temps_estat_main_{0.0F}; // Temps acumulat en state MAIN
|
||||||
bool animacio_activa_; // Flag: true cuando animación está activa
|
bool animacio_activa_{false}; // Flag: true cuando animación está activa
|
||||||
float factor_lerp_; // Factor de lerp actual (0.0 → 1.0)
|
float factor_lerp_{0.0F}; // Factor de lerp actual (0.0 → 1.0)
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
static constexpr float BRIGHTNESS_STARFIELD = 1.2F; // Brightness del starfield (>1.0 = més brillant)
|
static constexpr float BRIGHTNESS_STARFIELD = 1.2F; // Brightness del starfield (>1.0 = més brillant)
|
||||||
|
|||||||
@@ -16,10 +16,8 @@
|
|||||||
namespace StageSystem {
|
namespace StageSystem {
|
||||||
|
|
||||||
SpawnController::SpawnController()
|
SpawnController::SpawnController()
|
||||||
: config_(nullptr),
|
|
||||||
temps_transcorregut_(0.0F),
|
{}
|
||||||
index_spawn_actual_(0),
|
|
||||||
ship_position_(nullptr) {}
|
|
||||||
|
|
||||||
void SpawnController::configure(const StageConfig* config) {
|
void SpawnController::configure(const StageConfig* config) {
|
||||||
config_ = config;
|
config_ = config;
|
||||||
@@ -85,11 +83,11 @@ void SpawnController::update(float delta_time, std::array<Enemy, 15>& orni_array
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpawnController::tots_enemics_spawnejats() const {
|
auto SpawnController::tots_enemics_spawnejats() const -> bool {
|
||||||
return index_spawn_actual_ >= spawn_queue_.size();
|
return index_spawn_actual_ >= spawn_queue_.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpawnController::tots_enemics_destruits(const std::array<Enemy, 15>& orni_array) const {
|
auto SpawnController::tots_enemics_destruits(const std::array<Enemy, 15>& orni_array) const -> bool {
|
||||||
if (!tots_enemics_spawnejats()) {
|
if (!tots_enemics_spawnejats()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -103,7 +101,7 @@ bool SpawnController::tots_enemics_destruits(const std::array<Enemy, 15>& orni_a
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t SpawnController::get_enemics_vius(const std::array<Enemy, 15>& orni_array) const {
|
auto SpawnController::get_enemics_vius(const std::array<Enemy, 15>& orni_array) const -> uint8_t {
|
||||||
uint8_t count = 0;
|
uint8_t count = 0;
|
||||||
for (const auto& enemy : orni_array) {
|
for (const auto& enemy : orni_array) {
|
||||||
if (enemy.isActive()) {
|
if (enemy.isActive()) {
|
||||||
@@ -113,7 +111,7 @@ uint8_t SpawnController::get_enemics_vius(const std::array<Enemy, 15>& orni_arra
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t SpawnController::get_enemics_spawnejats() const {
|
auto SpawnController::get_enemics_spawnejats() const -> uint8_t {
|
||||||
return static_cast<uint8_t>(index_spawn_actual_);
|
return static_cast<uint8_t>(index_spawn_actual_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +130,7 @@ void SpawnController::generar_spawn_events() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EnemyType SpawnController::seleccionar_tipus_aleatori() const {
|
auto SpawnController::seleccionar_tipus_aleatori() const -> EnemyType {
|
||||||
if (config_ == nullptr) {
|
if (config_ == nullptr) {
|
||||||
return EnemyType::PENTAGON;
|
return EnemyType::PENTAGON;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,26 +33,26 @@ class SpawnController {
|
|||||||
void update(float delta_time, std::array<Enemy, 15>& orni_array, bool pausar = false);
|
void update(float delta_time, std::array<Enemy, 15>& orni_array, bool pausar = false);
|
||||||
|
|
||||||
// Status queries
|
// Status queries
|
||||||
[[nodiscard]] bool tots_enemics_spawnejats() const;
|
[[nodiscard]] auto tots_enemics_spawnejats() const -> bool;
|
||||||
[[nodiscard]] bool tots_enemics_destruits(const std::array<Enemy, 15>& orni_array) const;
|
[[nodiscard]] auto tots_enemics_destruits(const std::array<Enemy, 15>& orni_array) const -> bool;
|
||||||
[[nodiscard]] uint8_t get_enemics_vius(const std::array<Enemy, 15>& orni_array) const;
|
[[nodiscard]] auto get_enemics_vius(const std::array<Enemy, 15>& orni_array) const -> uint8_t;
|
||||||
[[nodiscard]] uint8_t get_enemics_spawnejats() const;
|
[[nodiscard]] auto get_enemics_spawnejats() const -> uint8_t;
|
||||||
|
|
||||||
// [NEW] Set ship position reference for safe spawn
|
// [NEW] Set ship position reference for safe spawn
|
||||||
void setShipPosition(const Vec2* ship_pos) { ship_position_ = ship_pos; }
|
void setShipPosition(const Vec2* ship_pos) { ship_position_ = ship_pos; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const StageConfig* config_; // Non-owning pointer to current stage config
|
const StageConfig* config_{nullptr}; // Non-owning pointer to current stage config
|
||||||
std::vector<SpawnEvent> spawn_queue_;
|
std::vector<SpawnEvent> spawn_queue_;
|
||||||
float temps_transcorregut_; // Elapsed time since stage start
|
float temps_transcorregut_{0.0F}; // Elapsed time since stage start
|
||||||
uint8_t index_spawn_actual_; // Next spawn to process
|
uint8_t index_spawn_actual_{0}; // Next spawn to process
|
||||||
|
|
||||||
// Spawn generation
|
// Spawn generation
|
||||||
void generar_spawn_events();
|
void generar_spawn_events();
|
||||||
[[nodiscard]] EnemyType seleccionar_tipus_aleatori() const;
|
[[nodiscard]] auto seleccionar_tipus_aleatori() const -> EnemyType;
|
||||||
void spawn_enemic(Enemy& enemy, EnemyType type, const Vec2* ship_pos = nullptr);
|
void spawn_enemic(Enemy& enemy, EnemyType type, const Vec2* ship_pos = nullptr);
|
||||||
void aplicar_multiplicadors(Enemy& enemy) const;
|
void aplicar_multiplicadors(Enemy& enemy) const;
|
||||||
const Vec2* ship_position_; // [NEW] Non-owning pointer to ship position
|
const Vec2* ship_position_{nullptr}; // [NEW] Non-owning pointer to ship position
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace StageSystem
|
} // namespace StageSystem
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ struct StageConfig {
|
|||||||
MultiplicadorsDificultat multiplicadors;
|
MultiplicadorsDificultat multiplicadors;
|
||||||
|
|
||||||
// Validació
|
// Validació
|
||||||
[[nodiscard]] bool es_valid() const {
|
[[nodiscard]] auto es_valid() const -> bool {
|
||||||
// stage_id es uint8_t: el rango superior (<=255) está garantizado por
|
// stage_id es uint8_t: el rango superior (<=255) está garantizado por
|
||||||
// el tipo; basta con confirmar que no es 0 (sentinela "sin asignar").
|
// el tipo; basta con confirmar que no es 0 (sentinela "sin asignar").
|
||||||
return stage_id >= 1 &&
|
return stage_id >= 1 &&
|
||||||
@@ -70,7 +70,7 @@ struct StageSystemConfig {
|
|||||||
std::vector<StageConfig> stages; // Índex [0] = stage 1
|
std::vector<StageConfig> stages; // Índex [0] = stage 1
|
||||||
|
|
||||||
// Obtenir configuración de un stage específic
|
// Obtenir configuración de un stage específic
|
||||||
[[nodiscard]] const StageConfig* obte_stage(uint8_t stage_id) const {
|
[[nodiscard]] auto obte_stage(uint8_t stage_id) const -> const StageConfig* {
|
||||||
if (stage_id < 1 || stage_id > stages.size()) {
|
if (stage_id < 1 || stage_id > stages.size()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
namespace StageSystem {
|
namespace StageSystem {
|
||||||
|
|
||||||
std::unique_ptr<StageSystemConfig> StageLoader::load(const std::string& path) {
|
auto StageLoader::load(const std::string& path) -> std::unique_ptr<StageSystemConfig> {
|
||||||
try {
|
try {
|
||||||
// Normalize path: "data/stages/stages.yaml" → "stages/stages.yaml"
|
// Normalize path: "data/stages/stages.yaml" → "stages/stages.yaml"
|
||||||
std::string normalized = path;
|
std::string normalized = path;
|
||||||
@@ -85,7 +85,7 @@ std::unique_ptr<StageSystemConfig> StageLoader::load(const std::string& path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StageLoader::parse_metadata(const fkyaml::node& yaml, MetadataStages& meta) {
|
auto StageLoader::parse_metadata(const fkyaml::node& yaml, MetadataStages& meta) -> bool {
|
||||||
try {
|
try {
|
||||||
if (!yaml.contains("version") || !yaml.contains("total_stages")) {
|
if (!yaml.contains("version") || !yaml.contains("total_stages")) {
|
||||||
std::cerr << "[StageLoader] Error: metadata incompleta" << '\n';
|
std::cerr << "[StageLoader] Error: metadata incompleta" << '\n';
|
||||||
@@ -105,7 +105,7 @@ bool StageLoader::parse_metadata(const fkyaml::node& yaml, MetadataStages& meta)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StageLoader::parse_stage(const fkyaml::node& yaml, StageConfig& stage) {
|
auto StageLoader::parse_stage(const fkyaml::node& yaml, StageConfig& stage) -> bool {
|
||||||
try {
|
try {
|
||||||
if (!yaml.contains("stage_id") || !yaml.contains("total_enemies") ||
|
if (!yaml.contains("stage_id") || !yaml.contains("total_enemies") ||
|
||||||
!yaml.contains("spawn_config") || !yaml.contains("enemy_distribution") ||
|
!yaml.contains("spawn_config") || !yaml.contains("enemy_distribution") ||
|
||||||
@@ -140,7 +140,7 @@ bool StageLoader::parse_stage(const fkyaml::node& yaml, StageConfig& stage) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StageLoader::parse_spawn_config(const fkyaml::node& yaml, ConfigSpawn& config) {
|
auto StageLoader::parse_spawn_config(const fkyaml::node& yaml, ConfigSpawn& config) -> bool {
|
||||||
try {
|
try {
|
||||||
if (!yaml.contains("mode") || !yaml.contains("initial_delay") ||
|
if (!yaml.contains("mode") || !yaml.contains("initial_delay") ||
|
||||||
!yaml.contains("spawn_interval")) {
|
!yaml.contains("spawn_interval")) {
|
||||||
@@ -160,7 +160,7 @@ bool StageLoader::parse_spawn_config(const fkyaml::node& yaml, ConfigSpawn& conf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StageLoader::parse_distribution(const fkyaml::node& yaml, DistribucioEnemics& dist) {
|
auto StageLoader::parse_distribution(const fkyaml::node& yaml, DistribucioEnemics& dist) -> bool {
|
||||||
try {
|
try {
|
||||||
if (!yaml.contains("pentagon") || !yaml.contains("cuadrado") ||
|
if (!yaml.contains("pentagon") || !yaml.contains("cuadrado") ||
|
||||||
!yaml.contains("molinillo")) {
|
!yaml.contains("molinillo")) {
|
||||||
@@ -186,7 +186,7 @@ bool StageLoader::parse_distribution(const fkyaml::node& yaml, DistribucioEnemic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StageLoader::parse_multipliers(const fkyaml::node& yaml, MultiplicadorsDificultat& mult) {
|
auto StageLoader::parse_multipliers(const fkyaml::node& yaml, MultiplicadorsDificultat& mult) -> bool {
|
||||||
try {
|
try {
|
||||||
if (!yaml.contains("speed_multiplier") || !yaml.contains("rotation_multiplier") ||
|
if (!yaml.contains("speed_multiplier") || !yaml.contains("rotation_multiplier") ||
|
||||||
!yaml.contains("tracking_strength")) {
|
!yaml.contains("tracking_strength")) {
|
||||||
@@ -216,7 +216,7 @@ bool StageLoader::parse_multipliers(const fkyaml::node& yaml, MultiplicadorsDifi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ModeSpawn StageLoader::parse_spawn_mode(const std::string& mode_str) {
|
auto StageLoader::parse_spawn_mode(const std::string& mode_str) -> ModeSpawn {
|
||||||
if (mode_str == "progressive") {
|
if (mode_str == "progressive") {
|
||||||
return ModeSpawn::PROGRESSIVE;
|
return ModeSpawn::PROGRESSIVE;
|
||||||
}
|
}
|
||||||
@@ -231,7 +231,7 @@ ModeSpawn StageLoader::parse_spawn_mode(const std::string& mode_str) {
|
|||||||
return ModeSpawn::PROGRESSIVE;
|
return ModeSpawn::PROGRESSIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StageLoader::validar_config(const StageSystemConfig& config) {
|
auto StageLoader::validar_config(const StageSystemConfig& config) -> bool {
|
||||||
if (config.stages.empty()) {
|
if (config.stages.empty()) {
|
||||||
std::cerr << "[StageLoader] Error: sin stage carregat" << '\n';
|
std::cerr << "[StageLoader] Error: sin stage carregat" << '\n';
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -15,19 +15,19 @@ class StageLoader {
|
|||||||
public:
|
public:
|
||||||
// Carregar configuración desde file YAML
|
// Carregar configuración desde file YAML
|
||||||
// Retorna nullptr si hay errors
|
// Retorna nullptr si hay errors
|
||||||
static std::unique_ptr<StageSystemConfig> load(const std::string& path);
|
static auto load(const std::string& path) -> std::unique_ptr<StageSystemConfig>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Parsing helpers (implementats en .cpp)
|
// Parsing helpers (implementats en .cpp)
|
||||||
static bool parse_metadata(const fkyaml::node& yaml, MetadataStages& meta);
|
static auto parse_metadata(const fkyaml::node& yaml, MetadataStages& meta) -> bool;
|
||||||
static bool parse_stage(const fkyaml::node& yaml, StageConfig& stage);
|
static auto parse_stage(const fkyaml::node& yaml, StageConfig& stage) -> bool;
|
||||||
static bool parse_spawn_config(const fkyaml::node& yaml, ConfigSpawn& config);
|
static auto parse_spawn_config(const fkyaml::node& yaml, ConfigSpawn& config) -> bool;
|
||||||
static bool parse_distribution(const fkyaml::node& yaml, DistribucioEnemics& dist);
|
static auto parse_distribution(const fkyaml::node& yaml, DistribucioEnemics& dist) -> bool;
|
||||||
static bool parse_multipliers(const fkyaml::node& yaml, MultiplicadorsDificultat& mult);
|
static auto parse_multipliers(const fkyaml::node& yaml, MultiplicadorsDificultat& mult) -> bool;
|
||||||
static ModeSpawn parse_spawn_mode(const std::string& mode_str);
|
static auto parse_spawn_mode(const std::string& mode_str) -> ModeSpawn;
|
||||||
|
|
||||||
// Validació
|
// Validació
|
||||||
static bool validar_config(const StageSystemConfig& config);
|
static auto validar_config(const StageSystemConfig& config) -> bool;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace StageSystem
|
} // namespace StageSystem
|
||||||
|
|||||||
@@ -15,10 +15,8 @@
|
|||||||
namespace StageSystem {
|
namespace StageSystem {
|
||||||
|
|
||||||
StageManager::StageManager(const StageSystemConfig* config)
|
StageManager::StageManager(const StageSystemConfig* config)
|
||||||
: config_(config),
|
: config_(config)
|
||||||
estat_(EstatStage::LEVEL_START),
|
{
|
||||||
stage_actual_(1),
|
|
||||||
timer_transicio_(0.0F) {
|
|
||||||
if (config_ == nullptr) {
|
if (config_ == nullptr) {
|
||||||
std::cerr << "[StageManager] Error: config es null" << '\n';
|
std::cerr << "[StageManager] Error: config es null" << '\n';
|
||||||
}
|
}
|
||||||
@@ -59,13 +57,13 @@ void StageManager::stage_completat() {
|
|||||||
canviar_estat(EstatStage::LEVEL_COMPLETED);
|
canviar_estat(EstatStage::LEVEL_COMPLETED);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StageManager::tot_completat() const {
|
auto StageManager::tot_completat() const -> bool {
|
||||||
return stage_actual_ >= config_->metadata.total_stages &&
|
return stage_actual_ >= config_->metadata.total_stages &&
|
||||||
estat_ == EstatStage::LEVEL_COMPLETED &&
|
estat_ == EstatStage::LEVEL_COMPLETED &&
|
||||||
timer_transicio_ <= 0.0F;
|
timer_transicio_ <= 0.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
const StageConfig* StageManager::get_config_actual() const {
|
auto StageManager::get_config_actual() const -> const StageConfig* {
|
||||||
return config_->obte_stage(stage_actual_);
|
return config_->obte_stage(stage_actual_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,26 +29,26 @@ class StageManager {
|
|||||||
|
|
||||||
// Stage progression
|
// Stage progression
|
||||||
void stage_completat(); // Call when all enemies destroyed
|
void stage_completat(); // Call when all enemies destroyed
|
||||||
[[nodiscard]] bool tot_completat() const; // All 10 stages done?
|
[[nodiscard]] auto tot_completat() const -> bool; // All 10 stages done?
|
||||||
|
|
||||||
// Current state queries
|
// Current state queries
|
||||||
[[nodiscard]] EstatStage get_estat() const { return estat_; }
|
[[nodiscard]] auto get_estat() const -> EstatStage { return estat_; }
|
||||||
[[nodiscard]] uint8_t get_stage_actual() const { return stage_actual_; }
|
[[nodiscard]] auto get_stage_actual() const -> uint8_t { return stage_actual_; }
|
||||||
[[nodiscard]] const StageConfig* get_config_actual() const;
|
[[nodiscard]] auto get_config_actual() const -> const StageConfig*;
|
||||||
[[nodiscard]] float get_timer_transicio() const { return timer_transicio_; }
|
[[nodiscard]] auto get_timer_transicio() const -> float { return timer_transicio_; }
|
||||||
[[nodiscard]] const std::string& get_missatge_level_start() const { return missatge_level_start_actual_; }
|
[[nodiscard]] auto get_missatge_level_start() const -> const std::string& { return missatge_level_start_actual_; }
|
||||||
|
|
||||||
// Spawn control (delegate to SpawnController)
|
// Spawn control (delegate to SpawnController)
|
||||||
SpawnController& getSpawnController() { return spawn_controller_; }
|
auto getSpawnController() -> SpawnController& { return spawn_controller_; }
|
||||||
[[nodiscard]] const SpawnController& getSpawnController() const { return spawn_controller_; }
|
[[nodiscard]] auto getSpawnController() const -> const SpawnController& { return spawn_controller_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const StageSystemConfig* config_; // Non-owning pointer
|
const StageSystemConfig* config_; // Non-owning pointer
|
||||||
SpawnController spawn_controller_;
|
SpawnController spawn_controller_;
|
||||||
|
|
||||||
EstatStage estat_;
|
EstatStage estat_{EstatStage::LEVEL_START};
|
||||||
uint8_t stage_actual_; // 1-10
|
uint8_t stage_actual_{1}; // 1-10
|
||||||
float timer_transicio_; // Timer for LEVEL_START/LEVEL_COMPLETED (3.0s → 0.0s)
|
float timer_transicio_{0.0F}; // Timer for LEVEL_START/LEVEL_COMPLETED (3.0s → 0.0s)
|
||||||
std::string missatge_level_start_actual_; // Missatge seleccionat per al level actual
|
std::string missatge_level_start_actual_; // Missatge seleccionat per al level actual
|
||||||
|
|
||||||
// State transitions
|
// State transitions
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ void ShipAnimator::skip_to_floating_state() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShipAnimator::is_visible() const {
|
auto ShipAnimator::is_visible() const -> bool {
|
||||||
// Retorna true si almenys una ship es visible
|
// Retorna true si almenys una ship es visible
|
||||||
for (const auto& ship : ships_) {
|
for (const auto& ship : ships_) {
|
||||||
if (ship.visible) {
|
if (ship.visible) {
|
||||||
@@ -156,7 +156,7 @@ void ShipAnimator::set_visible(bool visible) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShipAnimator::is_animation_complete() const {
|
auto ShipAnimator::is_animation_complete() const -> bool {
|
||||||
// Comprovar si todas las naves són invisibles (han completat l'animación de salida)
|
// Comprovar si todas las naves són invisibles (han completat l'animación de salida)
|
||||||
for (const auto& ship : ships_) {
|
for (const auto& ship : ships_) {
|
||||||
if (ship.visible) {
|
if (ship.visible) {
|
||||||
@@ -320,7 +320,7 @@ void ShipAnimator::configurar_nau_p2(TitleShip& ship) {
|
|||||||
ship.visible = true;
|
ship.visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2 ShipAnimator::calcular_posicio_fora_pantalla(float angle_rellotge) const {
|
auto ShipAnimator::calcular_posicio_fora_pantalla(float angle_rellotge) const -> Vec2 {
|
||||||
using namespace Defaults::Title::Ships;
|
using namespace Defaults::Title::Ships;
|
||||||
|
|
||||||
// Convertir angle del rellotge a radians (per exemple: 240° per clock 8)
|
// Convertir angle del rellotge a radians (per exemple: 240° per clock 8)
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ class ShipAnimator {
|
|||||||
|
|
||||||
// Control de visibilitat
|
// Control de visibilitat
|
||||||
void set_visible(bool visible);
|
void set_visible(bool visible);
|
||||||
[[nodiscard]] bool is_animation_complete() const;
|
[[nodiscard]] auto is_animation_complete() const -> bool;
|
||||||
[[nodiscard]] bool is_visible() const; // Comprova si alguna ship es visible
|
[[nodiscard]] auto is_visible() const -> bool; // Comprova si alguna ship es visible
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Rendering::Renderer* renderer_;
|
Rendering::Renderer* renderer_;
|
||||||
@@ -96,7 +96,7 @@ class ShipAnimator {
|
|||||||
// Configuración
|
// Configuración
|
||||||
void configurar_nau_p1(TitleShip& ship);
|
void configurar_nau_p1(TitleShip& ship);
|
||||||
void configurar_nau_p2(TitleShip& ship);
|
void configurar_nau_p2(TitleShip& ship);
|
||||||
[[nodiscard]] Vec2 calcular_posicio_fora_pantalla(float angle_rellotge) const;
|
[[nodiscard]] auto calcular_posicio_fora_pantalla(float angle_rellotge) const -> Vec2;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Title
|
} // namespace Title
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include "core/system/director.hpp"
|
#include "core/system/director.hpp"
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
auto main(int argc, char* argv[]) -> int {
|
||||||
// Convertir arguments a std::vector<std::string>
|
// Convertir arguments a std::vector<std::string>
|
||||||
std::vector<std::string> args(argv, argv + argc);
|
std::vector<std::string> args(argv, argv + argc);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user