feat: implementar jerarquia d'entitats amb classe base Entitat
This commit is contained in:
@@ -6,43 +6,45 @@
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include "core/graphics/shape.hpp"
|
||||
#include "core/defaults.hpp"
|
||||
#include "core/entities/entitat.hpp"
|
||||
#include "core/types.hpp"
|
||||
|
||||
class Bala {
|
||||
class Bala : public Entities::Entitat {
|
||||
public:
|
||||
Bala()
|
||||
: renderer_(nullptr) {}
|
||||
: Entitat(nullptr) {}
|
||||
Bala(SDL_Renderer* renderer);
|
||||
|
||||
void inicialitzar();
|
||||
void inicialitzar() override;
|
||||
void disparar(const Punt& posicio, float angle, uint8_t owner_id);
|
||||
void actualitzar(float delta_time);
|
||||
void dibuixar() const;
|
||||
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]] const Punt& get_centre() const { return centre_; }
|
||||
[[nodiscard]] uint8_t get_owner_id() const { return owner_id_; }
|
||||
[[nodiscard]] float get_grace_timer() const { return grace_timer_; }
|
||||
void desactivar() { esta_ = false; }
|
||||
|
||||
private:
|
||||
SDL_Renderer* renderer_;
|
||||
|
||||
// [NUEVO] Forma vectorial (compartida entre totes les bales)
|
||||
std::shared_ptr<Graphics::Shape> forma_;
|
||||
|
||||
// [NUEVO] Estat de la instància (separat de la geometria)
|
||||
Punt centre_;
|
||||
float angle_;
|
||||
// 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)
|
||||
float brightness_; // Factor de brillantor (0.0-1.0)
|
||||
|
||||
void mou(float delta_time);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user