claude: arreglos d'estil
This commit is contained in:
@@ -9,65 +9,62 @@
|
||||
#include "player.h" // Para Player
|
||||
#include "utils.h" // Para Circle
|
||||
|
||||
// Tipos de balas
|
||||
// --- Enums ---
|
||||
enum class BulletType : Uint8 {
|
||||
UP,
|
||||
LEFT,
|
||||
RIGHT,
|
||||
NONE
|
||||
UP, // Bala hacia arriba
|
||||
LEFT, // Bala hacia la izquierda
|
||||
RIGHT, // Bala hacia la derecha
|
||||
NONE // Sin bala
|
||||
};
|
||||
|
||||
// Resultado del movimiento de la bala
|
||||
enum class BulletMoveStatus : Uint8 {
|
||||
OK = 0,
|
||||
OUT = 1
|
||||
OK = 0, // Movimiento normal
|
||||
OUT = 1 // Fuera de los límites
|
||||
};
|
||||
|
||||
// Clase Bullet
|
||||
// --- Clase Bullet: representa una bala del jugador ---
|
||||
class Bullet {
|
||||
public:
|
||||
// Constantes
|
||||
static constexpr float WIDTH = 12.0F;
|
||||
static constexpr float HEIGHT = 12.0F;
|
||||
// --- Constantes ---
|
||||
static constexpr float WIDTH = 12.0F; // Anchura de la bala
|
||||
static constexpr float HEIGHT = 12.0F; // Altura de la bala
|
||||
|
||||
// Constructor y Destructor
|
||||
Bullet(float x, float y, BulletType bullet_type, bool powered, Player::Id owner);
|
||||
~Bullet() = default;
|
||||
// --- Constructor y destructor ---
|
||||
Bullet(float x, float y, BulletType bullet_type, bool powered, Player::Id owner); // Constructor principal
|
||||
~Bullet() = default; // Destructor
|
||||
|
||||
// Métodos principales
|
||||
void render(); // Dibuja la bala en pantalla
|
||||
auto update() -> BulletMoveStatus; // Actualiza el estado del objeto
|
||||
// --- Métodos principales ---
|
||||
void render(); // Dibuja la bala en pantalla
|
||||
auto update() -> BulletMoveStatus; // Actualiza el estado del objeto
|
||||
void disable(); // Desactiva la bala
|
||||
|
||||
// Estado de la bala
|
||||
[[nodiscard]] auto isEnabled() const -> bool; // Comprueba si está activa
|
||||
void disable(); // Desactiva la bala
|
||||
|
||||
// Getters
|
||||
[[nodiscard]] auto getOwner() const -> Player::Id; // Devuelve el identificador del dueño
|
||||
auto getCollider() -> Circle &; // Devuelve el círculo de colisión
|
||||
// --- Getters ---
|
||||
[[nodiscard]] auto isEnabled() const -> bool; // Comprueba si está activa
|
||||
[[nodiscard]] auto getOwner() const -> Player::Id; // Devuelve el identificador del dueño
|
||||
auto getCollider() -> Circle &; // Devuelve el círculo de colisión
|
||||
|
||||
private:
|
||||
// Constantes
|
||||
static constexpr float VEL_Y = -3.0F;
|
||||
static constexpr float VEL_X_LEFT = -2.0F;
|
||||
static constexpr float VEL_X_RIGHT = 2.0F;
|
||||
static constexpr float VEL_X_CENTER = 0.0F;
|
||||
// --- Constantes ---
|
||||
static constexpr float VEL_Y = -3.0F; // Velocidad vertical
|
||||
static constexpr float VEL_X_LEFT = -2.0F; // Velocidad izquierda
|
||||
static constexpr float VEL_X_RIGHT = 2.0F; // Velocidad derecha
|
||||
static constexpr float VEL_X_CENTER = 0.0F; // Velocidad central
|
||||
|
||||
// Propiedades
|
||||
// --- Objetos y punteros ---
|
||||
std::unique_ptr<AnimatedSprite> sprite_; // Sprite con los gráficos
|
||||
|
||||
float pos_x_; // Posición en el eje X
|
||||
float pos_y_; // Posición en el eje Y
|
||||
float vel_x_; // Velocidad en el eje X
|
||||
|
||||
// --- Variables de estado ---
|
||||
Circle collider_; // Círculo de colisión
|
||||
BulletType bullet_type_; // Tipo de bala
|
||||
Player::Id owner_; // Identificador del dueño
|
||||
Circle collider_; // Círculo de colisión
|
||||
float pos_x_; // Posición en el eje X
|
||||
float pos_y_; // Posición en el eje Y
|
||||
float vel_x_; // Velocidad en el eje X
|
||||
|
||||
// Métodos internos
|
||||
// --- Métodos internos ---
|
||||
void shiftColliders(); // Ajusta el círculo de colisión
|
||||
void shiftSprite(); // Ajusta el sprite
|
||||
auto move() -> BulletMoveStatus; // Mueve la bala y devuelve su estado
|
||||
static auto calculateVelocity(BulletType bullet_type) -> float; // Calcula la velocidad horizontal de la bala basada en su tipo
|
||||
static auto buildAnimationString(BulletType bullet_type, bool powered) -> std::string; // Construye el string de animación basado en el tipo de bala y si está potenciada
|
||||
static auto calculateVelocity(BulletType bullet_type) -> float; // Calcula la velocidad horizontal de la bala
|
||||
static auto buildAnimationString(BulletType bullet_type, bool powered) -> std::string; // Construye el string de animación
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user