cd38101f99
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>
51 lines
1.6 KiB
C++
51 lines
1.6 KiB
C++
// bala.hpp - Classe per a projectils de la nau
|
|
// © 1999 Visente i Sergi (versió Pascal)
|
|
// © 2025 Port a C++20 amb SDL3
|
|
|
|
#pragma once
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include <cstdint>
|
|
|
|
#include "core/defaults.hpp"
|
|
#include "core/entities/entitat.hpp"
|
|
#include "core/types.hpp"
|
|
|
|
class Bala : public Entities::Entitat {
|
|
public:
|
|
Bala()
|
|
: Entitat(nullptr) {}
|
|
Bala(SDL_Renderer* renderer);
|
|
|
|
void inicialitzar() override;
|
|
void disparar(const Vec2& posicio, float angle, uint8_t owner_id);
|
|
void actualitzar(float delta_time) override;
|
|
void dibuixar() const override;
|
|
|
|
// Override: Interfície d'Entitat
|
|
[[nodiscard]] bool esta_actiu() const override { return esta_; }
|
|
|
|
// Override: Interfície de col·lisió
|
|
[[nodiscard]] float get_collision_radius() const override {
|
|
return Defaults::Entities::BULLET_RADIUS;
|
|
}
|
|
[[nodiscard]] bool es_collidable() const override {
|
|
return esta_ && grace_timer_ <= 0.0F;
|
|
}
|
|
|
|
// Getters (API pública sense canvis)
|
|
[[nodiscard]] bool esta_activa() const { return esta_; }
|
|
[[nodiscard]] uint8_t get_owner_id() const { return owner_id_; }
|
|
[[nodiscard]] float get_grace_timer() const { return grace_timer_; }
|
|
void desactivar() { esta_ = false; }
|
|
|
|
private:
|
|
// Membres específics de Bala (heretats: renderer_, forma_, centre_, angle_, brightness_)
|
|
float velocitat_;
|
|
bool esta_;
|
|
uint8_t owner_id_; // 0=P1, 1=P2
|
|
float grace_timer_; // Grace period timer (0.0 = vulnerable)
|
|
|
|
void mou(float delta_time);
|
|
};
|