ae5cc1cfb4
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>
65 lines
2.2 KiB
C++
65 lines
2.2 KiB
C++
// shape.hpp - Sistema de formes vectorials
|
|
// © 2025 Port a C++20 amb SDL3
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "core/types.hpp"
|
|
|
|
namespace Graphics {
|
|
|
|
// Tipus de primitiva dins d'una forma
|
|
enum class PrimitiveType {
|
|
POLYLINE, // Seqüència de punts connectats
|
|
LINE // Línia individual (2 punts)
|
|
};
|
|
|
|
// Primitiva individual (polyline o line)
|
|
struct ShapePrimitive {
|
|
PrimitiveType type;
|
|
std::vector<Vec2> points; // 2+ punts per polyline, exactament 2 per line
|
|
};
|
|
|
|
// Classe Shape - representa una forma vectorial carregada des de .shp
|
|
class Shape {
|
|
public:
|
|
// Constructors
|
|
Shape() = default;
|
|
explicit Shape(const std::string& filepath);
|
|
|
|
// Carregar forma des de fitxer .shp
|
|
bool carregar(const std::string& filepath);
|
|
|
|
// Parsejar forma des de buffer de memòria (per al sistema de recursos)
|
|
bool parsejar_fitxer(const std::string& contingut);
|
|
|
|
// Getters
|
|
[[nodiscard]] const std::vector<ShapePrimitive>& get_primitives() const {
|
|
return primitives_;
|
|
}
|
|
[[nodiscard]] const Vec2& getCenter() const { return center_; }
|
|
[[nodiscard]] float get_escala_defecte() const { return escala_defecte_; }
|
|
[[nodiscard]] bool es_valida() const { return !primitives_.empty(); }
|
|
|
|
// Info de depuració
|
|
[[nodiscard]] std::string get_nom() const { return nom_; }
|
|
[[nodiscard]] size_t get_num_primitives() const { return primitives_.size(); }
|
|
|
|
private:
|
|
std::vector<ShapePrimitive> primitives_;
|
|
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ó)
|
|
|
|
// Helpers privats per parsejar
|
|
[[nodiscard]] std::string trim(const std::string& str) const;
|
|
[[nodiscard]] bool starts_with(const std::string& str, const std::string& prefix) const;
|
|
[[nodiscard]] std::string extract_value(const std::string& line) const;
|
|
void parse_center(const std::string& value);
|
|
[[nodiscard]] std::vector<Vec2> parse_points(const std::string& str) const;
|
|
};
|
|
|
|
} // namespace Graphics
|