From 7ebefd7b5458fb89145ac0ea04fc224a10c6a134 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Mon, 7 Oct 2024 12:30:46 +0200 Subject: [PATCH] Les enum class passen a estar totes amb la inicial en majuscula --- source/fade.cpp | 30 ++++++------ source/fade.h | 18 ++++---- source/game.cpp | 44 +++++++++--------- source/game.h | 2 +- source/hiscore_table.cpp | 10 ++-- source/hiscore_table.h | 2 +- source/instructions.cpp | 6 +-- source/options.cpp | 44 +++++++++--------- source/player.cpp | 98 ++++++++++++++++++++-------------------- source/player.h | 20 ++++---- source/scoreboard.cpp | 22 ++++----- source/scoreboard.h | 6 +-- source/screen.cpp | 18 ++++---- source/screen.h | 6 +-- source/title.cpp | 2 +- source/utils.h | 18 ++++---- 16 files changed, 173 insertions(+), 173 deletions(-) diff --git a/source/fade.cpp b/source/fade.cpp index 55325e5..46bad2a 100644 --- a/source/fade.cpp +++ b/source/fade.cpp @@ -27,8 +27,8 @@ Fade::~Fade() // Inicializa las variables void Fade::init() { - type = fadeType::CENTER; - mode = fadeMode::OUT; + type = FadeType::CENTER; + mode = FadeMode::OUT; enabled = false; finished = false; counter = 0; @@ -67,10 +67,10 @@ void Fade::update() { switch (type) { - case fadeType::FULLSCREEN: + case FadeType::FULLSCREEN: { // Modifica la transparencia - a = mode == fadeMode::OUT ? std::min(counter * 4, 255) : 255 - std::min(counter * 4, 255); + a = mode == FadeMode::OUT ? std::min(counter * 4, 255) : 255 - std::min(counter * 4, 255); SDL_SetTextureAlphaMod(backbuffer, a); @@ -83,7 +83,7 @@ void Fade::update() break; } - case fadeType::CENTER: + case FadeType::CENTER: { // Dibuja sobre el backbuffer auto *temp = SDL_GetRenderTarget(renderer); @@ -112,7 +112,7 @@ void Fade::update() break; } - case fadeType::RANDOM_SQUARE: + case FadeType::RANDOM_SQUARE: { if (counter % fadeRandomSquaresDelay == 0) { @@ -146,7 +146,7 @@ void Fade::update() break; } - case fadeType::VENETIAN: + case FadeType::VENETIAN: { // Counter debe ir de 0 a 150 if (square.back().h < param.fade.venetianSize) @@ -209,14 +209,14 @@ void Fade::activate() switch (type) { - case fadeType::FULLSCREEN: + case FadeType::FULLSCREEN: { // Pinta el backbuffer de color sólido cleanBackbuffer(r, g, b, 255); break; } - case fadeType::CENTER: + case FadeType::CENTER: { rect1 = {0, 0, param.game.width, 0}; rect2 = {0, 0, param.game.width, 0}; @@ -224,7 +224,7 @@ void Fade::activate() break; } - case fadeType::RANDOM_SQUARE: + case FadeType::RANDOM_SQUARE: { rect1 = {0, 0, param.game.width / numSquaresWidth, param.game.height / numSquaresHeight}; square.clear(); @@ -251,18 +251,18 @@ void Fade::activate() // Limpia la textura auto *temp = SDL_GetRenderTarget(renderer); SDL_SetRenderTarget(renderer, backbuffer); - a = mode == fadeMode::OUT ? 0 : 255; + a = mode == FadeMode::OUT ? 0 : 255; SDL_SetRenderDrawColor(renderer, r, g, b, a); SDL_RenderClear(renderer); SDL_SetRenderTarget(renderer, temp); // Deja el color listo para usar - a = mode == fadeMode::OUT ? 255 : 0; + a = mode == FadeMode::OUT ? 255 : 0; break; } - case fadeType::VENETIAN: + case FadeType::VENETIAN: { cleanBackbuffer(0, 0, 0, 0); rect1 = {0, 0, param.game.width, 0}; @@ -297,13 +297,13 @@ bool Fade::hasEnded() const } // Establece el tipo de fade -void Fade::setType(fadeType type) +void Fade::setType(FadeType type) { this->type = type; } // Establece el modo de fade -void Fade::setMode(fadeMode mode) +void Fade::setMode(FadeMode mode) { this->mode = mode; } diff --git a/source/fade.h b/source/fade.h index d717fb5..e205d78 100644 --- a/source/fade.h +++ b/source/fade.h @@ -6,7 +6,7 @@ #include // for vector // Tipos de fundido -enum class fadeType +enum class FadeType { FULLSCREEN = 0, CENTER = 1, @@ -15,7 +15,7 @@ enum class fadeType }; // Modos de fundido -enum class fadeMode +enum class FadeMode { IN = 0, OUT = 1, @@ -30,17 +30,17 @@ private: SDL_Texture *backbuffer; // Textura para usar como backbuffer con SDL_TEXTUREACCESS_TARGET // Variables - fadeType type; // Tipo de fade a realizar - fadeMode mode; // Modo de fade a realizar + FadeType type; // Tipo de fade a realizar + FadeMode mode; // Modo de fade a realizar Uint16 counter; // Contador interno bool enabled; // Indica si el fade está activo bool finished; // Indica si ha terminado la transición Uint8 r, g, b, a; // Colores para el fade SDL_Rect rect1; // Rectangulo usado para crear los efectos de transición SDL_Rect rect2; // Rectangulo usado para crear los efectos de transición - int numSquaresWidth; // Cantidad total de cuadraditos en horizontal para el fadeType::RANDOM_SQUARE - int numSquaresHeight; // Cantidad total de cuadraditos en vertical para el fadeType::RANDOM_SQUARE - std::vector square; // Vector con los indices de los cuadrados para el fadeType::RANDOM_SQUARE + int numSquaresWidth; // Cantidad total de cuadraditos en horizontal para el FadeType::RANDOM_SQUARE + int numSquaresHeight; // Cantidad total de cuadraditos en vertical para el FadeType::RANDOM_SQUARE + std::vector square; // Vector con los indices de los cuadrados para el FadeType::RANDOM_SQUARE int fadeRandomSquaresDelay; // Duración entre cada pintado de cuadrados int fadeRandomSquaresMult; // Cantidad de cuadrados que se pintaran cada vez int postDuration; // Duración posterior del fade tras finalizar @@ -78,10 +78,10 @@ public: bool isEnabled() const; // Establece el tipo de fade - void setType(fadeType type); + void setType(FadeType type); // Establece el modo de fade - void setMode(fadeMode mode); + void setMode(FadeMode mode); // Establece el color del fade void setColor(Uint8 r, Uint8 g, Uint8 b); diff --git a/source/game.cpp b/source/game.cpp index da56a19..ee30cd0 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -15,7 +15,7 @@ #include "bullet.h" // for Bullet, BulletType::LEFT, BulletType::RIGHT #include "enemy_formations.h" // for stage_t, EnemyFormations, enemyIni... #include "explosions.h" // for Explosions -#include "fade.h" // for Fade, fadeType::RANDOM_SQUARE, FADE_VEN... +#include "fade.h" // for Fade, FadeType::RANDOM_SQUARE, FADE_VEN... #include "global_inputs.h" // for globalInputs::check #include "input.h" // for inputs_e, Input, INPUT_DO_NOT_ALLO... #include "item.h" // for Item, ITEM_COFFEE_MACHINE, ITEM_CLOCK @@ -24,7 +24,7 @@ #include "manage_hiscore_table.h" // for ManageHiScoreTable #include "options.h" // for options #include "param.h" // for param -#include "player.h" // for Player, playerStatus::PLAYING, PLA... +#include "player.h" // for Player, PlayerStatus::PLAYING, PLA... #include "scoreboard.h" // for Scoreboard, scoreboard_modes_e #include "screen.h" // for Screen #include "smart_sprite.h" // for SmartSprite @@ -146,7 +146,7 @@ void Game::init(int playerID) Player *player = getPlayer(playerID); // Cambia el estado del jugador seleccionado - player->setStatusPlaying(playerStatus::PLAYING); + player->setStatusPlaying(PlayerStatus::PLAYING); // Como es el principio del juego, empieza sin inmunidad player->setInvulnerable(false); @@ -154,7 +154,7 @@ void Game::init(int playerID) // Variables relacionadas con la dificultad switch (difficulty) { - case gameDifficulty::EASY: + case GameDifficulty::EASY: { defaultEnemySpeed = BALLOON_SPEED_1; difficultyScoreMultiplier = 0.5f; @@ -163,7 +163,7 @@ void Game::init(int playerID) break; } - case gameDifficulty::NORMAL: + case GameDifficulty::NORMAL: { defaultEnemySpeed = BALLOON_SPEED_1; difficultyScoreMultiplier = 1.0f; @@ -172,7 +172,7 @@ void Game::init(int playerID) break; } - case gameDifficulty::HARD: + case GameDifficulty::HARD: { defaultEnemySpeed = BALLOON_SPEED_5; difficultyScoreMultiplier = 1.5f; @@ -192,10 +192,10 @@ void Game::init(int playerID) scoreboard->setName(player->getScoreBoardPanel(), player->getName()); if (player->isWaiting()) { - scoreboard->setMode(player->getScoreBoardPanel(), scoreboardMode::WAITING); + scoreboard->setMode(player->getScoreBoardPanel(), ScoreboardMode::WAITING); } } - scoreboard->setMode(SCOREBOARD_CENTER_PANEL, scoreboardMode::STAGE_INFO); + scoreboard->setMode(SCOREBOARD_CENTER_PANEL, ScoreboardMode::STAGE_INFO); // Resto de variables hiScore.score = options.game.hiScoreTable[0].score; @@ -255,7 +255,7 @@ void Game::init(int playerID) { const int otherPlayer = playerID == 1 ? 2 : 1; Player *player = getPlayer(otherPlayer); - player->setStatusPlaying(playerStatus::PLAYING); + player->setStatusPlaying(PlayerStatus::PLAYING); } for (auto player : players) @@ -274,8 +274,8 @@ void Game::init(int playerID) JA_EnableSound(false); // Configura los marcadores - scoreboard->setMode(SCOREBOARD_LEFT_PANEL, scoreboardMode::DEMO); - scoreboard->setMode(SCOREBOARD_RIGHT_PANEL, scoreboardMode::DEMO); + scoreboard->setMode(SCOREBOARD_LEFT_PANEL, ScoreboardMode::DEMO); + scoreboard->setMode(SCOREBOARD_RIGHT_PANEL, ScoreboardMode::DEMO); } initPaths(); @@ -297,7 +297,7 @@ void Game::init(int playerID) // Inicializa el objeto para el fundido fade->setColor(fadeColor.r, fadeColor.g, fadeColor.b); fade->setPost(param.fade.postDuration); - fade->setType(fadeType::VENETIAN); + fade->setType(FadeType::VENETIAN); // Con los globos creados, calcula el nivel de amenaza evaluateAndSetMenace(); @@ -861,7 +861,7 @@ void Game::updatePlayers() if (demo.enabled && allPlayersAreNotPlaying()) { - fade->setType(fadeType::RANDOM_SQUARE); + fade->setType(FadeType::RANDOM_SQUARE); fade->activate(); } } @@ -1037,7 +1037,7 @@ void Game::setBalloonSpeed(float speed) void Game::incBalloonSpeed() { // La velocidad solo se incrementa en el modo normal - if (difficulty == gameDifficulty::NORMAL) + if (difficulty == GameDifficulty::NORMAL) { if (enemySpeed == BALLOON_SPEED_1) { @@ -1067,7 +1067,7 @@ void Game::incBalloonSpeed() void Game::decBalloonSpeed() { // La velocidad solo se decrementa en el modo normal - if (difficulty == gameDifficulty::NORMAL) + if (difficulty == GameDifficulty::NORMAL) { if (enemySpeed == BALLOON_SPEED_5) { @@ -1740,7 +1740,7 @@ void Game::killPlayer(Player *player) JA_PlaySound(playerCollisionSound); screen->shake(); JA_PlaySound(coffeeOutSound); - player->setStatusPlaying(playerStatus::DYING); + player->setStatusPlaying(PlayerStatus::DYING); if (!demo.enabled) { // En el modo DEMO ni se para la musica ni se añade la puntuación a la tabla allPlayersAreNotPlaying() ? JA_StopMusic() : JA_ResumeMusic(); @@ -1840,7 +1840,7 @@ void Game::update() // Activa el fundido antes de acabar con los datos de la demo if (demo.counter == TOTAL_DEMO_DATA - 200) { - fade->setType(fadeType::RANDOM_SQUARE); + fade->setType(FadeType::RANDOM_SQUARE); fade->activate(); } @@ -2237,7 +2237,7 @@ void Game::checkInput() // Si no está jugando, el botón de start le permite continuar jugando if (input->checkInput(input_start, INPUT_DO_NOT_ALLOW_REPEAT, options.controller[controllerIndex].deviceType, options.controller[controllerIndex].index)) { - player->setStatusPlaying(playerStatus::PLAYING); + player->setStatusPlaying(PlayerStatus::PLAYING); } // Si está continuando, los botones de fuego hacen decrementar el contador @@ -2260,7 +2260,7 @@ void Game::checkInput() { player->setInput(input_start); addScoreToScoreBoard(player->getRecordName(), player->getScore()); - player->setStatusPlaying(playerStatus::CONTINUE); + player->setStatusPlaying(PlayerStatus::CONTINUE); } else { @@ -2287,7 +2287,7 @@ void Game::checkInput() { player->setInput(input_start); addScoreToScoreBoard(player->getRecordName(), player->getScore()); - player->setStatusPlaying(playerStatus::CONTINUE); + player->setStatusPlaying(PlayerStatus::CONTINUE); } } } @@ -2824,7 +2824,7 @@ void Game::checkAndUpdatePlayerStatus(int activePlayerIndex, int inactivePlayerI !players[inactivePlayerIndex]->isGameOver() && !players[inactivePlayerIndex]->isWaiting()) { - players[activePlayerIndex]->setStatusPlaying(playerStatus::WAITING); + players[activePlayerIndex]->setStatusPlaying(PlayerStatus::WAITING); } } @@ -2842,7 +2842,7 @@ void Game::checkPlayersStatusPlaying() // Entonces los pone en estado de Game Over for (auto player : players) { - player->setStatusPlaying(playerStatus::GAME_OVER); + player->setStatusPlaying(PlayerStatus::GAME_OVER); } } diff --git a/source/game.h b/source/game.h index b4e015a..ca2afc6 100644 --- a/source/game.h +++ b/source/game.h @@ -195,7 +195,7 @@ private: bool coffeeMachineEnabled; // Indica si hay una máquina de café en el terreno de juego bool gameCompleted; // Indica si se ha completado la partida, llegando al final de la ultima pantalla int gameCompletedCounter; // Contador para el tramo final, cuando se ha completado la partida y ya no aparecen más enemigos - gameDifficulty difficulty; // Dificultad del juego + GameDifficulty difficulty; // Dificultad del juego float difficultyScoreMultiplier; // Multiplicador de puntos en función de la dificultad color_t difficultyColor; // Color asociado a la dificultad int lastStageReached; // Contiene el número de la última pantalla que se ha alcanzado diff --git a/source/hiscore_table.cpp b/source/hiscore_table.cpp index 9ff3b9e..7d3a49d 100644 --- a/source/hiscore_table.cpp +++ b/source/hiscore_table.cpp @@ -43,7 +43,7 @@ HiScoreTable::HiScoreTable(JA_Music_t *music) : music(music) counter = 0; counterEnd = 800; viewArea = {0, 0, param.game.width, param.game.height}; - fadeMode = fadeMode::IN; + fadeMode = FadeMode::IN; // Inicializa objetos background->setPos(param.game.gameArea.rect); @@ -51,7 +51,7 @@ HiScoreTable::HiScoreTable(JA_Music_t *music) : music(music) background->setGradientNumber(1); background->setTransition(0.8f); fade->setColor(fadeColor.r, fadeColor.g, fadeColor.b); - fade->setType(fadeType::RANDOM_SQUARE); + fade->setType(FadeType::RANDOM_SQUARE); fade->setPost(param.fade.postDuration); fade->setMode(fadeMode); fade->activate(); @@ -275,14 +275,14 @@ void HiScoreTable::updateFade() { fade->update(); - if (fade->hasEnded() && fadeMode == fadeMode::IN) + if (fade->hasEnded() && fadeMode == FadeMode::IN) { fade->reset(); - fadeMode = fadeMode::OUT; + fadeMode = FadeMode::OUT; fade->setMode(fadeMode); } - if (fade->hasEnded() && fadeMode == fadeMode::OUT) + if (fade->hasEnded() && fadeMode == FadeMode::OUT) { section::name = section::NAME_INSTRUCTIONS; } diff --git a/source/hiscore_table.h b/source/hiscore_table.h index ecd8993..18db8b0 100644 --- a/source/hiscore_table.h +++ b/source/hiscore_table.h @@ -50,7 +50,7 @@ private: Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa SDL_Rect viewArea; // Parte de la textura que se muestra en pantalla - fadeMode fadeMode; // Modo de fade a utilizar + FadeMode fadeMode; // Modo de fade a utilizar // Actualiza las variables void update(); diff --git a/source/instructions.cpp b/source/instructions.cpp index 06d26de..9f4d31d 100644 --- a/source/instructions.cpp +++ b/source/instructions.cpp @@ -6,7 +6,7 @@ #include // for max #include // for basic_string #include "asset.h" // for Asset -#include "fade.h" // for Fade, fadeType::FULLSCREEN, fadeMode::IN +#include "fade.h" // for Fade, FadeType::FULLSCREEN, FadeMode::IN #include "global_inputs.h" // for globalInputs::check #include "input.h" // for Input #include "jail_audio.h" // for JA_GetMusicState, JA_Music_state @@ -57,9 +57,9 @@ Instructions::Instructions(JA_Music_t *music) // Inicializa objetos fade->setColor(fadeColor.r, fadeColor.g, fadeColor.b); - fade->setType(fadeType::FULLSCREEN); + fade->setType(FadeType::FULLSCREEN); fade->setPost(param.fade.postDuration); - fade->setMode(fadeMode::IN); + fade->setMode(FadeMode::IN); fade->activate(); // Rellena la textura de texto diff --git a/source/options.cpp b/source/options.cpp index 39b0640..d3d7f22 100644 --- a/source/options.cpp +++ b/source/options.cpp @@ -6,11 +6,11 @@ #include // for vector #include "input.h" // for inputs_e, INPUT_USE_ANY, INPUT_... #include "lang.h" // for lang_e -#include "screen.h" // for screenVideoMode, screenFilter +#include "screen.h" // for ScreenVideoMode, ScreenFilter #include "utils.h" // for op_controller_t, options_t, op_... - // Variables - options_t options; +// Variables +options_t options; // Declaraciones bool setOptions(std::string var, std::string value); @@ -20,13 +20,13 @@ void initOptions() { // Opciones de video #ifdef ANBERNIC - options.video.mode = screenVideoMode::WINDOW; + options.video.mode = ScreenVideoMode::WINDOW; options.video.window.size = 3; #else - options.video.mode = screenVideoMode::WINDOW; + options.video.mode = ScreenVideoMode::WINDOW; options.video.window.size = 2; #endif - options.video.filter = screenFilter::NEAREST; + options.video.filter = ScreenFilter::NEAREST; options.video.vSync = true; options.video.shaders = true; @@ -43,7 +43,7 @@ void initOptions() options.audio.sound.volume = 64; // Opciones de juego - options.game.difficulty = gameDifficulty::NORMAL; + options.game.difficulty = GameDifficulty::NORMAL; options.game.language = lang::ba_BA; options.game.autofire = true; @@ -132,11 +132,11 @@ bool loadOptionsFile(std::string filePath) } // Normaliza los valores - const bool a = options.video.mode == screenVideoMode::WINDOW; - const bool b = options.video.mode == screenVideoMode::FULLSCREEN; + const bool a = options.video.mode == ScreenVideoMode::WINDOW; + const bool b = options.video.mode == ScreenVideoMode::FULLSCREEN; if (!(a || b)) { - options.video.mode = screenVideoMode::WINDOW; + options.video.mode = ScreenVideoMode::WINDOW; } if (options.video.window.size < 1 || options.video.window.size > 4) @@ -171,10 +171,10 @@ bool saveOptionsFile(std::string filePath) #endif // Opciones de video - const auto valueVideoModeWinow = std::to_string(static_cast(screenVideoMode::WINDOW)); - const auto valueVideoModeFullscreen = std::to_string(static_cast(screenVideoMode::FULLSCREEN)); - const auto valueFilterNearest = std::to_string(static_cast(screenFilter::NEAREST)); - const auto valueFilterLineal = std::to_string(static_cast(screenFilter::LINEAL)); + const auto valueVideoModeWinow = std::to_string(static_cast(ScreenVideoMode::WINDOW)); + const auto valueVideoModeFullscreen = std::to_string(static_cast(ScreenVideoMode::FULLSCREEN)); + const auto valueFilterNearest = std::to_string(static_cast(ScreenFilter::NEAREST)); + const auto valueFilterLineal = std::to_string(static_cast(ScreenFilter::LINEAL)); file << "## VIDEO\n"; file << "## video.mode [" << valueVideoModeWinow << ": window, " << valueVideoModeFullscreen << ": fullscreen]\n"; @@ -236,9 +236,9 @@ bool saveOptionsFile(std::string filePath) file << "audio.sound.volume=" + std::to_string(options.audio.sound.volume) + "\n"; // Opciones del juego - const auto valueDifficultyEasy = std::to_string(static_cast(gameDifficulty::EASY)); - const auto valueDifficultyNormal = std::to_string(static_cast(gameDifficulty::NORMAL)); - const auto valueDifficultyHard = std::to_string(static_cast(gameDifficulty::HARD)); + const auto valueDifficultyEasy = std::to_string(static_cast(GameDifficulty::EASY)); + const auto valueDifficultyNormal = std::to_string(static_cast(GameDifficulty::NORMAL)); + const auto valueDifficultyHard = std::to_string(static_cast(GameDifficulty::HARD)); file << "\n\n## GAME\n"; file << "## game.language [0: spanish, 1: valencian, 2: english]\n"; file << "## game.difficulty [" << valueDifficultyEasy << ": easy, " << valueDifficultyNormal << ": normal, " << valueDifficultyHard << ": hard]\n"; @@ -285,8 +285,8 @@ bool setOptions(std::string var, std::string value) // Opciones de video if (var == "video.mode") { - // options.video.mode = value == std::to_string(static_cast(screenVideoMode::WINDOW)) ? screenVideoMode::WINDOW : screenVideoMode::FULLSCREEN; - options.video.mode = static_cast(std::stoi(value)); + // options.video.mode = value == std::to_string(static_cast(ScreenVideoMode::WINDOW)) ? ScreenVideoMode::WINDOW : ScreenVideoMode::FULLSCREEN; + options.video.mode = static_cast(std::stoi(value)); } else if (var == "video.window.size") @@ -300,8 +300,8 @@ bool setOptions(std::string var, std::string value) else if (var == "video.filter") { - // options.video.filter = value == std::to_string(static_cast(screenFilter::NEAREST)) ? screenFilter::NEAREST : screenFilter::LINEAL; - options.video.filter = static_cast(std::stoi(value)); + // options.video.filter = value == std::to_string(static_cast(ScreenFilter::NEAREST)) ? ScreenFilter::NEAREST : ScreenFilter::LINEAL; + options.video.filter = static_cast(std::stoi(value)); } else if (var == "video.shaders") @@ -370,7 +370,7 @@ bool setOptions(std::string var, std::string value) else if (var == "game.difficulty") { - options.game.difficulty = static_cast(std::stoi(value)); + options.game.difficulty = static_cast(std::stoi(value)); } else if (var == "game.autofire") diff --git a/source/player.cpp b/source/player.cpp index daf56df..9b88aa6 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -33,7 +33,7 @@ Player::Player(int id, float x, int y, bool demo, SDL_Rect *playArea, std::vecto // Inicializa variables this->id = id; this->demo = demo; - statusPlaying = playerStatus::WAITING; + statusPlaying = PlayerStatus::WAITING; scoreBoardPanel = 0; name = ""; setRecordName(enterName->getName()); @@ -46,8 +46,8 @@ void Player::init() // Inicializa variables de estado posX = defaultPosX; posY = defaultPosY; - statusWalking = playerStatus::WALKING_STOP; - statusFiring = playerStatus::FIRING_NO; + statusWalking = PlayerStatus::WALKING_STOP; + statusFiring = PlayerStatus::FIRING_NO; invulnerable = true; invulnerableCounter = PLAYER_INVULNERABLE_COUNTER; powerUp = false; @@ -81,11 +81,11 @@ void Player::setInput(int input) { switch (statusPlaying) { - case playerStatus::PLAYING: + case PlayerStatus::PLAYING: setInputPlaying(input); break; - case playerStatus::ENTERING_NAME: + case PlayerStatus::ENTERING_NAME: setInputEnteringName(input); break; @@ -101,29 +101,29 @@ void Player::setInputPlaying(int input) { case input_left: velX = -baseSpeed; - setWalkingStatus(playerStatus::WALKING_LEFT); + setWalkingStatus(PlayerStatus::WALKING_LEFT); break; case input_right: velX = baseSpeed; - setWalkingStatus(playerStatus::WALKING_RIGHT); + setWalkingStatus(PlayerStatus::WALKING_RIGHT); break; case input_fire_center: - setFiringStatus(playerStatus::FIRING_UP); + setFiringStatus(PlayerStatus::FIRING_UP); break; case input_fire_left: - setFiringStatus(playerStatus::FIRING_LEFT); + setFiringStatus(PlayerStatus::FIRING_LEFT); break; case input_fire_right: - setFiringStatus(playerStatus::FIRING_RIGHT); + setFiringStatus(PlayerStatus::FIRING_RIGHT); break; default: velX = 0; - setWalkingStatus(playerStatus::WALKING_STOP); + setWalkingStatus(PlayerStatus::WALKING_STOP); break; } } @@ -198,7 +198,7 @@ void Player::move() // Si el cadaver abandona el area de juego por abajo if (playerSprite->getPosY() > param.game.playArea.rect.h) { - setStatusPlaying(playerStatus::DIED); + setStatusPlaying(PlayerStatus::DIED); } } } @@ -219,7 +219,7 @@ void Player::render() } // Establece el estado del jugador cuando camina -void Player::setWalkingStatus(playerStatus status) +void Player::setWalkingStatus(PlayerStatus status) { // Si cambiamos de estado, reiniciamos la animación if (statusWalking != status) @@ -229,7 +229,7 @@ void Player::setWalkingStatus(playerStatus status) } // Establece el estado del jugador cuando dispara -void Player::setFiringStatus(playerStatus status) +void Player::setFiringStatus(PlayerStatus status) { // Si cambiamos de estado, reiniciamos la animación if (statusFiring != status) @@ -242,16 +242,16 @@ void Player::setFiringStatus(playerStatus status) void Player::setAnimation() { // Crea cadenas de texto para componer el nombre de la animación - const std::string aWalking = statusWalking == playerStatus::WALKING_STOP ? "stand" : "walk"; - const std::string aFiring = statusFiring == playerStatus::FIRING_UP ? "centershoot" : "sideshoot"; + const std::string aWalking = statusWalking == PlayerStatus::WALKING_STOP ? "stand" : "walk"; + const std::string aFiring = statusFiring == PlayerStatus::FIRING_UP ? "centershoot" : "sideshoot"; - const SDL_RendererFlip flipWalk = statusWalking == playerStatus::WALKING_RIGHT ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; - const SDL_RendererFlip flipFire = statusFiring == playerStatus::FIRING_RIGHT ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; + const SDL_RendererFlip flipWalk = statusWalking == PlayerStatus::WALKING_RIGHT ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; + const SDL_RendererFlip flipFire = statusFiring == PlayerStatus::FIRING_RIGHT ? SDL_FLIP_HORIZONTAL : SDL_FLIP_NONE; // Establece la animación a partir de las cadenas if (isPlaying()) { - if (statusFiring == playerStatus::FIRING_NO) + if (statusFiring == PlayerStatus::FIRING_NO) { // No esta disparando playerSprite->setCurrentAnimation(aWalking); playerSprite->setFlip(flipWalk); @@ -326,7 +326,7 @@ void Player::updateCooldown() } else { - setFiringStatus(playerStatus::FIRING_NO); + setFiringStatus(PlayerStatus::FIRING_NO); } } @@ -367,43 +367,43 @@ void Player::addScore(int score) // Indica si el jugador está jugando bool Player::isPlaying() const { - return statusPlaying == playerStatus::PLAYING; + return statusPlaying == PlayerStatus::PLAYING; } // Indica si el jugador está continuando bool Player::isContinue() const { - return statusPlaying == playerStatus::CONTINUE; + return statusPlaying == PlayerStatus::CONTINUE; } // Indica si el jugador está esperando bool Player::isWaiting() const { - return statusPlaying == playerStatus::WAITING; + return statusPlaying == PlayerStatus::WAITING; } // Indica si el jugador está introduciendo su nombre bool Player::isEnteringName() const { - return statusPlaying == playerStatus::ENTERING_NAME; + return statusPlaying == PlayerStatus::ENTERING_NAME; } // Indica si el jugador está muriendose bool Player::isDying() const { - return statusPlaying == playerStatus::DYING; + return statusPlaying == PlayerStatus::DYING; } // Indica si el jugador ha terminado de morir bool Player::hasDied() const { - return statusPlaying == playerStatus::DIED; + return statusPlaying == PlayerStatus::DIED; } // Indica si el jugador ya ha terminado de jugar bool Player::isGameOver() const { - return statusPlaying == playerStatus::GAME_OVER; + return statusPlaying == PlayerStatus::GAME_OVER; } // Actualiza el panel del marcador @@ -412,13 +412,13 @@ void Player::updateScoreboard() switch (statusPlaying) { - case playerStatus::CONTINUE: + case PlayerStatus::CONTINUE: { Scoreboard::get()->setContinue(getScoreBoardPanel(), getContinueCounter()); break; } - case playerStatus::ENTERING_NAME: + case PlayerStatus::ENTERING_NAME: { Scoreboard::get()->setRecordName(getScoreBoardPanel(), getRecordName()); Scoreboard::get()->setSelectorPos(getScoreBoardPanel(), getRecordNamePos()); @@ -431,7 +431,7 @@ void Player::updateScoreboard() } // Cambia el modo del marcador -void Player::setScoreboardMode(scoreboardMode mode) +void Player::setScoreboardMode(ScoreboardMode mode) { if (!demo) { @@ -440,43 +440,43 @@ void Player::setScoreboardMode(scoreboardMode mode) } // Establece el estado del jugador en el juego -void Player::setStatusPlaying(playerStatus value) +void Player::setStatusPlaying(PlayerStatus value) { statusPlaying = value; switch (statusPlaying) { - case playerStatus::PLAYING: + case PlayerStatus::PLAYING: { - statusPlaying = playerStatus::PLAYING; + statusPlaying = PlayerStatus::PLAYING; init(); - setScoreboardMode(scoreboardMode::SCORE); + setScoreboardMode(ScoreboardMode::SCORE); break; } - case playerStatus::CONTINUE: + case PlayerStatus::CONTINUE: { // Inicializa el contador de continuar continueTicks = SDL_GetTicks(); continueCounter = 9; enterName->init(); - setScoreboardMode(scoreboardMode::CONTINUE); + setScoreboardMode(ScoreboardMode::CONTINUE); break; } - case playerStatus::WAITING: + case PlayerStatus::WAITING: { - setScoreboardMode(scoreboardMode::WAITING); + setScoreboardMode(ScoreboardMode::WAITING); break; } - case playerStatus::ENTERING_NAME: + case PlayerStatus::ENTERING_NAME: { - setScoreboardMode(scoreboardMode::ENTER_NAME); + setScoreboardMode(ScoreboardMode::ENTER_NAME); break; } - case playerStatus::DYING: + case PlayerStatus::DYING: { // Activa la animación de morir playerSprite->setAccelY(0.2f); @@ -485,16 +485,16 @@ void Player::setStatusPlaying(playerStatus value) break; } - case playerStatus::DIED: + case PlayerStatus::DIED: { - const auto nextPlayerStatus = IsEligibleForHighScore() ? playerStatus::ENTERING_NAME : playerStatus::CONTINUE; - demo ? setStatusPlaying(playerStatus::WAITING) : setStatusPlaying(nextPlayerStatus); + const auto nextPlayerStatus = IsEligibleForHighScore() ? PlayerStatus::ENTERING_NAME : PlayerStatus::CONTINUE; + demo ? setStatusPlaying(PlayerStatus::WAITING) : setStatusPlaying(nextPlayerStatus); break; } - case playerStatus::GAME_OVER: + case PlayerStatus::GAME_OVER: { - setScoreboardMode(scoreboardMode::GAME_OVER); + setScoreboardMode(ScoreboardMode::GAME_OVER); break; } @@ -504,7 +504,7 @@ void Player::setStatusPlaying(playerStatus value) } // Obtiene el estado del jugador en el juego -playerStatus Player::getStatusPlaying() const +PlayerStatus Player::getStatusPlaying() const { return statusPlaying; } @@ -694,7 +694,7 @@ int Player::getContinueCounter() const // Actualiza el contador de continue void Player::updateContinueCounter() { - if (statusPlaying == playerStatus::CONTINUE) + if (statusPlaying == PlayerStatus::CONTINUE) { const Uint32 ticksSpeed = 1000; @@ -724,7 +724,7 @@ void Player::decContinueCounter() continueCounter--; if (continueCounter < 0) { - setStatusPlaying(playerStatus::GAME_OVER); + setStatusPlaying(PlayerStatus::GAME_OVER); } } diff --git a/source/player.h b/source/player.h index a2aa46c..4878098 100644 --- a/source/player.h +++ b/source/player.h @@ -9,10 +9,10 @@ #include "enter_name.h" // for EnterName #include "utils.h" // for circle_t class Texture; // lines 12-12 -enum class scoreboardMode; +enum class ScoreboardMode; // Estados del jugador -enum class playerStatus +enum class PlayerStatus { WALKING_LEFT, WALKING_RIGHT, @@ -60,9 +60,9 @@ private: int cooldown; // Contador durante el cual no puede disparar int score; // Puntos del jugador float scoreMultiplier; // Multiplicador de puntos - playerStatus statusWalking; // Estado del jugador al moverse - playerStatus statusFiring; // Estado del jugador al disparar - playerStatus statusPlaying; // Estado del jugador en el juego + PlayerStatus statusWalking; // Estado del jugador al moverse + PlayerStatus statusFiring; // Estado del jugador al disparar + PlayerStatus statusPlaying; // Estado del jugador en el juego bool invulnerable; // Indica si el jugador es invulnerable int invulnerableCounter; // Contador para la invulnerabilidad bool extraHit; // Indica si el jugador tiene un toque extra @@ -99,7 +99,7 @@ private: bool IsEligibleForHighScore(); // Cambia el modo del marcador - void setScoreboardMode(scoreboardMode mode); + void setScoreboardMode(ScoreboardMode mode); public: // Constructor @@ -133,10 +133,10 @@ public: void move(); // Establece el estado del jugador - void setWalkingStatus(playerStatus status); + void setWalkingStatus(PlayerStatus status); // Establece el estado del jugador - void setFiringStatus(playerStatus status); + void setFiringStatus(PlayerStatus status); // Establece la animación correspondiente al estado void setAnimation(); @@ -193,10 +193,10 @@ public: bool isGameOver() const; // Establece el estado del jugador en el juego - void setStatusPlaying(playerStatus value); + void setStatusPlaying(PlayerStatus value); // Obtiene el estado del jugador en el juego - playerStatus getStatusPlaying() const; + PlayerStatus getStatusPlaying() const; // Obtiene el valor de la variable float getScoreMultiplier() const; diff --git a/source/scoreboard.cpp b/source/scoreboard.cpp index 949d281..cc428ce 100644 --- a/source/scoreboard.cpp +++ b/source/scoreboard.cpp @@ -54,9 +54,9 @@ Scoreboard::Scoreboard(SDL_Renderer *renderer) : renderer(renderer) hiScoreName = ""; color = {0, 0, 0}; rect = {0, 0, 320, 40}; - panel[SCOREBOARD_LEFT_PANEL].mode = scoreboardMode::SCORE; - panel[SCOREBOARD_RIGHT_PANEL].mode = scoreboardMode::SCORE; - panel[SCOREBOARD_CENTER_PANEL].mode = scoreboardMode::STAGE_INFO; + panel[SCOREBOARD_LEFT_PANEL].mode = ScoreboardMode::SCORE; + panel[SCOREBOARD_RIGHT_PANEL].mode = ScoreboardMode::SCORE; + panel[SCOREBOARD_CENTER_PANEL].mode = ScoreboardMode::STAGE_INFO; ticks = SDL_GetTicks(); counter = 0; @@ -262,7 +262,7 @@ void Scoreboard::fillPanelTextures() switch (panel[i].mode) { - case scoreboardMode::SCORE: + case ScoreboardMode::SCORE: { // SCORE textScoreBoard->writeCentered(slot4_1.x, slot4_1.y, name[i]); @@ -274,7 +274,7 @@ void Scoreboard::fillPanelTextures() break; } - case scoreboardMode::DEMO: + case ScoreboardMode::DEMO: { // DEMO MODE textScoreBoard->writeCentered(slot4_1.x, slot4_1.y + 4, lang::getText(101)); @@ -288,7 +288,7 @@ void Scoreboard::fillPanelTextures() break; } - case scoreboardMode::WAITING: + case ScoreboardMode::WAITING: { // GAME OVER textScoreBoard->writeCentered(slot4_1.x, slot4_1.y + 4, lang::getText(102)); @@ -302,7 +302,7 @@ void Scoreboard::fillPanelTextures() break; } - case scoreboardMode::GAME_OVER: + case ScoreboardMode::GAME_OVER: { // GAME OVER textScoreBoard->writeCentered(slot4_1.x, slot4_1.y + 4, lang::getText(102)); @@ -316,7 +316,7 @@ void Scoreboard::fillPanelTextures() break; } - case scoreboardMode::STAGE_INFO: + case ScoreboardMode::STAGE_INFO: { // STAGE textScoreBoard->writeCentered(slot4_1.x, slot4_1.y, lang::getText(57) + std::to_string(stage)); @@ -333,7 +333,7 @@ void Scoreboard::fillPanelTextures() break; } - case scoreboardMode::CONTINUE: + case ScoreboardMode::CONTINUE: { // SCORE textScoreBoard->writeCentered(slot4_1.x, slot4_1.y, name[i]); @@ -345,7 +345,7 @@ void Scoreboard::fillPanelTextures() break; } - case scoreboardMode::ENTER_NAME: + case ScoreboardMode::ENTER_NAME: { // SCORE textScoreBoard->writeCentered(slot4_1.x, slot4_1.y, name[i]); @@ -457,7 +457,7 @@ void Scoreboard::recalculateAnchors() } // Establece el modo del marcador -void Scoreboard::setMode(int index, scoreboardMode mode) +void Scoreboard::setMode(int index, ScoreboardMode mode) { panel[index].mode = mode; } diff --git a/source/scoreboard.h b/source/scoreboard.h index 394b4b3..7004255 100644 --- a/source/scoreboard.h +++ b/source/scoreboard.h @@ -19,7 +19,7 @@ constexpr int SCOREBOARD_MAX_PANELS = 3; constexpr int SCOREBOARD_TICK_SPEED = 100; // Enums -enum class scoreboardMode +enum class ScoreboardMode { SCORE, STAGE_INFO, @@ -34,7 +34,7 @@ enum class scoreboardMode // Structs struct panel_t { - scoreboardMode mode; // Modo en el que se encuentra el panel + ScoreboardMode mode; // Modo en el que se encuentra el panel SDL_Rect pos; // Posición donde dibujar el panel dentro del marcador }; @@ -161,5 +161,5 @@ public: void setPos(SDL_Rect rect); // Establece el modo del marcador - void setMode(int index, scoreboardMode mode); + void setMode(int index, ScoreboardMode mode); }; diff --git a/source/screen.cpp b/source/screen.cpp index 2257d60..a327217 100644 --- a/source/screen.cpp +++ b/source/screen.cpp @@ -184,16 +184,16 @@ void Screen::blit() } // Establece el modo de video -void Screen::setVideoMode(screenVideoMode videoMode) +void Screen::setVideoMode(ScreenVideoMode videoMode) { options.video.mode = videoMode; #ifdef ARCADE - options.video.mode = screenVideoMode::WINDOW; + options.video.mode = ScreenVideoMode::WINDOW; #endif switch (options.video.mode) { - case screenVideoMode::WINDOW: + case ScreenVideoMode::WINDOW: { // Cambia a modo de ventana SDL_SetWindowFullscreen(window, 0); @@ -213,7 +213,7 @@ void Screen::setVideoMode(screenVideoMode videoMode) } // Si está activo el modo de pantalla completa añade el borde - case screenVideoMode::FULLSCREEN: + case ScreenVideoMode::FULLSCREEN: { // Aplica el modo de video SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); @@ -245,7 +245,7 @@ void Screen::setVideoMode(screenVideoMode videoMode) // Camibia entre pantalla completa y ventana void Screen::switchVideoMode() { - options.video.mode = options.video.mode == screenVideoMode::WINDOW ? screenVideoMode::FULLSCREEN : screenVideoMode::WINDOW; + options.video.mode = options.video.mode == ScreenVideoMode::WINDOW ? ScreenVideoMode::FULLSCREEN : ScreenVideoMode::WINDOW; setVideoMode(options.video.mode); } @@ -253,7 +253,7 @@ void Screen::switchVideoMode() void Screen::setWindowSize(int size) { options.video.window.size = size; - setVideoMode(screenVideoMode::WINDOW); + setVideoMode(ScreenVideoMode::WINDOW); } // Reduce el tamaño de la ventana @@ -261,7 +261,7 @@ void Screen::decWindowSize() { --options.video.window.size; options.video.window.size = std::max(options.video.window.size, 1); - setVideoMode(screenVideoMode::WINDOW); + setVideoMode(ScreenVideoMode::WINDOW); } // Aumenta el tamaño de la ventana @@ -269,7 +269,7 @@ void Screen::incWindowSize() { ++options.video.window.size; options.video.window.size = std::min(options.video.window.size, 4); - setVideoMode(screenVideoMode::WINDOW); + setVideoMode(ScreenVideoMode::WINDOW); } // Cambia el color del borde @@ -301,7 +301,7 @@ void Screen::checkInput() if (input->checkInput(input_window_fullscreen, INPUT_DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD)) { switchVideoMode(); - const std::string mode = options.video.mode == screenVideoMode::WINDOW ? "Window" : "Fullscreen"; + const std::string mode = options.video.mode == ScreenVideoMode::WINDOW ? "Window" : "Fullscreen"; showNotification(mode + " mode"); return; } diff --git a/source/screen.h b/source/screen.h index f673661..0597671 100644 --- a/source/screen.h +++ b/source/screen.h @@ -12,13 +12,13 @@ class Asset; class Input; class Notify; -enum class screenFilter +enum class ScreenFilter { NEAREST = 0, LINEAL = 1, }; -enum class screenVideoMode +enum class ScreenVideoMode { WINDOW = 0, FULLSCREEN = 1, @@ -122,7 +122,7 @@ public: void blit(); // Establece el modo de video - void setVideoMode(screenVideoMode videoMode); + void setVideoMode(ScreenVideoMode videoMode); // Camibia entre pantalla completa y ventana void switchVideoMode(); diff --git a/source/title.cpp b/source/title.cpp index 08a002c..653a389 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -59,7 +59,7 @@ void Title::init() ticks = 0; ticksSpeed = 15; fade->setColor(fadeColor.r, fadeColor.g, fadeColor.b); - fade->setType(fadeType::RANDOM_SQUARE); + fade->setType(FadeType::RANDOM_SQUARE); fade->setPost(param.fade.postDuration); demo = true; numControllers = input->getNumControllers(); diff --git a/source/utils.h b/source/utils.h index f36e1f3..8d875e9 100644 --- a/source/utils.h +++ b/source/utils.h @@ -10,11 +10,11 @@ #include "input.h" // for inputs_e struct JA_Music_t; struct JA_Sound_t; -enum class screenFilter; -enum class screenVideoMode; +enum class ScreenFilter; +enum class ScreenVideoMode; // Dificultad del juego -enum class gameDifficulty +enum class GameDifficulty { EASY = 0, NORMAL = 1, @@ -105,8 +105,8 @@ struct op_window_t struct op_video_t { op_window_t window; // Opciones para la ventana del programa - screenVideoMode mode; // Contiene el valor del modo de pantalla completa - screenFilter filter; // Filtro usado para el escalado de la imagen + ScreenVideoMode mode; // Contiene el valor del modo de pantalla completa + ScreenFilter filter; // Filtro usado para el escalado de la imagen bool vSync; // Indica si se quiere usar vsync o no bool shaders; // Indica si se van a usar shaders para los filtros de video }; @@ -135,7 +135,7 @@ struct op_audio_t // Estructura para las opciones del juego struct op_game_t { - gameDifficulty difficulty; // Dificultad del juego + GameDifficulty difficulty; // Dificultad del juego Uint8 language; // Idioma usado en el juego bool autofire; // Indica si el jugador ha de pulsar repetidamente para disparar o basta con mantener pulsado std::vector hiScoreTable; // Tabla con las mejores puntuaciones @@ -197,12 +197,12 @@ struct paramGame_t // param.fade struct paramFade_t { - int numSquaresWidth; // Cantidad total de cuadraditos en horizontal para el fadeType::RANDOM_SQUARE - int numSquaresHeight; // Cantidad total de cuadraditos en vertical para el fadeType::RANDOM_SQUARE + int numSquaresWidth; // Cantidad total de cuadraditos en horizontal para el FadeType::RANDOM_SQUARE + int numSquaresHeight; // Cantidad total de cuadraditos en vertical para el FadeType::RANDOM_SQUARE int randomSquaresDelay; // Duración entre cada pintado de cuadrados int randomSquaresMult; // Cantidad de cuadrados que se pintaran cada vez int postDuration; // Duración final del fade - int venetianSize; // Altura de los rectangulos para fadeType::VENETIAN + int venetianSize; // Altura de los rectangulos para FadeType::VENETIAN }; // param.title