linter
This commit is contained in:
@@ -1,21 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL3/SDL.h> // Para Uint32, SDL_FRect, SDL_FlipMode
|
||||
#include <SDL3/SDL.h> // Para SDL_FRect, SDL_FlipMode
|
||||
|
||||
#include <memory> // Para shared_ptr, allocator, unique_ptr
|
||||
#include <string> // Para string
|
||||
#include <utility> // Para pair
|
||||
#include <vector> // Para vector
|
||||
#include <cstddef> // Para size_t
|
||||
#include <iterator> // Para pair
|
||||
#include <memory> // Para shared_ptr, unique_ptr
|
||||
#include <string> // Para basic_string, string
|
||||
#include <utility> // Para move, pair
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "animated_sprite.hpp" // Para AnimatedSprite
|
||||
#include "bullet.hpp" // Para Bullet
|
||||
#include "enter_name.hpp" // Para EnterName
|
||||
#include "input.hpp" // Para Input
|
||||
#include "manage_hiscore_table.hpp" // Para Table
|
||||
#include "scoreboard.hpp" // Para Scoreboard
|
||||
#include "stage_interface.hpp" // Para IStageInfo
|
||||
#include "utils.hpp" // Para Circle
|
||||
#include "animated_sprite.hpp" // for AnimatedSprite
|
||||
#include "bullet.hpp" // for Bullet
|
||||
#include "enter_name.hpp" // for EnterName
|
||||
#include "input.hpp" // for Input
|
||||
#include "manage_hiscore_table.hpp" // for Table
|
||||
#include "scoreboard.hpp" // for Scoreboard
|
||||
#include "utils.hpp" // for Circle
|
||||
|
||||
class IStageInfo;
|
||||
class Texture;
|
||||
|
||||
// --- Clase Player: jugador principal del juego ---
|
||||
@@ -115,9 +117,9 @@ class Player {
|
||||
~Player() = default;
|
||||
|
||||
// --- Inicialización y ciclo de vida ---
|
||||
void init(); // Inicializa el jugador
|
||||
void update(float deltaTime); // Actualiza estado, animación y contadores (time-based)
|
||||
void render(); // Dibuja el jugador en pantalla
|
||||
void init(); // Inicializa el jugador
|
||||
void update(float delta_time); // Actualiza estado, animación y contadores (time-based)
|
||||
void render(); // Dibuja el jugador en pantalla
|
||||
|
||||
// --- Entrada y control ---
|
||||
void setInput(Input::Action action); // Procesa entrada general
|
||||
@@ -125,8 +127,8 @@ class Player {
|
||||
void setInputEnteringName(Input::Action action); // Procesa entrada al introducir nombre
|
||||
|
||||
// --- Movimiento y animación ---
|
||||
void move(float deltaTime); // Mueve el jugador (time-based)
|
||||
void setAnimation(float deltaTime); // Establece la animación según el estado (time-based)
|
||||
void move(float delta_time); // Mueve el jugador (time-based)
|
||||
void setAnimation(float delta_time); // Establece la animación según el estado (time-based)
|
||||
|
||||
// --- Texturas y animaciones ---
|
||||
void setPlayerTextures(const std::vector<std::shared_ptr<Texture>>& texture); // Cambia las texturas del jugador
|
||||
@@ -140,7 +142,7 @@ class Player {
|
||||
void setPlayingState(State state); // Cambia el estado de juego
|
||||
void setInvulnerable(bool value); // Establece el valor del estado de invulnerabilidad
|
||||
void setPowerUp(); // Activa el modo PowerUp
|
||||
void updatePowerUp(float deltaTime); // Actualiza el valor de PowerUp
|
||||
void updatePowerUp(float delta_time); // Actualiza el valor de PowerUp
|
||||
void giveExtraHit(); // Concede un toque extra al jugador
|
||||
void removeExtraHit(); // Quita el toque extra al jugador
|
||||
void decContinueCounter(); // Decrementa el contador de continuar
|
||||
@@ -221,7 +223,7 @@ class Player {
|
||||
|
||||
private:
|
||||
// --- Constantes de física y movimiento ---
|
||||
static constexpr float BASE_SPEED = 90.0f; // Velocidad base del jugador (pixels/segundo)
|
||||
static constexpr float BASE_SPEED = 90.0F; // Velocidad base del jugador (pixels/segundo)
|
||||
|
||||
// --- Constantes de power-ups y estados especiales ---
|
||||
static constexpr int POWERUP_COUNTER = 1500; // Duración del estado PowerUp (frames)
|
||||
@@ -236,10 +238,10 @@ class Player {
|
||||
static constexpr int WAITING_COUNTER = 1000; // Tiempo de espera en estado de espera
|
||||
|
||||
// --- Constantes del nuevo sistema de disparo de dos líneas ---
|
||||
static constexpr float AIMING_DURATION_FACTOR = 0.5f; // 50% del cooldown funcional
|
||||
static constexpr float RECOILING_DURATION_MULTIPLIER = 4.0f; // 4 veces la duración de aiming
|
||||
static constexpr float THREAT_POSE_DURATION = 50.0f / 60.0f; // 50 frames = ~0.833s (duración base)
|
||||
static constexpr float MIN_THREAT_POSE_DURATION = 6.0f / 60.0f; // 6 frames = ~0.1s (duración mínima)
|
||||
static constexpr float AIMING_DURATION_FACTOR = 0.5F; // 50% del cooldown funcional
|
||||
static constexpr float RECOILING_DURATION_MULTIPLIER = 4.0F; // 4 veces la duración de aiming
|
||||
static constexpr float THREAT_POSE_DURATION = 50.0F / 60.0F; // 50 frames = ~0.833s (duración base)
|
||||
static constexpr float MIN_THREAT_POSE_DURATION = 6.0F / 60.0F; // 6 frames = ~0.1s (duración mínima)
|
||||
|
||||
// --- Objetos y punteros ---
|
||||
std::unique_ptr<AnimatedSprite> player_sprite_; // Sprite para dibujar el jugador
|
||||
@@ -251,17 +253,17 @@ class Player {
|
||||
IStageInfo* stage_info_; // Informacion de la pantalla actual
|
||||
|
||||
// --- Variables de estado ---
|
||||
SDL_FRect play_area_; // Rectángulo con la zona de juego
|
||||
Circle collider_ = Circle(0, 0, 9); // Círculo de colisión del jugador
|
||||
std::string name_; // Nombre del jugador
|
||||
std::string last_enter_name_; // Último nombre introducido en la tabla de puntuaciones
|
||||
Scoreboard::Id scoreboard_panel_ = Scoreboard::Id::LEFT; // Panel del marcador asociado al jugador
|
||||
Id id_; // Identificador para el jugador
|
||||
State walking_state_ = State::WALKING_STOP; // Estado del jugador al moverse
|
||||
State firing_state_ = State::FIRING_NONE; // Estado del jugador al disparar
|
||||
State playing_state_ = State::WAITING; // Estado del jugador en el juego
|
||||
BulletColorPair bullet_colors_ = {Bullet::Color::YELLOW, Bullet::Color::GREEN}; // Par de colores de balas para este jugador
|
||||
std::string bullet_sound_file_ = "bullet1p.wav"; // Archivo de sonido de bala para este jugador
|
||||
SDL_FRect play_area_; // Rectángulo con la zona de juego
|
||||
Circle collider_ = Circle(0, 0, 9); // Círculo de colisión del jugador
|
||||
std::string name_; // Nombre del jugador
|
||||
std::string last_enter_name_; // Último nombre introducido en la tabla de puntuaciones
|
||||
Scoreboard::Id scoreboard_panel_ = Scoreboard::Id::LEFT; // Panel del marcador asociado al jugador
|
||||
Id id_; // Identificador para el jugador
|
||||
State walking_state_ = State::WALKING_STOP; // Estado del jugador al moverse
|
||||
State firing_state_ = State::FIRING_NONE; // Estado del jugador al disparar
|
||||
State playing_state_ = State::WAITING; // Estado del jugador en el juego
|
||||
BulletColorPair bullet_colors_ = {.normal_color = Bullet::Color::YELLOW, .powered_color = Bullet::Color::GREEN}; // Par de colores de balas para este jugador
|
||||
std::string bullet_sound_file_ = "bullet1p.wav"; // Archivo de sonido de bala para este jugador
|
||||
|
||||
float pos_x_ = 0.0F; // Posición en el eje X
|
||||
float default_pos_x_; // Posición inicial para el jugador
|
||||
@@ -270,20 +272,20 @@ class Player {
|
||||
int pos_y_ = 0; // Posición en el eje Y
|
||||
int default_pos_y_; // Posición inicial para el jugador
|
||||
int vel_y_ = 0; // Cantidad de píxeles a desplazarse en el eje Y
|
||||
float invulnerable_time_accumulator_ = 0.0f; // Acumulador de tiempo para invulnerabilidad (time-based)
|
||||
float power_up_time_accumulator_ = 0.0f; // Acumulador de tiempo para power-up (time-based)
|
||||
float continue_time_accumulator_ = 0.0f; // Acumulador de tiempo para continue counter (time-based)
|
||||
float name_entry_time_accumulator_ = 0.0f; // Acumulador de tiempo para name entry counter (time-based)
|
||||
float showing_name_time_accumulator_ = 0.0f; // Acumulador de tiempo para showing name (time-based)
|
||||
float waiting_time_accumulator_ = 0.0f; // Acumulador de tiempo para waiting movement (time-based)
|
||||
float step_time_accumulator_ = 0.0f; // Acumulador de tiempo para step counter (time-based)
|
||||
float invulnerable_time_accumulator_ = 0.0F; // Acumulador de tiempo para invulnerabilidad (time-based)
|
||||
float power_up_time_accumulator_ = 0.0F; // Acumulador de tiempo para power-up (time-based)
|
||||
float continue_time_accumulator_ = 0.0F; // Acumulador de tiempo para continue counter (time-based)
|
||||
float name_entry_time_accumulator_ = 0.0F; // Acumulador de tiempo para name entry counter (time-based)
|
||||
float showing_name_time_accumulator_ = 0.0F; // Acumulador de tiempo para showing name (time-based)
|
||||
float waiting_time_accumulator_ = 0.0F; // Acumulador de tiempo para waiting movement (time-based)
|
||||
float step_time_accumulator_ = 0.0F; // Acumulador de tiempo para step counter (time-based)
|
||||
|
||||
// ========================================
|
||||
// NUEVO SISTEMA DE DISPARO DE DOS LÍNEAS
|
||||
// ========================================
|
||||
|
||||
// LÍNEA 1: SISTEMA FUNCIONAL (CanFire)
|
||||
float fire_cooldown_timer_ = 0.0f; // Tiempo restante hasta poder disparar otra vez
|
||||
float fire_cooldown_timer_ = 0.0F; // Tiempo restante hasta poder disparar otra vez
|
||||
bool can_fire_new_system_ = true; // true si puede disparar ahora mismo
|
||||
|
||||
// LÍNEA 2: SISTEMA VISUAL (Animaciones)
|
||||
@@ -295,9 +297,9 @@ class Player {
|
||||
};
|
||||
|
||||
VisualFireState visual_fire_state_ = VisualFireState::NORMAL;
|
||||
float visual_state_timer_ = 0.0f; // Tiempo en el estado visual actual
|
||||
float aiming_duration_ = 0.0f; // Duración del estado AIMING
|
||||
float recoiling_duration_ = 0.0f; // Duración del estado RECOILING
|
||||
float visual_state_timer_ = 0.0F; // Tiempo en el estado visual actual
|
||||
float aiming_duration_ = 0.0F; // Duración del estado AIMING
|
||||
float recoiling_duration_ = 0.0F; // Duración del estado RECOILING
|
||||
|
||||
int invulnerable_counter_ = INVULNERABLE_COUNTER; // Contador para la invulnerabilidad
|
||||
int score_ = 0; // Puntos del jugador
|
||||
@@ -307,8 +309,8 @@ class Player {
|
||||
int continue_counter_ = 10; // Contador para poder continuar
|
||||
int controller_index_ = 0; // Índice del array de mandos que utilizará para moverse
|
||||
size_t demo_file_ = 0; // Indice del fichero de datos para el modo demo
|
||||
float name_entry_idle_time_accumulator_ = 0.0f; // Tiempo idle acumulado para poner nombre (milisegundos)
|
||||
float name_entry_total_time_accumulator_ = 0.0f; // Tiempo total acumulado poniendo nombre (milisegundos)
|
||||
float name_entry_idle_time_accumulator_ = 0.0F; // Tiempo idle acumulado para poner nombre (milisegundos)
|
||||
float name_entry_total_time_accumulator_ = 0.0F; // Tiempo total acumulado poniendo nombre (milisegundos)
|
||||
int step_counter_ = 0; // Cuenta los pasos para los estados en los que camina automáticamente
|
||||
int credits_used_ = 0; // Indica el número de veces que ha continuado
|
||||
int waiting_counter_ = 0; // Contador para el estado de espera
|
||||
@@ -336,11 +338,11 @@ class Player {
|
||||
void setScoreMultiplier(float value) { score_multiplier_ = value; }
|
||||
|
||||
// --- Actualizadores de estado (time-based) ---
|
||||
void updateInvulnerable(float deltaTime); // Monitoriza el estado de invulnerabilidad
|
||||
void updateContinueCounter(float deltaTime); // Actualiza el contador de continue
|
||||
void updateEnterNameCounter(float deltaTime); // Actualiza el contador de entrar nombre
|
||||
void updateShowingName(float deltaTime); // Actualiza el estado SHOWING_NAME
|
||||
void decNameEntryCounter(); // Decrementa el contador de entrar nombre
|
||||
void updateInvulnerable(float delta_time); // Monitoriza el estado de invulnerabilidad
|
||||
void updateContinueCounter(float delta_time); // Actualiza el contador de continue
|
||||
void updateEnterNameCounter(float delta_time); // Actualiza el contador de entrar nombre
|
||||
void updateShowingName(float delta_time); // Actualiza el estado SHOWING_NAME
|
||||
void decNameEntryCounter(); // Decrementa el contador de entrar nombre
|
||||
|
||||
// --- Utilidades generales ---
|
||||
void updateScoreboard(); // Actualiza el panel del marcador
|
||||
@@ -350,19 +352,19 @@ class Player {
|
||||
void addScoreToScoreBoard() const; // Añade una puntuación a la tabla de records
|
||||
|
||||
// --- Sistema de disparo (nuevo - dos líneas) ---
|
||||
void updateFireSystem(float deltaTime); // Método principal del nuevo sistema de disparo
|
||||
void updateFunctionalLine(float deltaTime); // Actualiza la línea funcional (CanFire)
|
||||
void updateVisualLine(float deltaTime); // Actualiza la línea visual (Animaciones)
|
||||
void updateFiringStateFromVisual(); // Sincroniza firing_state_ con visual_fire_state_
|
||||
void transitionToRecoilingNew(); // Transición AIMING → RECOILING
|
||||
void transitionToThreatPose(); // Transición RECOILING → THREAT_POSE
|
||||
void transitionToNormalNew(); // Transición THREAT_POSE → NORMAL
|
||||
void updateFireSystem(float delta_time); // Método principal del nuevo sistema de disparo
|
||||
void updateFunctionalLine(float delta_time); // Actualiza la línea funcional (CanFire)
|
||||
void updateVisualLine(float delta_time); // Actualiza la línea visual (Animaciones)
|
||||
void updateFiringStateFromVisual(); // Sincroniza firing_state_ con visual_fire_state_
|
||||
void transitionToRecoilingNew(); // Transición AIMING → RECOILING
|
||||
void transitionToThreatPose(); // Transición RECOILING → THREAT_POSE
|
||||
void transitionToNormalNew(); // Transición THREAT_POSE → NORMAL
|
||||
|
||||
// --- Manejadores de movimiento ---
|
||||
void handlePlayingMovement(float deltaTime); // Gestiona el movimiento durante el juego
|
||||
void handleRecoverMovement(); // Comprueba si ha acabado la animación de recuperación
|
||||
void updateStepCounter(float deltaTime); // Incrementa o ajusta el contador de pasos
|
||||
void setInputBasedOnPlayerId(); // Asocia las entradas de control según el jugador
|
||||
void handlePlayingMovement(float delta_time); // Gestiona el movimiento durante el juego
|
||||
void handleRecoverMovement(); // Comprueba si ha acabado la animación de recuperación
|
||||
void updateStepCounter(float delta_time); // Incrementa o ajusta el contador de pasos
|
||||
void setInputBasedOnPlayerId(); // Asocia las entradas de control según el jugador
|
||||
|
||||
// --- Manejadores de estados especiales ---
|
||||
void handleRollingMovement(); // Actualiza la lógica de movimiento de "rodar"
|
||||
@@ -373,18 +375,18 @@ class Player {
|
||||
void handleContinueTimeOut(); // Gestiona tiempo de espera en pantalla "Continuar"
|
||||
|
||||
// --- Manejadores de transiciones de pantalla ---
|
||||
void handleTitleAnimation(float deltaTime); // Ejecuta animación del título
|
||||
void handleLeavingScreen(float deltaTime); // Lógica para salir de pantalla
|
||||
void handleEnteringScreen(float deltaTime); // Lógica para entrar en pantalla
|
||||
void handlePlayer1Entering(float deltaTime); // Entrada del Jugador 1
|
||||
void handlePlayer2Entering(float deltaTime); // Entrada del Jugador 2
|
||||
void handleTitleAnimation(float delta_time); // Ejecuta animación del título
|
||||
void handleLeavingScreen(float delta_time); // Lógica para salir de pantalla
|
||||
void handleEnteringScreen(float delta_time); // Lógica para entrar en pantalla
|
||||
void handlePlayer1Entering(float delta_time); // Entrada del Jugador 1
|
||||
void handlePlayer2Entering(float delta_time); // Entrada del Jugador 2
|
||||
|
||||
// --- Manejadores de pantallas especiales ---
|
||||
void handleCreditsMovement(float deltaTime); // Movimiento en pantalla de créditos
|
||||
void handleCreditsRightMovement(); // Movimiento hacia la derecha en créditos
|
||||
void handleCreditsLeftMovement(); // Movimiento hacia la izquierda en créditos
|
||||
void handleWaitingMovement(float deltaTime); // Animación del jugador saludando
|
||||
void updateWalkingStateForCredits(); // Actualiza estado de caminata en créditos
|
||||
void handleCreditsMovement(float delta_time); // Movimiento en pantalla de créditos
|
||||
void handleCreditsRightMovement(); // Movimiento hacia la derecha en créditos
|
||||
void handleCreditsLeftMovement(); // Movimiento hacia la izquierda en créditos
|
||||
void handleWaitingMovement(float delta_time); // Animación del jugador saludando
|
||||
void updateWalkingStateForCredits(); // Actualiza estado de caminata en créditos
|
||||
|
||||
// --- Utilidades de animación ---
|
||||
[[nodiscard]] auto computeAnimation() const -> std::pair<std::string, SDL_FlipMode>; // Calcula animación de movimiento y disparo
|
||||
|
||||
Reference in New Issue
Block a user