50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
// entitat.hpp - Classe base abstracta per a totes les entitats del joc
|
|
// © 2025 Orni Attack - Arquitectura d'entitats
|
|
|
|
#pragma once
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include <memory>
|
|
|
|
#include "core/graphics/shape.hpp"
|
|
#include "core/types.hpp"
|
|
|
|
namespace Entities {
|
|
|
|
class Entitat {
|
|
public:
|
|
virtual ~Entitat() = default;
|
|
|
|
// Interfície principal (virtual pur)
|
|
virtual void inicialitzar() = 0;
|
|
virtual void actualitzar(float delta_time) = 0;
|
|
virtual void dibuixar() const = 0;
|
|
[[nodiscard]] virtual bool esta_actiu() const = 0;
|
|
|
|
// Interfície de col·lisió (override opcional)
|
|
[[nodiscard]] virtual float get_collision_radius() const { return 0.0F; }
|
|
[[nodiscard]] virtual bool es_collidable() const { return false; }
|
|
|
|
// Getters comuns (inline, sense overhead)
|
|
[[nodiscard]] const Punt& get_centre() const { return centre_; }
|
|
[[nodiscard]] float get_angle() const { return angle_; }
|
|
[[nodiscard]] float get_brightness() const { return brightness_; }
|
|
[[nodiscard]] const std::shared_ptr<Graphics::Shape>& get_forma() const { return forma_; }
|
|
|
|
protected:
|
|
// Estat comú (accés directe, sense overhead)
|
|
SDL_Renderer* renderer_;
|
|
std::shared_ptr<Graphics::Shape> forma_;
|
|
Punt centre_;
|
|
float angle_{0.0F};
|
|
float brightness_{1.0F};
|
|
|
|
// Constructor protegit (classe abstracta)
|
|
Entitat(SDL_Renderer* renderer = nullptr)
|
|
: renderer_(renderer),
|
|
centre_({.x = 0.0F, .y = 0.0F}) {}
|
|
};
|
|
|
|
} // namespace Entities
|