revisió de capçaleres
This commit is contained in:
102
source/tabe.h
102
source/tabe.h
@@ -7,6 +7,7 @@
|
||||
#include <memory> // Para unique_ptr
|
||||
#include "animated_sprite.h" // Para AnimatedSprite
|
||||
|
||||
// --- Enumeraciones para dirección y estado ---
|
||||
enum class TabeDirection : int
|
||||
{
|
||||
TO_THE_LEFT = 0,
|
||||
@@ -19,6 +20,7 @@ enum class TabeState : int
|
||||
HIT = 1,
|
||||
};
|
||||
|
||||
// --- Estructura para el temporizador del Tabe ---
|
||||
struct TabeTimer
|
||||
{
|
||||
Uint32 time_until_next_spawn; // Tiempo restante para la próxima aparición
|
||||
@@ -68,76 +70,54 @@ struct TabeTimer
|
||||
}
|
||||
};
|
||||
|
||||
// Clase Tabe
|
||||
// --- Clase Tabe ---
|
||||
class Tabe
|
||||
{
|
||||
public:
|
||||
// --- Constructores y destructor ---
|
||||
Tabe();
|
||||
~Tabe() = default;
|
||||
|
||||
// --- Métodos principales ---
|
||||
void update(); // Actualiza la lógica
|
||||
void render(); // Dibuja el objeto
|
||||
void enable(); // Habilita el objeto
|
||||
void setState(TabeState state); // Establece el estado
|
||||
bool tryToGetBonus(); // Intenta obtener el bonus
|
||||
|
||||
// --- Getters ---
|
||||
SDL_FRect &getCollider() { return sprite_->getRect(); } // Obtiene el área de colisión
|
||||
bool isEnabled() const { return enabled_; } // Indica si el objeto está activo
|
||||
|
||||
private:
|
||||
// Constantes
|
||||
// --- Constantes ---
|
||||
static constexpr int WIDTH_ = 32;
|
||||
static constexpr int HEIGHT_ = 32;
|
||||
|
||||
// Punteros
|
||||
std::unique_ptr<AnimatedSprite> sprite_; // Sprite con los graficos y animaciones
|
||||
// --- Objetos y punteros ---
|
||||
std::unique_ptr<AnimatedSprite> sprite_; // Sprite con los gráficos y animaciones
|
||||
|
||||
// Variables
|
||||
float x_ = 0; // Posición del objeto
|
||||
float y_ = 0; // Posición del objeto
|
||||
float speed_ = 0.0f; // Velocidad de movimiento del objeto
|
||||
float accel_ = 0.0f; // Aceleración del objeto
|
||||
// --- Variables de estado ---
|
||||
float x_ = 0; // Posición X
|
||||
float y_ = 0; // Posición Y
|
||||
float speed_ = 0.0f; // Velocidad de movimiento
|
||||
float accel_ = 0.0f; // Aceleración
|
||||
int fly_distance_ = 0; // Distancia de vuelo
|
||||
int waiting_counter_ = 0; // Tiempo que pasa quieto el objeto
|
||||
int waiting_counter_ = 0; // Tiempo que pasa quieto
|
||||
bool enabled_ = false; // Indica si el objeto está activo
|
||||
TabeDirection direction_ = TabeDirection::TO_THE_LEFT; // Dirección del objeto
|
||||
TabeDirection destiny_ = TabeDirection::TO_THE_LEFT; // Destino del objeto
|
||||
TabeState state_ = TabeState::FLY; // Estado
|
||||
TabeDirection direction_ = TabeDirection::TO_THE_LEFT; // Dirección actual
|
||||
TabeDirection destiny_ = TabeDirection::TO_THE_LEFT; // Destino
|
||||
TabeState state_ = TabeState::FLY; // Estado actual
|
||||
int hit_counter_ = 0; // Contador para el estado HIT
|
||||
int number_of_hits_ = 0; // Cantidad de disparos que ha recibido
|
||||
bool has_bonus_ = true; // Indica si el Tabe aun tiene el bonus para soltar
|
||||
TabeTimer timer_; // Temporizador para gestionar la aparición del Tabe
|
||||
int number_of_hits_ = 0; // Cantidad de disparos recibidos
|
||||
bool has_bonus_ = true; // Indica si aún tiene el bonus para soltar
|
||||
TabeTimer timer_; // Temporizador para gestionar la aparición
|
||||
|
||||
// Mueve el objeto
|
||||
void move();
|
||||
|
||||
// Actualiza la posición del sprite
|
||||
void shiftSprite() { sprite_->setPos(x_, y_); }
|
||||
|
||||
// Establece un vuelo aleatorio
|
||||
void setRandomFlyPath(TabeDirection direction, int lenght);
|
||||
|
||||
// Actualiza el estado
|
||||
void updateState();
|
||||
|
||||
// Actualiza el temporizador
|
||||
void updateTimer();
|
||||
|
||||
// Deshabilita el objeto
|
||||
void disable();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Tabe();
|
||||
|
||||
// Destructor
|
||||
~Tabe() = default;
|
||||
|
||||
// Actualiza la lógica
|
||||
void update();
|
||||
|
||||
// Dibuja el objeto
|
||||
void render();
|
||||
|
||||
// Habilita el objeto
|
||||
void enable();
|
||||
|
||||
// Establece el estado
|
||||
void setState(TabeState state);
|
||||
|
||||
// Intenta obtener el bonus
|
||||
bool tryToGetBonus();
|
||||
|
||||
// Obtiene el area de colisión
|
||||
SDL_FRect &getCollider() { return sprite_->getRect(); }
|
||||
|
||||
// Getters
|
||||
bool isEnabled() const { return enabled_; }
|
||||
// --- Métodos internos ---
|
||||
void move(); // Mueve el objeto
|
||||
void shiftSprite() { sprite_->setPos(x_, y_); } // Actualiza la posición del sprite
|
||||
void setRandomFlyPath(TabeDirection direction, int lenght); // Establece un vuelo aleatorio
|
||||
void updateState(); // Actualiza el estado
|
||||
void updateTimer(); // Actualiza el temporizador
|
||||
void disable(); // Deshabilita el objeto
|
||||
};
|
||||
Reference in New Issue
Block a user