neteja tidy a source/game (fixes d'arrel: BulletKind enum class, signatures, branches)
This commit is contained in:
@@ -2,14 +2,19 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <cstdint> // for uint8_t
|
||||
#include "utils/utils.h" // for circle_t
|
||||
class Sprite;
|
||||
class Texture;
|
||||
|
||||
// Tipos de bala
|
||||
constexpr int BULLET_UP = 1;
|
||||
constexpr int BULLET_LEFT = 2;
|
||||
constexpr int BULLET_RIGHT = 3;
|
||||
// Tipus de bala. Enum class fortament tipat per evitar confusió accidental
|
||||
// amb altres `int`/`Uint8` (p.ex. el `owner` a `createBullet`).
|
||||
enum class BulletKind : std::uint8_t {
|
||||
NONE = 0, // bala desactivada / fora de pantalla
|
||||
UP = 1,
|
||||
LEFT = 2,
|
||||
RIGHT = 3,
|
||||
};
|
||||
|
||||
// Tipos de retorno de la función move de la bala
|
||||
constexpr int BULLET_MOVE_OK = 0;
|
||||
@@ -28,7 +33,7 @@ class Bullet {
|
||||
Uint8 height; // Alto del objeto
|
||||
int velX; // Velocidad en el eje X
|
||||
int velY; // Velocidad en el eje Y
|
||||
int kind; // Tipo de objeto
|
||||
BulletKind kind; // Tipo de objeto
|
||||
int owner; // Identificador del dueño del objeto
|
||||
circle_t collider; // Circulo de colisión del objeto
|
||||
|
||||
@@ -37,31 +42,31 @@ class Bullet {
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Bullet(int x, int y, int kind, bool poweredUp, int owner, Texture *texture, SDL_Renderer *renderer);
|
||||
Bullet(int x, int y, BulletKind kind, bool poweredUp, int owner, Texture *texture, SDL_Renderer *renderer);
|
||||
|
||||
// Destructor
|
||||
~Bullet();
|
||||
|
||||
Bullet(const Bullet &) = delete;
|
||||
Bullet &operator=(const Bullet &) = delete;
|
||||
auto operator=(const Bullet &) -> Bullet & = delete;
|
||||
|
||||
// Pinta el objeto en pantalla
|
||||
void render();
|
||||
|
||||
// Actualiza la posición y estado del objeto
|
||||
Uint8 move();
|
||||
auto move() -> Uint8;
|
||||
|
||||
// Comprueba si el objeto está habilitado
|
||||
bool isEnabled();
|
||||
[[nodiscard]] auto isEnabled() const -> bool;
|
||||
|
||||
// Deshabilita el objeto
|
||||
void disable();
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getPosX();
|
||||
[[nodiscard]] auto getPosX() const -> int;
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getPosY();
|
||||
[[nodiscard]] auto getPosY() const -> int;
|
||||
|
||||
// Establece el valor de la variable
|
||||
void setPosX(int x);
|
||||
@@ -70,14 +75,14 @@ class Bullet {
|
||||
void setPosY(int y);
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getVelY();
|
||||
[[nodiscard]] auto getVelY() const -> int;
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getKind();
|
||||
[[nodiscard]] auto getKind() const -> BulletKind;
|
||||
|
||||
// Obtiene el valor de la variable
|
||||
int getOwner();
|
||||
[[nodiscard]] auto getOwner() const -> int;
|
||||
|
||||
// Obtiene el circulo de colisión
|
||||
circle_t &getCollider();
|
||||
auto getCollider() -> circle_t &;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user