48 lines
1.4 KiB
C++
48 lines
1.4 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 <memory>
|
|
|
|
#include "core/graphics/shape.hpp"
|
|
#include "core/types.hpp"
|
|
|
|
class Bala {
|
|
public:
|
|
Bala()
|
|
: renderer_(nullptr) {}
|
|
Bala(SDL_Renderer* renderer);
|
|
|
|
void inicialitzar();
|
|
void disparar(const Punt& posicio, float angle, uint8_t owner_id);
|
|
void actualitzar(float delta_time);
|
|
void dibuixar() const;
|
|
|
|
// Getters (API pública sense canvis)
|
|
bool esta_activa() const { return esta_; }
|
|
const Punt& get_centre() const { return centre_; }
|
|
uint8_t get_owner_id() const { return owner_id_; }
|
|
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_;
|
|
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);
|
|
};
|