This commit is contained in:
2025-11-19 20:21:45 +01:00
parent cbe71b5af4
commit 35ef99cf7c
25 changed files with 397 additions and 462 deletions

View File

@@ -61,13 +61,13 @@ class Player {
static constexpr size_t LAST_SOUND = 17; // Último sonido a reproducir (índice 17)
static constexpr float SECONDS_PER_SOUND = JUMP_DURATION / (LAST_SOUND - FIRST_SOUND + 1);
size_t current_index_ = 0; // Índice del sonido actual
float elapsed_time_ = 0.0F; // Tiempo transcurrido durante el salto
bool active_ = false; // Indica si el controlador está activo
size_t current_index = 0; // Índice del sonido actual
float elapsed_time = 0.0F; // Tiempo transcurrido durante el salto
bool active = false; // Indica si el controlador está activo
void start(); // Inicia el controlador
void reset(); // Resetea el controlador
bool shouldPlay(float delta_time, size_t& out_index); // Comprueba si debe reproducir un sonido
auto shouldPlay(float delta_time, size_t& out_index) -> bool; // Comprueba si debe reproducir un sonido
};
struct FallSoundController {
@@ -75,14 +75,14 @@ class Player {
static constexpr size_t FIRST_SOUND = 1; // Primer sonido a reproducir (índice 1)
static constexpr size_t LAST_SOUND = 13; // Último sonido a reproducir (índice 13)
size_t current_index_ = 0; // Índice del sonido actual
float distance_traveled_ = 0.0F; // Distancia acumulada durante la caída
float last_y_ = 0.0F; // Última posición Y registrada
bool active_ = false; // Indica si el controlador está activo
size_t current_index = 0; // Índice del sonido actual
float distance_traveled = 0.0F; // Distancia acumulada durante la caída
float last_y = 0.0F; // Última posición Y registrada
bool active = false; // Indica si el controlador está activo
void start(float start_y); // Inicia el controlador
void reset(); // Resetea el controlador
bool shouldPlay(float delta_time, float current_y, size_t& out_index); // Comprueba si debe reproducir un sonido
auto shouldPlay(float delta_time, float current_y, size_t& out_index) -> bool; // Comprueba si debe reproducir un sonido
};
// --- Constructor y Destructor ---
@@ -97,7 +97,7 @@ class Player {
void switchBorders(); // Cambia al jugador de un borde al opuesto. Util para el cambio de pantalla
auto getRect() -> SDL_FRect { return {x_, y_, WIDTH, HEIGHT}; } // Obtiene el rectangulo que delimita al jugador
auto getCollider() -> SDL_FRect& { return collider_box_; } // Obtiene el rectangulo de colision del jugador
auto getSpawnParams() -> SpawnData { return {x_, y_, vx_, vy_, last_grounded_position_, state_, sprite_->getFlip()}; } // Obtiene el estado de reaparición del jugador
auto getSpawnParams() -> SpawnData { return {.x = x_, .y = y_, .vx = vx_, .vy = vy_, .last_grounded_position = last_grounded_position_, .state = state_, .flip = sprite_->getFlip()}; } // Obtiene el estado de reaparición del jugador
void setColor(); // Establece el color del jugador
void setRoom(std::shared_ptr<Room> room) { room_ = std::move(room); } // Establece la habitación en la que se encuentra el jugador
[[nodiscard]] auto isAlive() const -> bool { return is_alive_; } // Comprueba si el jugador esta vivo
@@ -120,8 +120,8 @@ class Player {
float vx_ = 0.0F; // Velocidad/desplazamiento del jugador en el eje X
float vy_ = 0.0F; // Velocidad/desplazamiento del jugador en el eje Y
Direction wannaGo = Direction::NONE;
bool wannaJump = false;
Direction wanna_go_ = Direction::NONE;
bool wanna_jump_ = false;
// --- Variables de estado ---
State state_ = State::ON_GROUND; // Estado en el que se encuentra el jugador. Util apara saber si está saltando o cayendo