Fase 1b: rename d'entitats i metodes virtuals a CamelCase/camelBack

Tots els tipus d'entitat passen del catala a l'angles seguint el
.clang-tidy del projecte (tipus en CamelCase, metodes en camelBack,
membres en lower_case amb sufix _).

Renames de tipus:
- Entitat -> Entity (core/entities/entity.hpp)
- Nau -> Ship (game/entities/ship.{hpp,cpp})
- Enemic -> Enemy (game/entities/enemy.{hpp,cpp})
- Bala -> Bullet (game/entities/bullet.{hpp,cpp})
- TipusEnemic -> EnemyType
- AnimacioEnemic -> EnemyAnimation

Metodes virtuals (s'aplica a tot el codi, no nomes a entitats):
- actualitzar -> update
- dibuixar -> draw
- inicialitzar -> init
- processar_input -> processInput
- esta_actiu -> isActive
- es_collidable -> isCollidable
- get_collision_radius -> getCollisionRadius

Getters comuns:
- get_centre -> getCenter
- get_angle -> getAngle
- get_brightness -> getBrightness
- get_forma -> getShape

Metodes especifics:
- esta_viva -> isAlive
- esta_tocada -> isHit
- es_invulnerable -> isInvulnerable
- get_velocitat_vector -> getVelocityVector
- set_centre -> setCenter
- marcar_tocada -> markHit
- aplicar_fisica -> applyPhysics
- get_tipus -> getType

Camps privats:
- centre_ -> center_
- velocitat_ -> velocity_
- forma_ -> shape_
- esta_tocada_ -> is_hit_
- tipus_ -> type_

L'import d'audio/input d'AEEA quedara coherent (mateix estil).
Diff net: 30 fitxers, +437/-437 (la majoria es renames simetrics).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-19 11:37:18 +02:00
parent cd38101f99
commit ae5cc1cfb4
32 changed files with 505 additions and 505 deletions
-49
View File
@@ -1,49 +0,0 @@
// entitat.hpp - Classe base abstracta per a totes les entitats del joc
// © 2025 Orni Attack - Arquitectura d'entitats
#pragma once
#include <SDL3/SDL.h>
#include <memory>
#include "core/graphics/shape.hpp"
#include "core/types.hpp"
namespace Entities {
class Entitat {
public:
virtual ~Entitat() = default;
// Interfície principal (virtual pur)
virtual void inicialitzar() = 0;
virtual void actualitzar(float delta_time) = 0;
virtual void dibuixar() const = 0;
[[nodiscard]] virtual bool esta_actiu() const = 0;
// Interfície de col·lisió (override opcional)
[[nodiscard]] virtual float get_collision_radius() const { return 0.0F; }
[[nodiscard]] virtual bool es_collidable() const { return false; }
// Getters comuns (inline, sense overhead)
[[nodiscard]] const Vec2& get_centre() const { return centre_; }
[[nodiscard]] float get_angle() const { return angle_; }
[[nodiscard]] float get_brightness() const { return brightness_; }
[[nodiscard]] const std::shared_ptr<Graphics::Shape>& get_forma() const { return forma_; }
protected:
// Estat comú (accés directe, sense overhead)
SDL_Renderer* renderer_;
std::shared_ptr<Graphics::Shape> forma_;
Vec2 centre_;
float angle_{0.0F};
float brightness_{1.0F};
// Constructor protegit (classe abstracta)
Entitat(SDL_Renderer* renderer = nullptr)
: renderer_(renderer),
centre_({.x = 0.0F, .y = 0.0F}) {}
};
} // namespace Entities
+49
View File
@@ -0,0 +1,49 @@
// entitat.hpp - Classe base abstracta per a totes les entitats del joc
// © 2025 Orni Attack - Arquitectura d'entitats
#pragma once
#include <SDL3/SDL.h>
#include <memory>
#include "core/graphics/shape.hpp"
#include "core/types.hpp"
namespace Entities {
class Entity {
public:
virtual ~Entity() = default;
// Interfície principal (virtual pur)
virtual void init() = 0;
virtual void update(float delta_time) = 0;
virtual void draw() const = 0;
[[nodiscard]] virtual bool isActive() const = 0;
// Interfície de col·lisió (override opcional)
[[nodiscard]] virtual float getCollisionRadius() const { return 0.0F; }
[[nodiscard]] virtual bool isCollidable() const { return false; }
// Getters comuns (inline, sense overhead)
[[nodiscard]] const Vec2& getCenter() const { return center_; }
[[nodiscard]] float getAngle() const { return angle_; }
[[nodiscard]] float getBrightness() const { return brightness_; }
[[nodiscard]] const std::shared_ptr<Graphics::Shape>& getShape() const { return shape_; }
protected:
// Estat comú (accés directe, sense overhead)
SDL_Renderer* renderer_;
std::shared_ptr<Graphics::Shape> shape_;
Vec2 center_;
float angle_{0.0F};
float brightness_{1.0F};
// Constructor protegit (classe abstracta)
Entity(SDL_Renderer* renderer = nullptr)
: renderer_(renderer),
center_({.x = 0.0F, .y = 0.0F}) {}
};
} // namespace Entities
+4 -4
View File
@@ -11,7 +11,7 @@
namespace Graphics {
Shape::Shape(const std::string& filepath)
: centre_({.x = 0.0F, .y = 0.0F}),
: center_({.x = 0.0F, .y = 0.0F}),
escala_defecte_(1.0F),
nom_("unnamed") {
carregar(filepath);
@@ -124,11 +124,11 @@ void Shape::parse_center(const std::string& value) {
size_t comma = val.find(',');
if (comma != std::string::npos) {
try {
centre_.x = std::stof(trim(val.substr(0, comma)));
centre_.y = std::stof(trim(val.substr(comma + 1)));
center_.x = std::stof(trim(val.substr(0, comma)));
center_.y = std::stof(trim(val.substr(comma + 1)));
} catch (...) {
std::cerr << "[Shape] Warning: centre invàlid, usant (0,0)" << '\n';
centre_ = {.x = 0.0F, .y = 0.0F};
center_ = {.x = 0.0F, .y = 0.0F};
}
}
}
+2 -2
View File
@@ -39,7 +39,7 @@ class Shape {
[[nodiscard]] const std::vector<ShapePrimitive>& get_primitives() const {
return primitives_;
}
[[nodiscard]] const Vec2& get_centre() const { return centre_; }
[[nodiscard]] const Vec2& getCenter() const { return center_; }
[[nodiscard]] float get_escala_defecte() const { return escala_defecte_; }
[[nodiscard]] bool es_valida() const { return !primitives_.empty(); }
@@ -49,7 +49,7 @@ class Shape {
private:
std::vector<ShapePrimitive> primitives_;
Vec2 centre_; // Centre/origen de la forma
Vec2 center_; // Centre/origen de la forma
float escala_defecte_; // Escala per defecte (normalment 1.0)
std::string nom_; // Nom de la forma (per depuració)
+2 -2
View File
@@ -113,7 +113,7 @@ float Starfield::calcular_brightness(const Estrella& estrella) const {
}
// Actualitzar posicions de les estrelles
void Starfield::actualitzar(float delta_time) {
void Starfield::update(float delta_time) {
for (auto& estrella : estrelles_) {
// Obtenir configuració de la capa
const CapaConfig& capa = capes_[estrella.capa];
@@ -145,7 +145,7 @@ void Starfield::set_brightness(float multiplier) {
}
// Dibuixar totes les estrelles
void Starfield::dibuixar() {
void Starfield::draw() {
if (!shape_estrella_->es_valida()) {
return;
}
+2 -2
View File
@@ -35,10 +35,10 @@ class Starfield {
int densitat = 150);
// Actualitzar posicions de les estrelles
void actualitzar(float delta_time);
void update(float delta_time);
// Dibuixar totes les estrelles
void dibuixar();
void draw();
// Setters per ajustar paràmetres en temps real
void set_punt_fuga(const Vec2& punt) { punt_fuga_ = punt; }
+6 -6
View File
@@ -3,25 +3,25 @@
#pragma once
#include "core/entities/entitat.hpp"
#include "core/entities/entity.hpp"
#include "core/types.hpp"
namespace Physics {
// Comprovació genèrica de col·lisió entre dues entitats
inline bool check_collision(const Entities::Entitat& a, const Entities::Entitat& b, float amplifier = 1.0F) {
inline bool check_collision(const Entities::Entity& a, const Entities::Entity& b, float amplifier = 1.0F) {
// Comprovar si ambdós són col·lisionables
if (!a.es_collidable() || !b.es_collidable()) {
if (!a.isCollidable() || !b.isCollidable()) {
return false;
}
// Calcular radi combinat (amb amplificador per hitbox generós)
float suma_radis = (a.get_collision_radius() + b.get_collision_radius()) * amplifier;
float suma_radis = (a.getCollisionRadius() + b.getCollisionRadius()) * amplifier;
float suma_radis_sq = suma_radis * suma_radis;
// Comprovació distància al quadrat (sense sqrt)
const Vec2& pos_a = a.get_centre();
const Vec2& pos_b = b.get_centre();
const Vec2& pos_a = a.getCenter();
const Vec2& pos_b = b.getCenter();
float dx = pos_a.x - pos_b.x;
float dy = pos_a.y - pos_b.y;
float dist_sq = (dx * dx) + (dy * dy);
+2 -2
View File
@@ -85,13 +85,13 @@ void render_shape(SDL_Renderer* renderer,
return;
}
// Si progress < 1.0, no dibuixar (tot o res)
// Si progress < 1.0, no draw (tot o res)
if (progress < 1.0F) {
return;
}
// Obtenir el centre de la forma per a transformacions
const Vec2& shape_centre = shape->get_centre();
const Vec2& shape_centre = shape->getCenter();
// Iterar sobre totes les primitives
for (const auto& primitive : shape->get_primitives()) {
+1 -1
View File
@@ -34,7 +34,7 @@ struct Rotation3D {
// Renderitzar forma amb transformacions
// - renderer: SDL renderer
// - shape: forma vectorial a dibuixar
// - shape: forma vectorial a draw
// - posicio: posició del centre en coordenades mundials
// - angle: rotació en radians (0 = amunt, sentit horari)
// - escala: factor d'escala (1.0 = mida original)