Pasaeta de linters

This commit is contained in:
2025-08-06 13:05:04 +02:00
parent 8ed2dbcd4f
commit 1224af2a9b
40 changed files with 623 additions and 592 deletions

View File

@@ -104,17 +104,16 @@ void Credits::update() {
fillCanvas();
}
static const auto audio = Audio::get();
audio->update();
Audio::update();
}
// Dibuja Credits::en patalla
void Credits::render() {
static const auto screen = Screen::get();
static auto *const SCREEN = Screen::get();
screen->start(); // Prepara para empezar a dibujar en la textura de juego
SDL_RenderTexture(screen->getRenderer(), canvas_, nullptr, nullptr); // Copia la textura con la zona de juego a la pantalla
screen->render(); // Vuelca el contenido del renderizador en pantalla
SCREEN->start(); // Prepara para empezar a dibujar en la textura de juego
SDL_RenderTexture(SCREEN->getRenderer(), canvas_, nullptr, nullptr); // Copia la textura con la zona de juego a la pantalla
SCREEN->render(); // Vuelca el contenido del renderizador en pantalla
}
// Comprueba el manejador de eventos

View File

@@ -1,19 +1,20 @@
#include "game.h"
#include <SDL3/SDL.h> // Para SDL_GetTicks, SDL_SetRenderTarget, SDL_EventType, SDL_CreateTexture, SDL_Delay, SDL_DestroyTexture, SDL_Event, SDL_GetRenderTarget, SDL_PollEvent, SDL_RenderTexture, SDL_SetTextureBlendMode, SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6, SDLK_7, SDLK_8, SDLK_9, SDL_BLENDMODE_BLEND, SDL_PixelFormat, SDL_Point, SDL_TextureAccess
#include <SDL3/SDL.h> // Para SDL_GetTicks, SDL_SetRenderTarget, SDL_EventType, SDL_CreateTexture, SDL_Delay, SDL_DestroyTexture, SDL_Event, SDL_GetRenderTarget, SDL_PollEvent, SDL_RenderTexture, SDL_SetTextureBlendMode, SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6, SDLK_7, SDLK_8, SDLK_9, SDLK_KP_MINUS, SDLK_KP_PLUS, SDL_BLENDMODE_BLEND, SDL_PixelFormat, SDL_Point, SDL_TextureAccess
#include <algorithm> // Para max, find_if, clamp, find, min
#include <algorithm> // Para max, find, clamp, find_if, min
#include <array> // Para array
#include <cstdlib> // Para rand, size_t
#include <functional> // Para function
#include <iostream> // Para std::cout, std::endl
#include <iterator> // Para distance, size
#include <memory> // Para std::make_unique
#include <iostream> // Para basic_ostream, basic_ostream::operator<<, cout, endl
#include <iterator> // Para size
#include <memory> // Para shared_ptr, unique_ptr, __shared_ptr_access, allocator, make_unique, operator==, make_shared
#include <utility> // Para move
#include "asset.h" // Para Asset
#include "audio.h" // Para Audio
#include "background.h" // Para Background
#include "balloon.h" // Para Balloon, Balloon::SPEED
#include "balloon.h" // Para Balloon
#include "balloon_manager.h" // Para BalloonManager
#include "bullet.h" // Para Bullet, BulletType, BulletMoveStatus
#include "color.h" // Para Color, FLASH_COLOR
@@ -22,20 +23,21 @@
#include "global_events.h" // Para check
#include "global_inputs.h" // Para check
#include "hit.h" // Para Hit
#include "input.h" // Para InputAction, Input, Input::DO_NOT_ALLOW_REPEAT, Input::ALLOW_REPEAT, InputDevice
#include "input.h" // Para Input
#include "input_types.h" // Para InputAction
#include "item.h" // Para Item, ItemType
#include "lang.h" // Para getText
#include "manage_hiscore_table.h" // Para ManageHiScoreTable, HiScoreEntry
#include "manage_hiscore_table.h" // Para HiScoreEntry, ManageHiScoreTable
#include "param.h" // Para Param, param, ParamGame, ParamScoreboard, ParamFade, ParamBalloon
#include "path_sprite.h" // Para Path, PathSprite, createPath, PathType
#include "player.h" // Para Player, PlayerState
#include "player.h" // Para Player
#include "resource.h" // Para Resource
#include "scoreboard.h" // Para Scoreboard, ScoreboardMode, SCOREBOARD_LEFT_PANEL, SCOREBOARD_RIGHT_PANEL, SCOREBOARD_CENTER_PANEL
#include "scoreboard.h" // Para Scoreboard
#include "screen.h" // Para Screen
#include "section.hpp" // Para Name, name, AttractMode, Options, attract_mode, options
#include "smart_sprite.h" // Para SmartSprite
#include "stage.h" // Para number, Stage, get, total_power, power, addPower, init, power_can_be_added, stages
#include "tabe.h" // Para Tabe, TabeState
#include "tabe.h" // Para Tabe
#include "text.h" // Para Text
#include "texture.h" // Para Texture
#include "ui/notifier.h" // Para Notifier
@@ -903,8 +905,7 @@ void Game::update() {
fillCanvas();
}
static const auto audio = Audio::get();
audio->update();
Audio::update();
}
// Dibuja el juego
@@ -1834,8 +1835,8 @@ void Game::playSound(const std::string &name) const {
return;
}
static auto audio = Audio::get();
audio->playSound(name);
static auto *audio_ = Audio::get();
audio_->playSound(name);
}
// Organiza los jugadores para que los vivos se pinten sobre los muertos
@@ -1903,7 +1904,7 @@ void Game::sendPlayerToTheFront(const std::shared_ptr<Player> &player) {
#ifdef _DEBUG
// Comprueba los eventos en el modo DEBUG
void Game::checkDebugEvents(const SDL_Event &event) {
static int formation_id = 0;
static int formation_id_ = 0;
if (event.type == SDL_EVENT_KEY_DOWN && static_cast<int>(event.key.repeat) == 0) {
switch (event.key.key) {
case SDLK_1: // Crea una powerball
@@ -1966,17 +1967,17 @@ void Game::checkDebugEvents(const SDL_Event &event) {
break;
}
case SDLK_KP_PLUS: {
++formation_id;
++formation_id_;
balloon_manager_->destroyAllBalloons();
balloon_manager_->deployFormation(formation_id);
std::cout << formation_id << std::endl;
balloon_manager_->deployFormation(formation_id_);
std::cout << formation_id_ << std::endl;
break;
}
case SDLK_KP_MINUS: {
--formation_id;
--formation_id_;
balloon_manager_->destroyAllBalloons();
balloon_manager_->deployFormation(formation_id);
std::cout << formation_id << std::endl;
balloon_manager_->deployFormation(formation_id_);
std::cout << formation_id_ << std::endl;
break;
}
default:

View File

@@ -171,12 +171,12 @@ class Game {
void updateGameStateGameOver(); // Gestiona el estado de fin de partida
// --- Gestión de jugadores ---
void initPlayers(Player::Id player_id); // Inicializa los datos de los jugadores
void updatePlayers(); // Actualiza las variables y estados de los jugadores
void renderPlayers(); // Renderiza todos los jugadores en pantalla
void sortPlayersByZOrder(); // Reorganiza el orden de dibujado de jugadores
auto getPlayer(Player::Id id) -> std::shared_ptr<Player>; // Obtiene un jugador por su identificador
static auto getController(Player::Id player_id) -> int; // Obtiene el controlador asignado a un jugador
void initPlayers(Player::Id player_id); // Inicializa los datos de los jugadores
void updatePlayers(); // Actualiza las variables y estados de los jugadores
void renderPlayers(); // Renderiza todos los jugadores en pantalla
void sortPlayersByZOrder(); // Reorganiza el orden de dibujado de jugadores
auto getPlayer(Player::Id id) -> std::shared_ptr<Player>; // Obtiene un jugador por su identificador
static auto getController(Player::Id player_id) -> int; // Obtiene el controlador asignado a un jugador
// --- Estado de jugadores ---
void checkAndUpdatePlayerStatus(int active_player_index, int inactive_player_index); // Actualiza estado entre jugadores
@@ -209,11 +209,11 @@ class Game {
void demoHandlePlayerInput(const std::shared_ptr<Player> &player, int index); // Procesa entrada de jugador en demo
// --- Sistema de balas y proyectiles ---
void updateBullets(); // Actualiza posición y estado de todas las balas
void renderBullets(); // Renderiza todas las balas activas
void updateBullets(); // Actualiza posición y estado de todas las balas
void renderBullets(); // Renderiza todas las balas activas
void createBullet(int x, int y, BulletType kind, bool powered_up, Player::Id owner); // Crea una nueva bala
void checkBulletCollision(); // Verifica colisiones de todas las balas
void freeBullets(); // Libera memoria del vector de balas
void checkBulletCollision(); // Verifica colisiones de todas las balas
void freeBullets(); // Libera memoria del vector de balas
// --- Colisiones específicas de balas ---
auto checkBulletTabeCollision(std::shared_ptr<Bullet> bullet) -> bool; // Detecta colisión bala-Tabe
@@ -274,7 +274,7 @@ class Game {
// --- Modo demostración ---
void initDemo(Player::Id player_id); // Inicializa variables para el modo demostración
void updateDemo(); // Actualiza lógica específica del modo demo
void updateDemo(); // Actualiza lógica específica del modo demo
// --- Recursos y renderizado ---
void setResources(); // Asigna texturas y animaciones a los objetos
@@ -285,8 +285,8 @@ class Game {
// --- Sistema de audio ---
static void playMusic(); // Reproduce la música de fondo
void stopMusic() const; // Detiene la reproducción de música
void pauseMusic(); // Pausa la música
void resumeMusic(); // Retoma la música que eestaba pausada
static void pauseMusic(); // Pausa la música
static void resumeMusic(); // Retoma la música que eestaba pausada
void playSound(const std::string &name) const; // Reproduce un efecto de sonido específico
// --- Utilidades y servicios ---

View File

@@ -66,23 +66,22 @@ void HiScoreTable::update() {
fillTexture(); // Dibuja los sprites en la textura
}
static const auto audio = Audio::get();
audio->update();
Audio::update();
}
// Pinta en pantalla
void HiScoreTable::render() {
static const auto screen = Screen::get();
static auto *const SCREEN = Screen::get();
screen->start(); // Prepara para empezar a dibujar en la textura de juego
screen->clean(); // Limpia la pantalla
SCREEN->start(); // Prepara para empezar a dibujar en la textura de juego
SCREEN->clean(); // Limpia la pantalla
background_->render(); // Pinta el fondo
view_area_.y = std::max(0.0F, param.game.height - counter_ + 100); // Establece la ventana del backbuffer
SDL_RenderTexture(renderer_, backbuffer_, nullptr, &view_area_); // Copia el backbuffer al renderizador
fade_->render(); // Renderiza el fade
screen->render(); // Vuelca el contenido del renderizador en pantalla
SCREEN->render(); // Vuelca el contenido del renderizador en pantalla
}
// Dibuja los sprites en la textura

View File

@@ -209,26 +209,25 @@ void Instructions::update() {
ticks_ = SDL_GetTicks(); // Actualiza el contador de ticks
Screen::get()->update(); // Actualiza el objeto screen
counter_++; // Incrementa el contador
updateSprites(); // Actualiza los sprites
updateBackbuffer(); // Gestiona la textura con los graficos
tiled_bg_->update(); // Actualiza el mosaico de fondo
fade_->update(); // Actualiza el objeto "fade"
fillBackbuffer(); // Rellena el backbuffer
counter_++; // Incrementa el contador
updateSprites(); // Actualiza los sprites
updateBackbuffer(); // Gestiona la textura con los graficos
tiled_bg_->update(); // Actualiza el mosaico de fondo
fade_->update(); // Actualiza el objeto "fade"
fillBackbuffer(); // Rellena el backbuffer
}
static const auto audio = Audio::get();
audio->update();
Audio::update();
}
// Pinta en pantalla
void Instructions::render() {
static const auto screen = Screen::get();
screen->start();// Prepara para empezar a dibujar en la textura de juego
screen->clean();// Limpia la pantalla
static auto *const SCREEN = Screen::get();
tiled_bg_->render();// Dibuja el mosacico de fondo
SCREEN->start(); // Prepara para empezar a dibujar en la textura de juego
SCREEN->clean(); // Limpia la pantalla
tiled_bg_->render(); // Dibuja el mosacico de fondo
// Copia la textura y el backbuffer al renderizador
if (view_.y == 0) {
@@ -237,9 +236,9 @@ void Instructions::render() {
SDL_RenderTexture(renderer_, backbuffer_, nullptr, &view_);
}
fade_->render(); // Renderiza el fundido
screen->render();// Vuelca el contenido del renderizador en pantalla
fade_->render(); // Renderiza el fundido
SCREEN->render(); // Vuelca el contenido del renderizador en pantalla
}
// Comprueba los eventos

View File

@@ -225,7 +225,7 @@ void Intro::update() {
ticks_ = SDL_GetTicks(); // Actualiza el contador de ticks
Screen::get()->update(); // Actualiza el objeto screen
tiled_bg_->update(); // Actualiza el fondo
tiled_bg_->update(); // Actualiza el fondo
switch (state_) {
case IntroState::SCENES:
@@ -240,18 +240,17 @@ void Intro::update() {
}
}
static const auto audio = Audio::get();
audio->update();
Audio::update();
}
// Dibuja el objeto en pantalla
void Intro::render() {
static const auto screen = Screen::get();
screen->start();// Prepara para empezar a dibujar en la textura de juego
screen->clean();// Limpia la pantalla
static auto *const SCREEN = Screen::get();
tiled_bg_->render();// Dibuja el fondo
SCREEN->start(); // Prepara para empezar a dibujar en la textura de juego
SCREEN->clean(); // Limpia la pantalla
tiled_bg_->render(); // Dibuja el fondo
switch (state_) {
case IntroState::SCENES: {
@@ -263,8 +262,8 @@ void Intro::render() {
case IntroState::POST:
break;
}
screen->render();// Vuelca el contenido del renderizador en pantalla
SCREEN->render(); // Vuelca el contenido del renderizador en pantalla
}
// Bucle principal

View File

@@ -134,26 +134,25 @@ void Logo::update() {
if (SDL_GetTicks() - ticks_ > param.game.speed) {
ticks_ = SDL_GetTicks(); // Actualiza el contador de ticks
Screen::get()->update(); // Actualiza el objeto screen
updateJAILGAMES(); // Actualiza el logo de JAILGAMES
updateTextureColors(); // Actualiza los colores de las texturas
++counter_; // Gestiona el contador
updateJAILGAMES(); // Actualiza el logo de JAILGAMES
updateTextureColors(); // Actualiza los colores de las texturas
++counter_; // Gestiona el contador
}
static const auto audio = Audio::get();
audio->update();
Audio::update();
}
// Dibuja en pantalla
void Logo::render() {
static const auto screen = Screen::get();
static auto *const SCREEN = Screen::get();
screen->start();
screen->clean();
SCREEN->start();
SCREEN->clean();
renderJAILGAMES();
screen->render();
SCREEN->render();
}
// Bucle para el logo del juego

View File

@@ -1,34 +1,34 @@
#include "title.h"
#include <SDL3/SDL.h> // Para SDL_GetTicks, Uint32, SDL_EventType
#include <SDL3/SDL.h> // Para SDL_GetTicks, Uint32, SDL_Keycode, SDL_Event, SDL_PollEvent, SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_A, SDLK_C, SDLK_D, SDLK_F, SDLK_S, SDLK_V, SDLK_X, SDLK_Z, SDL_EventType
#include <algorithm> // Para find_if
#include <cstddef> // Para size_t
#include <iostream> // Para basic_ostream, basic_ostream::operator<<
#include <string> // Para basic_string, char_traits, operator+
#include <algorithm> // Para max, find_if
#include <iostream> // Para basic_ostream, basic_ostream::operator<<, operator<<, cout, endl, hex
#include <string> // Para char_traits, operator+, to_string, string, basic_string
#include <vector> // Para vector
#include "audio.h" // Para Audio
#include "color.h" // Para Color, Zone, NO_TEXT_COLOR, TITLE_SHADO...
#include "color.h" // Para Color, NO_TEXT_COLOR, TITLE_SHADOW_TEXT_COLOR
#include "define_buttons.h" // Para DefineButtons
#include "fade.h" // Para Fade, FadeType
#include "game_logo.h" // Para GameLogo
#include "global_events.h" // Para check
#include "global_inputs.h" // Para check
#include "input.h" // Para Input, Input::DO_NOT_ALLOW_REPEAT, Input...
#include "input.h" // Para Input
#include "input_types.h" // Para InputAction
#include "lang.h" // Para getText
#include "options.h" // Para GamepadOptions, controllers, getPlayerW...
#include "param.h" // Para Param, param, ParamGame, ParamTitle
#include "player.h" // Para Player, PlayerState
#include "options.h" // Para Gamepad, GamepadManager, gamepad_manager, Settings, settings, getPlayerWhoUsesKeyboard, swapControllers, swapKeyboard
#include "param.h" // Para Param, param, ParamGame, ParamTitle, ParamFade
#include "player.h" // Para Player
#include "resource.h" // Para Resource
#include "screen.h" // Para Screen
#include "section.hpp" // Para Name, name, Options, options, AttractMode
#include "section.hpp" // Para Name, name, Options, options, AttractMode, attract_mode
#include "sprite.h" // Para Sprite
#include "text.h" // Para TEXT_CENTER, TEXT_SHADOW, Text
#include "tiled_bg.h" // Para TiledBG, TiledBGMode
#include "ui/notifier.h" // Para Notifier
#include "ui/service_menu.h" // Para ServiceMenu
#include "utils.h"
#include "utils.h" // Para Zone, BLOCK
class Texture;
@@ -87,16 +87,15 @@ void Title::update() {
updatePlayers();
}
static const auto audio = Audio::get();
audio->update();
Audio::update();
}
// Dibuja el objeto en pantalla
void Title::render() {
static const auto screen = Screen::get();
static auto* const SCREEN = Screen::get();
screen->start();
screen->clean();
SCREEN->start();
SCREEN->clean();
tiled_bg_->render();
game_logo_->render();
@@ -106,7 +105,7 @@ void Title::render() {
define_buttons_->render();
fade_->render();
screen->render();
SCREEN->render();
}
// Comprueba los eventos
@@ -348,7 +347,7 @@ void Title::showControllers() {
// Crea los textos
std::string text1 = Lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(static_cast<int>(Player::Id::PLAYER1)) + ": " + Options::gamepad_manager.getGamepad(Player::Id::PLAYER1).name;
std::string text2 = Lang::getText("[DEFINE_BUTTONS] PLAYER") + std::to_string(static_cast<int>(Player::Id::PLAYER2)) + ": " + Options::gamepad_manager.getGamepad(Player::Id::PLAYER2).name;
// Muestra la notificación
Notifier::get()->show({text1, text2});
}

View File

@@ -1,8 +1,8 @@
#pragma once
#include <SDL3/SDL.h> // Para SDL_Keycode, SDL_Event, Uint64
#include <stdint.h> // Para uint8_t
#include <cstdint> // Para uint8_t
#include <memory> // Para unique_ptr, shared_ptr
#include <string_view> // Para string_view
#include <vector> // Para vector
@@ -87,18 +87,18 @@ class Title {
void resetCounter(); // Reinicia el contador interno
// --- Entrada de usuario ---
void checkEvents(); // Comprueba los eventos
void checkInput(); // Comprueba las entradas
void handleKeyDownEvent(const SDL_Event& event); // Maneja el evento de tecla presionada
void handleControlKeys(SDL_Keycode key); // Maneja las teclas de control específicas
[[nodiscard]] auto shouldSkipInputCheck() const -> bool; // Determina si se debe omitir la comprobación de entrada
void processControllerInputs(); // Procesa las entradas de los mandos
[[nodiscard]] static auto isStartButtonPressed(const Options::Gamepad *controller) -> bool; // Comprueba si se ha pulsado el botón Start
void handleStartButtonPress(const Options::Gamepad *controller); // Maneja la pulsación del botón Start
[[nodiscard]] auto canProcessStartButton() const -> bool; // Verifica si se puede procesar la pulsación del botón Start
void processPlayer1Start(); // Procesa el inicio del jugador 1
void processPlayer2Start(); // Procesa el inicio del jugador 2
void activatePlayerAndSetState(Player::Id player_id); // Activa al jugador y cambia el estado del título
void checkEvents(); // Comprueba los eventos
void checkInput(); // Comprueba las entradas
void handleKeyDownEvent(const SDL_Event& event); // Maneja el evento de tecla presionada
void handleControlKeys(SDL_Keycode key); // Maneja las teclas de control específicas
[[nodiscard]] auto shouldSkipInputCheck() const -> bool; // Determina si se debe omitir la comprobación de entrada
void processControllerInputs(); // Procesa las entradas de los mandos
[[nodiscard]] static auto isStartButtonPressed(const Options::Gamepad* controller) -> bool; // Comprueba si se ha pulsado el botón Start
void handleStartButtonPress(const Options::Gamepad* controller); // Maneja la pulsación del botón Start
[[nodiscard]] auto canProcessStartButton() const -> bool; // Verifica si se puede procesar la pulsación del botón Start
void processPlayer1Start(); // Procesa el inicio del jugador 1
void processPlayer2Start(); // Procesa el inicio del jugador 2
void activatePlayerAndSetState(Player::Id player_id); // Activa al jugador y cambia el estado del título
// --- Gestión de jugadores ---
void initPlayers(); // Inicializa los jugadores