Fase 1a: Punt -> Vec2 amb operadors moderns
Primera sub-fase del naming sweep. Punt era un struct sense
operacions, conservat per compatibilitat amb el Pascal original.
Substituit per Vec2, un aggregate amb operadors aritmetics, dot,
length, normalized i length_squared (camelBack: lengthSquared)
seguint les regles del .clang-tidy del projecte.
Canvis:
- core/types.hpp reescrit: nou struct Vec2 amb +=,-=,*=,/=,
unary -, ==, dot, length, lengthSquared, normalized
- Operadors fora de la classe: +, -, *, / (amb float per ambdues
bandes), - unari, ==
- Vec2 segueix sent aggregate (sense constructors definits):
els 'designated initializers' del codi existent funcionen igual:
Vec2{.x = ..., .y = ...}
- Sed global sobre 35 fitxers: tots els 'Punt' -> 'Vec2'
Net: 35 fitxers tocats, +180 / -114. Compila i enllaça.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -20,7 +20,7 @@ class Nau : public Entities::Entitat {
|
||||
Nau(SDL_Renderer* renderer, const char* shape_file = "ship.shp");
|
||||
|
||||
void inicialitzar() override { inicialitzar(nullptr, false); }
|
||||
void inicialitzar(const Punt* spawn_point, bool activar_invulnerabilitat = false);
|
||||
void inicialitzar(const Vec2* spawn_point, bool activar_invulnerabilitat = false);
|
||||
void processar_input(float delta_time, uint8_t player_id);
|
||||
void actualitzar(float delta_time) override;
|
||||
void dibuixar() const override;
|
||||
@@ -40,14 +40,14 @@ class Nau : public Entities::Entitat {
|
||||
[[nodiscard]] bool esta_viva() const { return !esta_tocada_; }
|
||||
[[nodiscard]] bool esta_tocada() const { return esta_tocada_; }
|
||||
[[nodiscard]] bool es_invulnerable() const { return invulnerable_timer_ > 0.0F; }
|
||||
[[nodiscard]] Punt get_velocitat_vector() const {
|
||||
[[nodiscard]] Vec2 get_velocitat_vector() const {
|
||||
return {
|
||||
.x = velocitat_ * std::cos(angle_ - (Constants::PI / 2.0F)),
|
||||
.y = velocitat_ * std::sin(angle_ - (Constants::PI / 2.0F))};
|
||||
}
|
||||
|
||||
// Setters
|
||||
void set_centre(const Punt& nou_centre) { centre_ = nou_centre; }
|
||||
void set_centre(const Vec2& nou_centre) { centre_ = nou_centre; }
|
||||
|
||||
// Col·lisions (Fase 10)
|
||||
void marcar_tocada() { esta_tocada_ = true; }
|
||||
|
||||
Reference in New Issue
Block a user