From 18cd2878084ab17000af1f496a4ae606a0b2ca19 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sat, 16 May 2026 15:12:28 +0200 Subject: [PATCH] treball en curs: correccions de tidy --- source/game/entities/balloon.h | 64 +-- source/game/game.cpp | 845 ++++++++++++++++----------------- source/game/game.h | 170 +++---- source/game/scenes/title.cpp | 17 +- source/game/scenes/title.h | 40 +- 5 files changed, 558 insertions(+), 578 deletions(-) diff --git a/source/game/entities/balloon.h b/source/game/entities/balloon.h index ee2cd8c..57547cb 100644 --- a/source/game/entities/balloon.h +++ b/source/game/entities/balloon.h @@ -61,7 +61,7 @@ class Balloon { static constexpr int POWERBALL_COUNTER = 8; Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer, Texture *texture, std::vector *animation, SDL_Renderer *renderer); // Constructor - ~Balloon(); // Destructor + ~Balloon(); // Destructor Balloon(const Balloon &) = delete; auto operator=(const Balloon &) -> Balloon & = delete; @@ -73,35 +73,35 @@ class Balloon { void pop(); // Explosiona el globo void update(); // Actualiza al globo a su posicion, animación y controla los contadores - [[nodiscard]] auto isEnabled() const -> bool; // Comprueba si el globo está habilitado - [[nodiscard]] auto isStopped() const -> bool; // Obtiene del valor de la variable - [[nodiscard]] auto isBlinking() const -> bool; // Obtiene del valor de la variable - [[nodiscard]] auto isVisible() const -> bool; // Obtiene del valor de la variable - [[nodiscard]] auto isInvulnerable() const -> bool; // Obtiene del valor de la variable - [[nodiscard]] auto isBeingCreated() const -> bool; // Obtiene del valor de la variable - [[nodiscard]] auto isPopping() const -> bool; // Obtiene del valor de la variable + [[nodiscard]] auto isEnabled() const -> bool; // Comprueba si el globo está habilitado + [[nodiscard]] auto isStopped() const -> bool; // Obtiene del valor de la variable + [[nodiscard]] auto isBlinking() const -> bool; // Obtiene del valor de la variable + [[nodiscard]] auto isVisible() const -> bool; // Obtiene del valor de la variable + [[nodiscard]] auto isInvulnerable() const -> bool; // Obtiene del valor de la variable + [[nodiscard]] auto isBeingCreated() const -> bool; // Obtiene del valor de la variable + [[nodiscard]] auto isPopping() const -> bool; // Obtiene del valor de la variable - [[nodiscard]] auto getPosX() const -> float; // Obtiene del valor de la variable - [[nodiscard]] auto getPosY() const -> float; // Obtiene del valor de la variable - [[nodiscard]] auto getVelY() const -> float; // Obtiene del valor de la variable - [[nodiscard]] auto getWidth() const -> int; // Obtiene del valor de la variable - [[nodiscard]] auto getHeight() const -> int; // Obtiene del valor de la variable - [[nodiscard]] auto getKind() const -> int; // Obtiene del valor de la variable - [[nodiscard]] auto getSize() const -> Uint8; // Obtiene del valor de la variable - [[nodiscard]] auto getClass() const -> Uint8; // Obtiene la clase a la que pertenece el globo + [[nodiscard]] auto getPosX() const -> float; // Obtiene del valor de la variable + [[nodiscard]] auto getPosY() const -> float; // Obtiene del valor de la variable + [[nodiscard]] auto getVelY() const -> float; // Obtiene del valor de la variable + [[nodiscard]] auto getWidth() const -> int; // Obtiene del valor de la variable + [[nodiscard]] auto getHeight() const -> int; // Obtiene del valor de la variable + [[nodiscard]] auto getKind() const -> int; // Obtiene del valor de la variable + [[nodiscard]] auto getSize() const -> Uint8; // Obtiene del valor de la variable + [[nodiscard]] auto getClass() const -> Uint8; // Obtiene la clase a la que pertenece el globo [[nodiscard]] auto getStoppedTimer() const -> Uint16; // Obtiene del valor de la variable - [[nodiscard]] auto getScore() const -> Uint16; // Obtiene del valor de la variable - [[nodiscard]] auto getMenace() const -> Uint8; // Obtiene le valor de la variable - [[nodiscard]] auto getPower() const -> Uint8; // Obtiene le valor de la variable + [[nodiscard]] auto getScore() const -> Uint16; // Obtiene del valor de la variable + [[nodiscard]] auto getMenace() const -> Uint8; // Obtiene le valor de la variable + [[nodiscard]] auto getPower() const -> Uint8; // Obtiene le valor de la variable - void setVelY(float vel_y); // Establece el valor de la variable - void setSpeed(float speed); // Establece el valor de la variable - void setStop(bool state); // Establece el valor de la variable - void setBlink(bool value); // Establece el valor de la variable - void setVisible(bool value); // Establece el valor de la variable - void setInvulnerable(bool value); // Establece el valor de la variable - void setPopping(bool value); // Establece el valor de la variable - void setStoppedTimer(Uint16 time); // Establece el valor de la variable + void setVelY(float vel_y); // Establece el valor de la variable + void setSpeed(float speed); // Establece el valor de la variable + void setStop(bool state); // Establece el valor de la variable + void setBlink(bool value); // Establece el valor de la variable + void setVisible(bool value); // Establece el valor de la variable + void setInvulnerable(bool value); // Establece el valor de la variable + void setPopping(bool value); // Establece el valor de la variable + void setStoppedTimer(Uint16 time); // Establece el valor de la variable auto getCollider() -> Circle &; // Obtiene el circulo de colisión @@ -156,11 +156,11 @@ class Balloon { Uint8 power_; // Cantidad de poder que alberga el globo Bouncing bouncing_; // Contiene las variables para el efecto de rebote - void updateColliders(); // Alinea el circulo de colisión con la posición del objeto globo - void bounceStart(); // Activa el efecto - void bounceStop(); // Detiene el efecto - void updateBounce(); // Aplica el efecto - void updateAnimation(); // Establece la animación correspondiente + void updateColliders(); // Alinea el circulo de colisión con la posición del objeto globo + void bounceStart(); // Activa el efecto + void bounceStop(); // Detiene el efecto + void updateBounce(); // Aplica el efecto + void updateAnimation(); // Establece la animación correspondiente void setBeingCreated(bool value); // Establece el valor de la variable void updateState(); // Actualiza los estados del globo diff --git a/source/game/game.cpp b/source/game/game.cpp index 0156682..177450b 100644 --- a/source/game/game.cpp +++ b/source/game/game.cpp @@ -4,7 +4,6 @@ #include // for max, min #include // for rand -#include // for basic_ifstream #include // for basic_ostream, char_traits, operator<< #include // for accumulate @@ -31,22 +30,22 @@ struct JA_Sound_t; // Constructor -Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, bool demo, Section *section) - : last_stage_reached_(currentStage) { +Game::Game(int num_players, int current_stage, SDL_Renderer *renderer, bool demo, Section *section) + : last_stage_reached_(current_stage) { // Copia los punteros this->renderer_ = renderer; this->section_ = section; // Pasa variables this->demo_.enabled = demo; - this->num_players_ = numPlayers; + this->num_players_ = num_players; #ifdef PAUSE this->currentStage = 3; #else - this->current_stage_ = currentStage; + this->current_stage_ = current_stage; #endif - if (numPlayers == 1) { // Si solo juega un jugador, permite jugar tanto con teclado como con mando - one_player_control_ = Options::inputs[0].deviceType; + if (num_players == 1) { // Si solo juega un jugador, permite jugar tanto con teclado como con mando + player_one_control_ = Options::inputs[0].deviceType; Options::inputs[0].deviceType = INPUT_USE_ANY; } difficulty_ = Options::settings.difficulty; @@ -94,7 +93,7 @@ Game::~Game() { // Restaura el metodo de control if (num_players_ == 1) { - Options::inputs[0].deviceType = one_player_control_; + Options::inputs[0].deviceType = player_one_control_; } // Elimina todos los objetos contenidos en vectores (jugadores, balas, etc.) @@ -226,8 +225,8 @@ void Game::init() { game_over_post_fade_ = 0; if (demo_.enabled) { - const int num = rand() % 2; - if (num == 0) { + const int NUM = rand() % 2; + if (NUM == 0) { balloons_popped_ = 1000; current_stage_ = 3; } else { @@ -330,106 +329,106 @@ void Game::loadMedia() { << "** LOADING RESOURCES FOR GAME SECTION" << '\n'; } - Resource *R = Resource::get(); + Resource *resource = Resource::get(); // Texturas (handles compartidos — no se liberan aquí) - bullet_texture_ = R->getTexture("bullet.png"); - game_buildings_texture_ = R->getTexture("game_buildings.png"); - game_clouds_texture_ = R->getTexture("game_clouds.png"); - game_grass_texture_ = R->getTexture("game_grass.png"); - game_power_meter_texture_ = R->getTexture("game_power_meter.png"); - game_sky_colors_texture_ = R->getTexture("game_sky_colors.png"); - game_text_texture_ = R->getTexture("game_text.png"); - game_over_texture_ = R->getTexture("menu_game_over.png"); - game_over_end_texture_ = R->getTexture("menu_game_over_end.png"); + bullet_texture_ = resource->getTexture("bullet.png"); + game_buildings_texture_ = resource->getTexture("game_buildings.png"); + game_clouds_texture_ = resource->getTexture("game_clouds.png"); + game_grass_texture_ = resource->getTexture("game_grass.png"); + game_power_meter_texture_ = resource->getTexture("game_power_meter.png"); + game_sky_colors_texture_ = resource->getTexture("game_sky_colors.png"); + game_text_texture_ = resource->getTexture("game_text.png"); + game_over_texture_ = resource->getTexture("menu_game_over.png"); + game_over_end_texture_ = resource->getTexture("menu_game_over_end.png"); // Texturas - Globos - balloon_textures_.push_back(R->getTexture("balloon1.png")); - balloon_textures_.push_back(R->getTexture("balloon2.png")); - balloon_textures_.push_back(R->getTexture("balloon3.png")); - balloon_textures_.push_back(R->getTexture("balloon4.png")); + balloon_textures_.push_back(resource->getTexture("balloon1.png")); + balloon_textures_.push_back(resource->getTexture("balloon2.png")); + balloon_textures_.push_back(resource->getTexture("balloon3.png")); + balloon_textures_.push_back(resource->getTexture("balloon4.png")); // Texturas - Items - item_textures_.push_back(R->getTexture("item_points1_disk.png")); - item_textures_.push_back(R->getTexture("item_points2_gavina.png")); - item_textures_.push_back(R->getTexture("item_points3_pacmar.png")); - item_textures_.push_back(R->getTexture("item_clock.png")); - item_textures_.push_back(R->getTexture("item_coffee.png")); - item_textures_.push_back(R->getTexture("item_coffee_machine.png")); + item_textures_.push_back(resource->getTexture("item_points1_disk.png")); + item_textures_.push_back(resource->getTexture("item_points2_gavina.png")); + item_textures_.push_back(resource->getTexture("item_points3_pacmar.png")); + item_textures_.push_back(resource->getTexture("item_clock.png")); + item_textures_.push_back(resource->getTexture("item_coffee.png")); + item_textures_.push_back(resource->getTexture("item_coffee_machine.png")); // Texturas - Player1 - player1_textures_.push_back(R->getTexture("player_bal1_head.png")); - player1_textures_.push_back(R->getTexture("player_bal1_body.png")); - player1_textures_.push_back(R->getTexture("player_bal1_legs.png")); - player1_textures_.push_back(R->getTexture("player_bal1_death.png")); - player1_textures_.push_back(R->getTexture("player_bal1_fire.png")); + player1_textures_.push_back(resource->getTexture("player_bal1_head.png")); + player1_textures_.push_back(resource->getTexture("player_bal1_body.png")); + player1_textures_.push_back(resource->getTexture("player_bal1_legs.png")); + player1_textures_.push_back(resource->getTexture("player_bal1_death.png")); + player1_textures_.push_back(resource->getTexture("player_bal1_fire.png")); player_textures_.push_back(player1_textures_); // Texturas - Player2 - player2_textures_.push_back(R->getTexture("player_arounder_head.png")); - player2_textures_.push_back(R->getTexture("player_arounder_body.png")); - player2_textures_.push_back(R->getTexture("player_arounder_legs.png")); - player2_textures_.push_back(R->getTexture("player_arounder_death.png")); - player2_textures_.push_back(R->getTexture("player_arounder_fire.png")); + player2_textures_.push_back(resource->getTexture("player_arounder_head.png")); + player2_textures_.push_back(resource->getTexture("player_arounder_body.png")); + player2_textures_.push_back(resource->getTexture("player_arounder_legs.png")); + player2_textures_.push_back(resource->getTexture("player_arounder_death.png")); + player2_textures_.push_back(resource->getTexture("player_arounder_fire.png")); player_textures_.push_back(player2_textures_); // Animaciones (handles a los vectores raw de Resource — no se liberan) - player_animations_.push_back(&R->getAnimationLines("player_head.ani")); - player_animations_.push_back(&R->getAnimationLines("player_body.ani")); - player_animations_.push_back(&R->getAnimationLines("player_legs.ani")); - player_animations_.push_back(&R->getAnimationLines("player_death.ani")); - player_animations_.push_back(&R->getAnimationLines("player_fire.ani")); + player_animations_.push_back(&resource->getAnimationLines("player_head.ani")); + player_animations_.push_back(&resource->getAnimationLines("player_body.ani")); + player_animations_.push_back(&resource->getAnimationLines("player_legs.ani")); + player_animations_.push_back(&resource->getAnimationLines("player_death.ani")); + player_animations_.push_back(&resource->getAnimationLines("player_fire.ani")); - balloon_animations_.push_back(&R->getAnimationLines("balloon1.ani")); - balloon_animations_.push_back(&R->getAnimationLines("balloon2.ani")); - balloon_animations_.push_back(&R->getAnimationLines("balloon3.ani")); - balloon_animations_.push_back(&R->getAnimationLines("balloon4.ani")); + balloon_animations_.push_back(&resource->getAnimationLines("balloon1.ani")); + balloon_animations_.push_back(&resource->getAnimationLines("balloon2.ani")); + balloon_animations_.push_back(&resource->getAnimationLines("balloon3.ani")); + balloon_animations_.push_back(&resource->getAnimationLines("balloon4.ani")); - item_animations_.push_back(&R->getAnimationLines("item_points1_disk.ani")); - item_animations_.push_back(&R->getAnimationLines("item_points2_gavina.ani")); - item_animations_.push_back(&R->getAnimationLines("item_points3_pacmar.ani")); - item_animations_.push_back(&R->getAnimationLines("item_clock.ani")); - item_animations_.push_back(&R->getAnimationLines("item_coffee.ani")); - item_animations_.push_back(&R->getAnimationLines("item_coffee_machine.ani")); + item_animations_.push_back(&resource->getAnimationLines("item_points1_disk.ani")); + item_animations_.push_back(&resource->getAnimationLines("item_points2_gavina.ani")); + item_animations_.push_back(&resource->getAnimationLines("item_points3_pacmar.ani")); + item_animations_.push_back(&resource->getAnimationLines("item_clock.ani")); + item_animations_.push_back(&resource->getAnimationLines("item_coffee.ani")); + item_animations_.push_back(&resource->getAnimationLines("item_coffee_machine.ani")); // Texto - text_ = R->getText("smb2"); - text_scoreboard_ = R->getText("8bithud"); - text_big_ = R->getText("smb2_big"); - text_nokia2_ = R->getText("nokia2"); - text_nokia_big2_ = R->getText("nokia_big2"); + text_ = resource->getText("smb2"); + text_scoreboard_ = resource->getText("8bithud"); + text_big_ = resource->getText("smb2_big"); + text_nokia2_ = resource->getText("nokia2"); + text_nokia_big2_ = resource->getText("nokia_big2"); // Menus - game_over_menu_ = R->getMenu("gameover"); + game_over_menu_ = resource->getMenu("gameover"); game_over_menu_->setItemCaption(0, Lang::get()->getText(48)); game_over_menu_->setItemCaption(1, Lang::get()->getText(49)); - const int w = text_->getCharacterSize() * Lang::get()->getText(45).length(); - game_over_menu_->setRectSize(w, 0); + const int W = text_->getCharacterSize() * Lang::get()->getText(45).length(); + game_over_menu_->setRectSize(W, 0); game_over_menu_->centerMenuOnX(199); - pause_menu_ = R->getMenu("pause"); + pause_menu_ = resource->getMenu("pause"); pause_menu_->setItemCaption(0, Lang::get()->getText(41)); pause_menu_->setItemCaption(1, Lang::get()->getText(46)); pause_menu_->setItemCaption(2, Lang::get()->getText(47)); // Sonidos - balloon_sound_ = R->getSound("balloon.wav"); - bubble1_sound_ = R->getSound("bubble1.wav"); - bubble2_sound_ = R->getSound("bubble2.wav"); - bubble3_sound_ = R->getSound("bubble3.wav"); - bubble4_sound_ = R->getSound("bubble4.wav"); - bullet_sound_ = R->getSound("bullet.wav"); - clock_sound_ = R->getSound("clock.wav"); - coffee_out_sound_ = R->getSound("coffeeout.wav"); - hi_score_sound_ = R->getSound("hiscore.wav"); - item_drop_sound_ = R->getSound("itemdrop.wav"); - item_pick_up_sound_ = R->getSound("itempickup.wav"); - player_collision_sound_ = R->getSound("player_collision.wav"); - power_ball_sound_ = R->getSound("powerball.wav"); - stage_change_sound_ = R->getSound("stage_change.wav"); - coffee_machine_sound_ = R->getSound("title.wav"); + balloon_sound_ = resource->getSound("balloon.wav"); + bubble1_sound_ = resource->getSound("bubble1.wav"); + bubble2_sound_ = resource->getSound("bubble2.wav"); + bubble3_sound_ = resource->getSound("bubble3.wav"); + bubble4_sound_ = resource->getSound("bubble4.wav"); + bullet_sound_ = resource->getSound("bullet.wav"); + clock_sound_ = resource->getSound("clock.wav"); + coffee_out_sound_ = resource->getSound("coffeeout.wav"); + hi_score_sound_ = resource->getSound("hiscore.wav"); + item_drop_sound_ = resource->getSound("itemdrop.wav"); + item_pick_up_sound_ = resource->getSound("itempickup.wav"); + player_collision_sound_ = resource->getSound("player_collision.wav"); + power_ball_sound_ = resource->getSound("powerball.wav"); + stage_change_sound_ = resource->getSound("stage_change.wav"); + coffee_machine_sound_ = resource->getSound("title.wav"); // Musicas - game_music_ = R->getMusic("playing.ogg"); + game_music_ = resource->getMusic("playing.ogg"); if (Options::settings.console) { std::cout << "** RESOURCES FOR GAME SECTION LOADED" << '\n' @@ -441,21 +440,21 @@ void Game::loadMedia() { auto Game::loadScoreFile() -> bool { // Indicador de éxito en la carga bool success = true; - const std::string p = Asset::get()->get("score.bin"); - const std::string filename = p.substr(p.find_last_of("\\/") + 1); - SDL_IOStream *file = SDL_IOFromFile(p.c_str(), "r+b"); + const std::string P = Asset::get()->get("score.bin"); + const std::string FILE_NAME = P.substr(P.find_last_of("\\/") + 1); + SDL_IOStream *file = SDL_IOFromFile(P.c_str(), "r+b"); // El fichero no existe if (file == nullptr) { if (Options::settings.console) { - std::cout << "Warning: Unable to open " << filename.c_str() << " file" << '\n'; + std::cout << "Warning: Unable to open " << FILE_NAME.c_str() << " file" << '\n'; } // Creamos el fichero para escritura - file = SDL_IOFromFile(p.c_str(), "w+b"); + file = SDL_IOFromFile(P.c_str(), "w+b"); if (file != nullptr) { if (Options::settings.console) { - std::cout << "New file (" << filename.c_str() << ") created!" << '\n'; + std::cout << "New file (" << FILE_NAME.c_str() << ") created!" << '\n'; } // Inicializamos los datos @@ -468,7 +467,7 @@ auto Game::loadScoreFile() -> bool { SDL_CloseIO(file); } else { if (Options::settings.console) { - std::cout << "Error: Unable to create file " << filename.c_str() << '\n'; + std::cout << "Error: Unable to create file " << FILE_NAME.c_str() << '\n'; } success = false; } @@ -477,7 +476,7 @@ auto Game::loadScoreFile() -> bool { else { // Cargamos los datos if (Options::settings.console) { - std::cout << "Reading file " << filename.c_str() << '\n'; + std::cout << "Reading file " << FILE_NAME.c_str() << '\n'; } for (unsigned int &i : score_data_file_) { SDL_ReadIO(file, &i, sizeof(Uint32)); @@ -502,8 +501,8 @@ auto Game::loadScoreFile() -> bool { auto Game::loadDemoFile() -> bool { // Lee los datos de la demo desde Resource (precargados al arrancar). const auto &bytes = Resource::get()->getDemoBytes(); - const size_t expected = sizeof(DemoKeys) * TOTAL_DEMO_DATA; - if (bytes.size() >= expected) { + const size_t EXPECTED = sizeof(DemoKeys) * TOTAL_DEMO_DATA; + if (bytes.size() >= EXPECTED) { for (int i = 0; i < TOTAL_DEMO_DATA; ++i) { memcpy(&demo_.data_file[i], bytes.data() + (i * sizeof(DemoKeys)), sizeof(DemoKeys)); } @@ -531,9 +530,9 @@ auto Game::loadDemoFile() -> bool { // Guarda el fichero de puntos auto Game::saveScoreFile() -> bool { bool success = true; - const std::string p = Asset::get()->get("score.bin"); - const std::string filename = p.substr(p.find_last_of("\\/") + 1); - SDL_IOStream *file = SDL_IOFromFile(p.c_str(), "w+b"); + const std::string P = Asset::get()->get("score.bin"); + const std::string FILE_NAME = P.substr(P.find_last_of("\\/") + 1); + SDL_IOStream *file = SDL_IOFromFile(P.c_str(), "w+b"); if (file != nullptr) { // Guardamos los datos for (unsigned int &i : score_data_file_) { @@ -541,14 +540,14 @@ auto Game::saveScoreFile() -> bool { } if (Options::settings.console) { - std::cout << "Writing file " << filename.c_str() << '\n'; + std::cout << "Writing file " << FILE_NAME.c_str() << '\n'; } // Cerramos el fichero SDL_CloseIO(file); } else { if (Options::settings.console) { - std::cout << "Error: Unable to save " << filename.c_str() << " file! " << SDL_GetError() << '\n'; + std::cout << "Error: Unable to save " << FILE_NAME.c_str() << " file! " << SDL_GetError() << '\n'; } } return success; @@ -557,10 +556,10 @@ auto Game::saveScoreFile() -> bool { // Guarda el fichero de datos para la demo auto Game::saveDemoFile() -> bool { bool success = true; - const std::string p = Asset::get()->get("demo.bin"); - const std::string filename = p.substr(p.find_last_of("\\/") + 1); + const std::string P = Asset::get()->get("demo.bin"); + const std::string FILE_NAME = P.substr(P.find_last_of("\\/") + 1); if (demo_.recording) { - SDL_IOStream *file = SDL_IOFromFile(p.c_str(), "w+b"); + SDL_IOStream *file = SDL_IOFromFile(P.c_str(), "w+b"); if (file != nullptr) { // Guardamos los datos for (auto &i : demo_.data_file) { @@ -568,14 +567,14 @@ auto Game::saveDemoFile() -> bool { } if (Options::settings.console) { - std::cout << "Writing file " << filename.c_str() << '\n'; + std::cout << "Writing file " << FILE_NAME.c_str() << '\n'; } // Cerramos el fichero SDL_CloseIO(file); } else { if (Options::settings.console) { - std::cout << "Error: Unable to save " << filename.c_str() << " file! " << SDL_GetError() << '\n'; + std::cout << "Error: Unable to save " << FILE_NAME.c_str() << " file! " << SDL_GetError() << '\n'; } } } @@ -584,22 +583,22 @@ auto Game::saveDemoFile() -> bool { // Inicializa las formaciones enemigas void Game::initEnemyFormations() { - const int y4 = (PLAY_AREA_TOP - BLOCK); - const int x4_0 = PLAY_AREA_LEFT; - const int x4_100 = (PLAY_AREA_RIGHT)-Balloon::WIDTH_4; + const int Y4 = (PLAY_AREA_TOP - BLOCK); + const int X4_0 = PLAY_AREA_LEFT; + const int X4_100 = (PLAY_AREA_RIGHT)-Balloon::WIDTH_4; - const int y3 = (PLAY_AREA_TOP - BLOCK); - const int x3_0 = PLAY_AREA_LEFT; - const int x3_100 = (PLAY_AREA_RIGHT)-Balloon::WIDTH_3; + const int Y3 = (PLAY_AREA_TOP - BLOCK); + const int X3_0 = PLAY_AREA_LEFT; + const int X3_100 = (PLAY_AREA_RIGHT)-Balloon::WIDTH_3; - const int y2 = (PLAY_AREA_TOP - BLOCK); - const int x2_0 = PLAY_AREA_LEFT; - const int x2_100 = (PLAY_AREA_RIGHT)-Balloon::WIDTH_2; + const int Y2 = (PLAY_AREA_TOP - BLOCK); + const int X2_0 = PLAY_AREA_LEFT; + const int X2_100 = (PLAY_AREA_RIGHT)-Balloon::WIDTH_2; - const int y1 = (PLAY_AREA_TOP - BLOCK); - const int x1_0 = PLAY_AREA_LEFT; - const int x1_50 = PLAY_AREA_CENTER_X - (Balloon::WIDTH_1 / 2); - const int x1_100 = (PLAY_AREA_RIGHT)-Balloon::WIDTH_1; + const int Y1 = (PLAY_AREA_TOP - BLOCK); + const int X1_0 = PLAY_AREA_LEFT; + const int X1_50 = PLAY_AREA_CENTER_X - (Balloon::WIDTH_1 / 2); + const int X1_100 = (PLAY_AREA_RIGHT)-Balloon::WIDTH_1; // Inicializa a cero las variables for (auto &i : enemy_formation_) { @@ -613,385 +612,385 @@ void Game::initEnemyFormations() { } } - const Uint16 creationTime = 300; - int incX = 0; - Uint8 incTime = 0; + const Uint16 CREATION_TIME = 300; + int inc_x = 0; + Uint8 inc_time = 0; Uint8 j = 0; // #00 - Dos enemigos BALLOON4 uno a cada extremo j = 0; enemy_formation_[j].number_of_enemies = 2; - incX = x4_100; - incTime = 0; + inc_x = X4_100; + inc_time = 0; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x4_0 + (i * incX); - enemy_formation_[j].init[i].y = y4; + enemy_formation_[j].init[i].x = X4_0 + (i * inc_x); + enemy_formation_[j].init[i].y = Y4; enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE * (((i % 2) * 2) - 1); enemy_formation_[j].init[i].kind = Balloon::BALLOON_4; - enemy_formation_[j].init[i].creation_counter = creationTime + (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME + (inc_time * i); } // #01 - Dos enemigos BALLOON4 uno a cada cuarto. Ambos van hacia el centro j = 1; enemy_formation_[j].number_of_enemies = 2; - incX = PLAY_AREA_CENTER_X; - incTime = 0; + inc_x = PLAY_AREA_CENTER_X; + inc_time = 0; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = PLAY_AREA_CENTER_FIRST_QUARTER_X - (Balloon::WIDTH_4 / 2) + (i * incX); - enemy_formation_[j].init[i].y = y4; + enemy_formation_[j].init[i].x = PLAY_AREA_CENTER_FIRST_QUARTER_X - (Balloon::WIDTH_4 / 2) + (i * inc_x); + enemy_formation_[j].init[i].y = Y4; enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE * (((i % 2) * 2) - 1); enemy_formation_[j].init[i].kind = Balloon::BALLOON_4; - enemy_formation_[j].init[i].creation_counter = creationTime + (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME + (inc_time * i); } // #02 - Cuatro enemigos BALLOON2 uno detras del otro. A la izquierda y hacia el centro j = 2; enemy_formation_[j].number_of_enemies = 4; - incX = Balloon::WIDTH_2 + 1; - incTime = 10; + inc_x = Balloon::WIDTH_2 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x2_0 + (i * incX); - enemy_formation_[j].init[i].y = y2; + enemy_formation_[j].init[i].x = X2_0 + (i * inc_x); + enemy_formation_[j].init[i].y = Y2; enemy_formation_[j].init[i].vel_x = Balloon::VELX_POSITIVE; enemy_formation_[j].init[i].kind = Balloon::BALLOON_2; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); } // #03 - Cuatro enemigos BALLOON2 uno detras del otro. A la derecha y hacia el centro j = 3; enemy_formation_[j].number_of_enemies = 4; - incX = Balloon::WIDTH_2 + 1; - incTime = 10; + inc_x = Balloon::WIDTH_2 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x2_100 - (i * incX); - enemy_formation_[j].init[i].y = y2; + enemy_formation_[j].init[i].x = X2_100 - (i * inc_x); + enemy_formation_[j].init[i].y = Y2; enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE; enemy_formation_[j].init[i].kind = Balloon::BALLOON_2; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); } // #04 - Tres enemigos BALLOON3. 0, 25, 50. Hacia la derecha j = 4; enemy_formation_[j].number_of_enemies = 3; - incX = Balloon::WIDTH_3 * 2; - incTime = 10; + inc_x = Balloon::WIDTH_3 * 2; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x3_0 + (i * incX); - enemy_formation_[j].init[i].y = y3; + enemy_formation_[j].init[i].x = X3_0 + (i * inc_x); + enemy_formation_[j].init[i].y = Y3; enemy_formation_[j].init[i].vel_x = Balloon::VELX_POSITIVE; enemy_formation_[j].init[i].kind = Balloon::BALLOON_3; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); } // #05 - Tres enemigos BALLOON3. 50, 75, 100. Hacia la izquierda j = 5; enemy_formation_[j].number_of_enemies = 3; - incX = Balloon::WIDTH_3 * 2; - incTime = 10; + inc_x = Balloon::WIDTH_3 * 2; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x3_100 - (i * incX); - enemy_formation_[j].init[i].y = y3; + enemy_formation_[j].init[i].x = X3_100 - (i * inc_x); + enemy_formation_[j].init[i].y = Y3; enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE; enemy_formation_[j].init[i].kind = Balloon::BALLOON_3; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); } // #06 - Tres enemigos BALLOON3. 0, 0, 0. Hacia la derecha j = 6; enemy_formation_[j].number_of_enemies = 3; - incX = Balloon::WIDTH_3 + 1; - incTime = 10; + inc_x = Balloon::WIDTH_3 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x3_0 + (i * incX); - enemy_formation_[j].init[i].y = y3; + enemy_formation_[j].init[i].x = X3_0 + (i * inc_x); + enemy_formation_[j].init[i].y = Y3; enemy_formation_[j].init[i].vel_x = Balloon::VELX_POSITIVE; enemy_formation_[j].init[i].kind = Balloon::BALLOON_3; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); } // #07 - Tres enemigos BALLOON3. 100, 100, 100. Hacia la izquierda j = 7; enemy_formation_[j].number_of_enemies = 3; - incX = Balloon::WIDTH_3 + 1; - incTime = 10; + inc_x = Balloon::WIDTH_3 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x3_100 - (i * incX); - enemy_formation_[j].init[i].y = y3; + enemy_formation_[j].init[i].x = X3_100 - (i * inc_x); + enemy_formation_[j].init[i].y = Y3; enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE; enemy_formation_[j].init[i].kind = Balloon::BALLOON_3; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); } // #08 - Seis enemigos BALLOON1. 0, 0, 0, 0, 0, 0. Hacia la derecha j = 8; enemy_formation_[j].number_of_enemies = 6; - incX = Balloon::WIDTH_1 + 1; - incTime = 10; + inc_x = Balloon::WIDTH_1 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x1_0 + (i * incX); + enemy_formation_[j].init[i].x = X1_0 + (i * inc_x); enemy_formation_[j].init[i].y = 13; enemy_formation_[j].init[i].vel_x = Balloon::VELX_POSITIVE; enemy_formation_[j].init[i].kind = Balloon::BALLOON_1; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); } // #09 - Seis enemigos BALLOON1. 100, 100, 100, 100, 100, 100. Hacia la izquierda j = 9; enemy_formation_[j].number_of_enemies = 6; - incX = Balloon::WIDTH_1 + 1; - incTime = 10; + inc_x = Balloon::WIDTH_1 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x1_100 - (i * incX); + enemy_formation_[j].init[i].x = X1_100 - (i * inc_x); enemy_formation_[j].init[i].y = 13; enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE; enemy_formation_[j].init[i].kind = Balloon::BALLOON_1; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); } // #10 - Tres enemigos BALLOON4 seguidos desde la izquierda j = 10; enemy_formation_[j].number_of_enemies = 3; - incX = Balloon::WIDTH_4 + 1; - incTime = 15; + inc_x = Balloon::WIDTH_4 + 1; + inc_time = 15; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x4_0 + (i * incX); - enemy_formation_[j].init[i].y = y4; + enemy_formation_[j].init[i].x = X4_0 + (i * inc_x); + enemy_formation_[j].init[i].y = Y4; enemy_formation_[j].init[i].vel_x = Balloon::VELX_POSITIVE; enemy_formation_[j].init[i].kind = Balloon::BALLOON_4; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); } // #11 - Tres enemigos BALLOON4 seguidos desde la derecha j = 11; enemy_formation_[j].number_of_enemies = 3; - incX = Balloon::WIDTH_4 + 1; - incTime = 15; + inc_x = Balloon::WIDTH_4 + 1; + inc_time = 15; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x4_100 - (i * incX); - enemy_formation_[j].init[i].y = y4; + enemy_formation_[j].init[i].x = X4_100 - (i * inc_x); + enemy_formation_[j].init[i].y = Y4; enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE; enemy_formation_[j].init[i].kind = Balloon::BALLOON_4; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); } // #12 - Seis enemigos BALLOON2 uno detras del otro. A la izquierda y hacia el centro j = 12; enemy_formation_[j].number_of_enemies = 6; - incX = Balloon::WIDTH_2 + 1; - incTime = 10; + inc_x = Balloon::WIDTH_2 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x2_0 + (i * incX); - enemy_formation_[j].init[i].y = y2; + enemy_formation_[j].init[i].x = X2_0 + (i * inc_x); + enemy_formation_[j].init[i].y = Y2; enemy_formation_[j].init[i].vel_x = Balloon::VELX_POSITIVE; enemy_formation_[j].init[i].kind = Balloon::BALLOON_2; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); } // #13 - Seis enemigos BALLOON2 uno detras del otro. A la derecha y hacia el centro j = 13; enemy_formation_[j].number_of_enemies = 6; - incX = Balloon::WIDTH_2 + 1; - incTime = 10; + inc_x = Balloon::WIDTH_2 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x2_100 - (i * incX); - enemy_formation_[j].init[i].y = y2; + enemy_formation_[j].init[i].x = X2_100 - (i * inc_x); + enemy_formation_[j].init[i].y = Y2; enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE; enemy_formation_[j].init[i].kind = Balloon::BALLOON_2; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); } // #14 - Cinco enemigos BALLOON3. Hacia la derecha. Separados j = 14; enemy_formation_[j].number_of_enemies = 5; - incX = Balloon::WIDTH_3 * 2; - incTime = 10; + inc_x = Balloon::WIDTH_3 * 2; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x3_0 + (i * incX); - enemy_formation_[j].init[i].y = y3; + enemy_formation_[j].init[i].x = X3_0 + (i * inc_x); + enemy_formation_[j].init[i].y = Y3; enemy_formation_[j].init[i].vel_x = Balloon::VELX_POSITIVE; enemy_formation_[j].init[i].kind = Balloon::BALLOON_3; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); } // #15 - Cinco enemigos BALLOON3. Hacia la izquierda. Separados j = 15; enemy_formation_[j].number_of_enemies = 5; - incX = Balloon::WIDTH_3 * 2; - incTime = 10; + inc_x = Balloon::WIDTH_3 * 2; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x3_100 - (i * incX); - enemy_formation_[j].init[i].y = y3; + enemy_formation_[j].init[i].x = X3_100 - (i * inc_x); + enemy_formation_[j].init[i].y = Y3; enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE; enemy_formation_[j].init[i].kind = Balloon::BALLOON_3; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); } // #16 - Cinco enemigos BALLOON3. Hacia la derecha. Juntos j = 16; enemy_formation_[j].number_of_enemies = 5; - incX = Balloon::WIDTH_3 + 1; - incTime = 10; + inc_x = Balloon::WIDTH_3 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x3_0 + (i * incX); - enemy_formation_[j].init[i].y = y3; + enemy_formation_[j].init[i].x = X3_0 + (i * inc_x); + enemy_formation_[j].init[i].y = Y3; enemy_formation_[j].init[i].vel_x = Balloon::VELX_POSITIVE; enemy_formation_[j].init[i].kind = Balloon::BALLOON_3; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); } // #17 - Cinco enemigos BALLOON3. Hacia la izquierda. Juntos j = 17; enemy_formation_[j].number_of_enemies = 5; - incX = Balloon::WIDTH_3 + 1; - incTime = 10; + inc_x = Balloon::WIDTH_3 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x3_100 - (i * incX); - enemy_formation_[j].init[i].y = y3; + enemy_formation_[j].init[i].x = X3_100 - (i * inc_x); + enemy_formation_[j].init[i].y = Y3; enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE; enemy_formation_[j].init[i].kind = Balloon::BALLOON_3; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); } // #18 - Doce enemigos BALLOON1. Hacia la derecha. Juntos j = 18; enemy_formation_[j].number_of_enemies = 12; - incX = Balloon::WIDTH_1 + 1; - incTime = 10; + inc_x = Balloon::WIDTH_1 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x1_0 + (i * incX); - enemy_formation_[j].init[i].y = y1; + enemy_formation_[j].init[i].x = X1_0 + (i * inc_x); + enemy_formation_[j].init[i].y = Y1; enemy_formation_[j].init[i].vel_x = Balloon::VELX_POSITIVE; enemy_formation_[j].init[i].kind = Balloon::BALLOON_1; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); } // #19 - Doce enemigos BALLOON1. Hacia la izquierda. Juntos j = 19; enemy_formation_[j].number_of_enemies = 12; - incX = Balloon::WIDTH_1 + 1; - incTime = 10; + inc_x = Balloon::WIDTH_1 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { - enemy_formation_[j].init[i].x = x1_100 - (i * incX); - enemy_formation_[j].init[i].y = y1; + enemy_formation_[j].init[i].x = X1_100 - (i * inc_x); + enemy_formation_[j].init[i].y = Y1; enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE; enemy_formation_[j].init[i].kind = Balloon::BALLOON_1; - enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME - (inc_time * i); } // #20 - Dos enemigos BALLOON4 seguidos desde la izquierda/derecha. Simetricos j = 20; enemy_formation_[j].number_of_enemies = 4; - incX = Balloon::WIDTH_4 + 1; - incTime = 0; + inc_x = Balloon::WIDTH_4 + 1; + inc_time = 0; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { Uint8 half = enemy_formation_[j].number_of_enemies / 2; if (i < half) { - enemy_formation_[j].init[i].x = x4_0 + (i * incX); + enemy_formation_[j].init[i].x = X4_0 + (i * inc_x); enemy_formation_[j].init[i].vel_x = Balloon::VELX_POSITIVE; } else { - enemy_formation_[j].init[i].x = x4_100 - ((i - half) * incX); + enemy_formation_[j].init[i].x = X4_100 - ((i - half) * inc_x); enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE; } - enemy_formation_[j].init[i].y = y4; + enemy_formation_[j].init[i].y = Y4; enemy_formation_[j].init[i].kind = Balloon::BALLOON_4; - enemy_formation_[j].init[i].creation_counter = creationTime + (incTime * i); + enemy_formation_[j].init[i].creation_counter = CREATION_TIME + (inc_time * i); } // #21 - Diez enemigos BALLOON2 uno detras del otro. Izquierda/derecha. Simetricos j = 21; enemy_formation_[j].number_of_enemies = 10; - incX = Balloon::WIDTH_2 + 1; - incTime = 3; + inc_x = Balloon::WIDTH_2 + 1; + inc_time = 3; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { Uint8 half = enemy_formation_[j].number_of_enemies / 2; if (i < half) { - enemy_formation_[j].init[i].x = x2_0 + (i * incX); + enemy_formation_[j].init[i].x = X2_0 + (i * inc_x); enemy_formation_[j].init[i].vel_x = Balloon::VELX_POSITIVE; - enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * i); + enemy_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * i); } else { - enemy_formation_[j].init[i].x = x2_100 - ((i - half) * incX); + enemy_formation_[j].init[i].x = X2_100 - ((i - half) * inc_x); enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE; - enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * (i - half)); + enemy_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * (i - half)); } - enemy_formation_[j].init[i].y = y2; + enemy_formation_[j].init[i].y = Y2; enemy_formation_[j].init[i].kind = Balloon::BALLOON_2; } // #22 - Diez enemigos BALLOON3. Hacia la derecha/izquierda. Separados. Simetricos j = 22; enemy_formation_[j].number_of_enemies = 10; - incX = Balloon::WIDTH_3 * 2; - incTime = 10; + inc_x = Balloon::WIDTH_3 * 2; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { Uint8 half = enemy_formation_[j].number_of_enemies / 2; if (i < half) { - enemy_formation_[j].init[i].x = x3_0 + (i * incX); + enemy_formation_[j].init[i].x = X3_0 + (i * inc_x); enemy_formation_[j].init[i].vel_x = Balloon::VELX_POSITIVE; - enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * i); + enemy_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * i); } else { - enemy_formation_[j].init[i].x = x3_100 - ((i - half) * incX); + enemy_formation_[j].init[i].x = X3_100 - ((i - half) * inc_x); enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE; - enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * (i - half)); + enemy_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * (i - half)); } - enemy_formation_[j].init[i].y = y3; + enemy_formation_[j].init[i].y = Y3; enemy_formation_[j].init[i].kind = Balloon::BALLOON_3; } // #23 - Diez enemigos BALLOON3. Hacia la derecha. Juntos. Simetricos j = 23; enemy_formation_[j].number_of_enemies = 10; - incX = Balloon::WIDTH_3 + 1; - incTime = 10; + inc_x = Balloon::WIDTH_3 + 1; + inc_time = 10; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { Uint8 half = enemy_formation_[j].number_of_enemies / 2; if (i < half) { - enemy_formation_[j].init[i].x = x3_0 + (i * incX); + enemy_formation_[j].init[i].x = X3_0 + (i * inc_x); enemy_formation_[j].init[i].vel_x = Balloon::VELX_POSITIVE; - enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * i); + enemy_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * i); } else { - enemy_formation_[j].init[i].x = x3_100 - ((i - half) * incX); + enemy_formation_[j].init[i].x = X3_100 - ((i - half) * inc_x); enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE; - enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * (i - half)); + enemy_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * (i - half)); } - enemy_formation_[j].init[i].y = y3; + enemy_formation_[j].init[i].y = Y3; enemy_formation_[j].init[i].kind = Balloon::BALLOON_3; } // #24 - Treinta enemigos BALLOON1. Del centro hacia los extremos. Juntos. Simetricos j = 24; enemy_formation_[j].number_of_enemies = 30; - incTime = 5; + inc_time = 5; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { Uint8 half = enemy_formation_[j].number_of_enemies / 2; if (i < half) { - enemy_formation_[j].init[i].x = x1_50; + enemy_formation_[j].init[i].x = X1_50; enemy_formation_[j].init[i].vel_x = Balloon::VELX_POSITIVE; - enemy_formation_[j].init[i].creation_counter = (creationTime) + (incTime * i); + enemy_formation_[j].init[i].creation_counter = (CREATION_TIME) + (inc_time * i); } else { - enemy_formation_[j].init[i].x = x1_50; + enemy_formation_[j].init[i].x = X1_50; enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE; - enemy_formation_[j].init[i].creation_counter = (creationTime) + (incTime * (i - half)); + enemy_formation_[j].init[i].creation_counter = (CREATION_TIME) + (inc_time * (i - half)); } - enemy_formation_[j].init[i].y = y1; + enemy_formation_[j].init[i].y = Y1; enemy_formation_[j].init[i].kind = Balloon::BALLOON_1; } // #25 - Treinta enemigos BALLOON1. Del centro hacia adentro. Juntos. Simetricos j = 25; enemy_formation_[j].number_of_enemies = 30; - incTime = 5; + inc_time = 5; for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { Uint8 half = enemy_formation_[j].number_of_enemies / 2; if (i < half) { - enemy_formation_[j].init[i].x = x1_50 + 20; + enemy_formation_[j].init[i].x = X1_50 + 20; enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE; - enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * i); + enemy_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * i); } else { - enemy_formation_[j].init[i].x = x1_50 - 20; + enemy_formation_[j].init[i].x = X1_50 - 20; enemy_formation_[j].init[i].vel_x = Balloon::VELX_POSITIVE; - enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * (i - half)); + enemy_formation_[j].init[i].creation_counter = (CREATION_TIME) - (inc_time * (i - half)); } - enemy_formation_[j].init[i].y = y1; + enemy_formation_[j].init[i].y = Y1; enemy_formation_[j].init[i].kind = Balloon::BALLOON_1; } @@ -1011,25 +1010,25 @@ void Game::initEnemyFormations() { enemy_formation_[99].number_of_enemies = 4; enemy_formation_[99].init[0].x = 10; - enemy_formation_[99].init[0].y = y1; + enemy_formation_[99].init[0].y = Y1; enemy_formation_[99].init[0].vel_x = 0; enemy_formation_[99].init[0].kind = Balloon::BALLOON_1; enemy_formation_[99].init[0].creation_counter = 200; enemy_formation_[99].init[1].x = 50; - enemy_formation_[99].init[1].y = y1; + enemy_formation_[99].init[1].y = Y1; enemy_formation_[99].init[1].vel_x = 0; enemy_formation_[99].init[1].kind = Balloon::BALLOON_2; enemy_formation_[99].init[1].creation_counter = 200; enemy_formation_[99].init[2].x = 90; - enemy_formation_[99].init[2].y = y1; + enemy_formation_[99].init[2].y = Y1; enemy_formation_[99].init[2].vel_x = 0; enemy_formation_[99].init[2].kind = Balloon::BALLOON_3; enemy_formation_[99].init[2].creation_counter = 200; enemy_formation_[99].init[3].x = 140; - enemy_formation_[99].init[3].y = y1; + enemy_formation_[99].init[3].y = Y1; enemy_formation_[99].init[3].vel_x = 0; enemy_formation_[99].init[3].kind = Balloon::BALLOON_4; enemy_formation_[99].init[3].creation_counter = 200; @@ -1266,8 +1265,8 @@ void Game::deployEnemyFormation() { last_enemy_deploy_ = set; - const Uint8 numEnemies = stage_[current_stage_].enemy_pool->set[set]->number_of_enemies; - for (int i = 0; i < numEnemies; ++i) { + const Uint8 NUM_ENEMIES = stage_[current_stage_].enemy_pool->set[set]->number_of_enemies; + for (int i = 0; i < NUM_ENEMIES; ++i) { createBalloon(stage_[current_stage_].enemy_pool->set[set]->init[i].x, stage_[current_stage_].enemy_pool->set[set]->init[i].y, stage_[current_stage_].enemy_pool->set[set]->init[i].kind, @@ -1353,62 +1352,62 @@ void Game::renderScoreBoard() { } else { // Pinta el fondo del marcador del color de la dificultad SDL_SetRenderDrawColor(renderer_, difficulty_color_.r, difficulty_color_.g, difficulty_color_.b, 255); } - SDL_FRect fRect = {0, 160, 256, 32}; - SDL_RenderFillRect(renderer_, &fRect); + SDL_FRect f_rect = {0, 160, 256, 32}; + SDL_RenderFillRect(renderer_, &f_rect); // Dibuja la linea que separa el marcador de la zona de juego SDL_SetRenderDrawColor(renderer_, 13, 26, 43, 255); SDL_RenderLine(renderer_, 0, 160, 255, 160); // Anclas para los elementos - const int offset1 = 162; - const int offset2 = offset1 + 7; - const int offset3 = offset2 + 7; - const int offset4 = offset3 + 7; + const int OFFSET1 = 162; + const int OFFSET2 = OFFSET1 + 7; + const int OFFSET3 = OFFSET2 + 7; + const int OFFSET4 = OFFSET3 + 7; - const int offsetLeft = PLAY_AREA_LEFT + 45; - const int offsetRight = PLAY_AREA_RIGHT - 45; + const int OFFSET_LEFT = PLAY_AREA_LEFT + 45; + const int OFFSET_RIGHT = PLAY_AREA_RIGHT - 45; // PLAYER1 - SCORE - text_scoreboard_->writeCentered(offsetLeft, offset1, Lang::get()->getText(53)); - text_scoreboard_->writeCentered(offsetLeft, offset2, updateScoreText(players_[0]->getScore())); + text_scoreboard_->writeCentered(OFFSET_LEFT, OFFSET1, Lang::get()->getText(53)); + text_scoreboard_->writeCentered(OFFSET_LEFT, OFFSET2, updateScoreText(players_[0]->getScore())); // PLAYER1 - MULT - text_scoreboard_->writeCentered(offsetLeft, offset3, Lang::get()->getText(55)); - text_scoreboard_->writeCentered(offsetLeft, offset4, std::to_string(players_[0]->getScoreMultiplier()).substr(0, 3)); + text_scoreboard_->writeCentered(OFFSET_LEFT, OFFSET3, Lang::get()->getText(55)); + text_scoreboard_->writeCentered(OFFSET_LEFT, OFFSET4, std::to_string(players_[0]->getScoreMultiplier()).substr(0, 3)); if (num_players_ == 2) { // PLAYER2 - SCORE - text_scoreboard_->writeCentered(offsetRight, offset1, Lang::get()->getText(54)); - text_scoreboard_->writeCentered(offsetRight, offset2, updateScoreText(players_[1]->getScore())); + text_scoreboard_->writeCentered(OFFSET_RIGHT, OFFSET1, Lang::get()->getText(54)); + text_scoreboard_->writeCentered(OFFSET_RIGHT, OFFSET2, updateScoreText(players_[1]->getScore())); // PLAYER2 - MULT - text_scoreboard_->writeCentered(offsetRight, offset3, Lang::get()->getText(55)); - text_scoreboard_->writeCentered(offsetRight, offset4, std::to_string(players_[1]->getScoreMultiplier()).substr(0, 3)); + text_scoreboard_->writeCentered(OFFSET_RIGHT, OFFSET3, Lang::get()->getText(55)); + text_scoreboard_->writeCentered(OFFSET_RIGHT, OFFSET4, std::to_string(players_[1]->getScoreMultiplier()).substr(0, 3)); } else { // PLAYER2 - SCORE - text_scoreboard_->writeCentered(offsetRight, offset1, Lang::get()->getText(54)); - text_scoreboard_->writeCentered(offsetRight, offset2, "0000000"); + text_scoreboard_->writeCentered(OFFSET_RIGHT, OFFSET1, Lang::get()->getText(54)); + text_scoreboard_->writeCentered(OFFSET_RIGHT, OFFSET2, "0000000"); // PLAYER2 - MULT - text_scoreboard_->writeCentered(offsetRight, offset3, Lang::get()->getText(55)); - text_scoreboard_->writeCentered(offsetRight, offset4, "1.0"); + text_scoreboard_->writeCentered(OFFSET_RIGHT, OFFSET3, Lang::get()->getText(55)); + text_scoreboard_->writeCentered(OFFSET_RIGHT, OFFSET4, "1.0"); } // STAGE - text_scoreboard_->writeCentered(PLAY_AREA_CENTER_X, offset1, Lang::get()->getText(57) + std::to_string(stage_[current_stage_].number)); + text_scoreboard_->writeCentered(PLAY_AREA_CENTER_X, OFFSET1, Lang::get()->getText(57) + std::to_string(stage_[current_stage_].number)); // POWERMETER - power_meter_sprite_->setPosY(offset2); + power_meter_sprite_->setPosY(OFFSET2); power_meter_sprite_->setSpriteClip(0, 0, 40, 7); power_meter_sprite_->render(); - const float percent = (stage_[current_stage_].current_power * 40.0F) / stage_[current_stage_].power_to_complete; - power_meter_sprite_->setSpriteClip(40, 0, (int)percent, 7); + const float PERCENT = (stage_[current_stage_].current_power * 40.0F) / stage_[current_stage_].power_to_complete; + power_meter_sprite_->setSpriteClip(40, 0, (int)PERCENT, 7); power_meter_sprite_->render(); // HI-SCORE - text_scoreboard_->writeCentered(PLAY_AREA_CENTER_X, offset3, Lang::get()->getText(56)); - text_scoreboard_->writeCentered(PLAY_AREA_CENTER_X, offset4, hi_score_name_ + updateScoreText(hi_score_)); + text_scoreboard_->writeCentered(PLAY_AREA_CENTER_X, OFFSET3, Lang::get()->getText(56)); + text_scoreboard_->writeCentered(PLAY_AREA_CENTER_X, OFFSET4, hi_score_name_ + updateScoreText(hi_score_)); } // Actualiza las variables del jugador @@ -1446,14 +1445,14 @@ void Game::updateStage() { // Cambio de fase current_stage_++; last_stage_reached_ = current_stage_; - if (current_stage_ == 10) { // Ha llegado al final el juego - game_completed_ = true; // Marca el juego como completado - current_stage_ = 9; // Deja el valor dentro de los limites + if (current_stage_ == 10) { // Ha llegado al final el juego + game_completed_ = true; // Marca el juego como completado + current_stage_ = 9; // Deja el valor dentro de los limites stage_[current_stage_].current_power = 0; // Deja el poder a cero para que no vuelva a entrar en esta condición - destroyAllBalloons(); // Destruye a todos los enemigos + destroyAllBalloons(); // Destruye a todos los enemigos stage_[current_stage_].current_power = 0; // Vuelve a dejar el poder a cero, por lo que hubiera podido subir al destruir todos lo globos - menace_current_ = 255; // Sube el nivel de amenaza para que no cree mas globos - for (auto *player : players_) { // Añade un millon de puntos a los jugadores que queden vivos + menace_current_ = 255; // Sube el nivel de amenaza para que no cree mas globos + for (auto *player : players_) { // Añade un millon de puntos a los jugadores que queden vivos if (player->isAlive()) { player->addScore(1000000); } @@ -1483,21 +1482,21 @@ void Game::updateStage() { // Actualiza el estado de muerte void Game::updateDeath() { // Comprueba si todos los jugadores estan muertos - bool allDead = true; + bool all_dead = true; for (auto *player : players_) { - allDead &= (!player->isAlive()); + all_dead &= (!player->isAlive()); } - if (allDead) { + if (all_dead) { if (death_counter_ > 0) { death_counter_--; if ((death_counter_ == 250) || (death_counter_ == 200) || (death_counter_ == 180) || (death_counter_ == 120) || (death_counter_ == 60)) { // Hace sonar aleatoriamente uno de los 4 sonidos de burbujas if (!demo_.enabled) { - const Uint8 index = rand() % 4; + const Uint8 INDEX = rand() % 4; JA_Sound_t *sound[4] = {bubble1_sound_, bubble2_sound_, bubble3_sound_, bubble4_sound_}; - Audio::get()->playSound(sound[index]); + Audio::get()->playSound(sound[INDEX]); } } } else { @@ -1547,25 +1546,25 @@ void Game::renderBalloons() { // Crea un globo nuevo en el vector de globos auto Game::createBalloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 creationtimer) -> Uint8 { - const int index = (kind - 1) % 4; - auto *b = new Balloon(x, y, kind, velx, speed, creationtimer, balloon_textures_[index], balloon_animations_[index], renderer_); + const int INDEX = (kind - 1) % 4; + auto *b = new Balloon(x, y, kind, velx, speed, creationtimer, balloon_textures_[INDEX], balloon_animations_[INDEX], renderer_); balloons_.push_back(b); return (Uint8)(balloons_.size() - 1); } // Crea una PowerBall void Game::createPowerBall() { - const int posY = PLAY_AREA_TOP; + const int POS_Y = PLAY_AREA_TOP; - const int left = PLAY_AREA_LEFT; - const int center = PLAY_AREA_CENTER_X - (Balloon::WIDTH_4 / 2); - const int right = PLAY_AREA_RIGHT - Balloon::WIDTH_4; + const int LEFT = PLAY_AREA_LEFT; + const int CENTER = PLAY_AREA_CENTER_X - (Balloon::WIDTH_4 / 2); + const int RIGHT = PLAY_AREA_RIGHT - Balloon::WIDTH_4; - const int luck = rand() % 3; - const int x[3] = {left, center, right}; - const float vx[3] = {Balloon::VELX_POSITIVE, Balloon::VELX_POSITIVE, Balloon::VELX_NEGATIVE}; + const int LUCK = rand() % 3; + const int X[3] = {LEFT, CENTER, RIGHT}; + const float VX[3] = {Balloon::VELX_POSITIVE, Balloon::VELX_POSITIVE, Balloon::VELX_NEGATIVE}; - auto *b = new Balloon(x[luck], posY, Balloon::POWER_BALL, vx[luck], enemy_speed_, 100, balloon_textures_[3], balloon_animations_[3], renderer_); + auto *b = new Balloon(X[LUCK], POS_Y, Balloon::POWER_BALL, VX[LUCK], enemy_speed_, 100, balloon_textures_[3], balloon_animations_[3], renderer_); balloons_.push_back(b); power_ball_enabled_ = true; @@ -1607,29 +1606,15 @@ void Game::incBalloonSpeed() { // Actualiza la velocidad de los globos en funcion del poder acumulado de la fase void Game::updateBalloonSpeed() { - const float percent = (float)stage_[current_stage_].current_power / (float)stage_[current_stage_].power_to_complete; + const float PERCENT = (float)stage_[current_stage_].current_power / (float)stage_[current_stage_].power_to_complete; if (enemy_speed_ == Balloon::SPEED_1) { - if (percent > 0.2F) { - incBalloonSpeed(); - } - } - - else if (enemy_speed_ == Balloon::SPEED_2) { - if (percent > 0.4F) { - incBalloonSpeed(); - } - } - - else if (enemy_speed_ == Balloon::SPEED_3) { - if (percent > 0.6F) { - incBalloonSpeed(); - } - } - - else if (enemy_speed_ == Balloon::SPEED_4) { - if (percent > 0.8F) { - incBalloonSpeed(); - } + if (PERCENT > 0.2F) { incBalloonSpeed(); } + } else if (enemy_speed_ == Balloon::SPEED_2) { + if (PERCENT > 0.4F) { incBalloonSpeed(); } + } else if (enemy_speed_ == Balloon::SPEED_3) { + if (PERCENT > 0.6F) { incBalloonSpeed(); } + } else if (enemy_speed_ == Balloon::SPEED_4) { + if (PERCENT > 0.8F) { incBalloonSpeed(); } } } @@ -1639,8 +1624,8 @@ void Game::popBalloon(Balloon *balloon) { increaseStageCurrentPower(1); balloons_popped_++; - const Uint8 kind = balloon->getKind(); - switch (kind) { + const Uint8 KIND = balloon->getKind(); + switch (KIND) { // Tipus més petits: simplement elimina el globó case Balloon::BALLOON_1: case Balloon::HEXAGON_1: @@ -1656,20 +1641,20 @@ void Game::popBalloon(Balloon *balloon) { // En cualquier otro caso, crea dos globos de un tipo inferior default: - const int index = createBalloon(0, balloon->getPosY(), balloon->getKind() - 1, Balloon::VELX_NEGATIVE, enemy_speed_, 0); - balloons_[index]->allignTo(balloon->getPosX() + (balloon->getWidth() / 2)); - if (balloons_[index]->getClass() == Balloon::BALLOON_CLASS) { - balloons_[index]->setVelY(-2.50F); + const int INDEX = createBalloon(0, balloon->getPosY(), balloon->getKind() - 1, Balloon::VELX_NEGATIVE, enemy_speed_, 0); + balloons_[INDEX]->allignTo(balloon->getPosX() + (balloon->getWidth() / 2)); + if (balloons_[INDEX]->getClass() == Balloon::BALLOON_CLASS) { + balloons_[INDEX]->setVelY(-2.50F); } else { - balloons_[index]->setVelY(Balloon::VELX_NEGATIVE); + balloons_[INDEX]->setVelY(Balloon::VELX_NEGATIVE); } - const int index2 = createBalloon(0, balloon->getPosY(), balloon->getKind() - 1, Balloon::VELX_POSITIVE, enemy_speed_, 0); - balloons_[index2]->allignTo(balloon->getPosX() + (balloon->getWidth() / 2)); - if (balloons_[index2]->getClass() == Balloon::BALLOON_CLASS) { - balloons_[index2]->setVelY(-2.50F); + const int INDEX2 = createBalloon(0, balloon->getPosY(), balloon->getKind() - 1, Balloon::VELX_POSITIVE, enemy_speed_, 0); + balloons_[INDEX2]->allignTo(balloon->getPosX() + (balloon->getWidth() / 2)); + if (balloons_[INDEX2]->getClass() == Balloon::BALLOON_CLASS) { + balloons_[INDEX2]->setVelY(-2.50F); } else { - balloons_[index2]->setVelY(Balloon::VELX_NEGATIVE); + balloons_[INDEX2]->setVelY(Balloon::VELX_NEGATIVE); } // Elimina el globo @@ -1917,8 +1902,8 @@ void Game::renderBullets() { } // Crea un objeto bala -void Game::createBullet(int x, int y, Bullet::Kind kind, bool poweredUp, int owner) { - auto *b = new Bullet(x, y, kind, poweredUp, owner, bullet_texture_, renderer_); +void Game::createBullet(int x, int y, Bullet::Kind kind, bool powered_up, int owner) { + auto *b = new Bullet(x, y, kind, powered_up, owner, bullet_texture_, renderer_); bullets_.push_back(b); } @@ -1956,36 +1941,28 @@ void Game::renderItems() { // Devuelve un item en función del azar auto Game::dropItem() -> Item::Id { - const Uint8 luckyNumber = rand() % 100; - const Uint8 item = rand() % 6; + const Uint8 LUCKY_NUMBER = rand() % 100; + const Uint8 ITEM = rand() % 6; - switch (item) { + switch (ITEM) { case 0: - if (luckyNumber < helper_.item_disk_odds) { - return Item::Id::DISK; - } + if (LUCKY_NUMBER < helper_.item_disk_odds) { return Item::Id::DISK; } break; case 1: - if (luckyNumber < helper_.item_gavina_odds) { - return Item::Id::GAVINA; - } + if (LUCKY_NUMBER < helper_.item_gavina_odds) { return Item::Id::GAVINA; } break; case 2: - if (luckyNumber < helper_.item_paco_odds) { - return Item::Id::PACMAR; - } + if (LUCKY_NUMBER < helper_.item_paco_odds) { return Item::Id::PACMAR; } break; case 3: - if (luckyNumber < helper_.item_clock_odds) { - return Item::Id::CLOCK; - } + if (LUCKY_NUMBER < helper_.item_clock_odds) { return Item::Id::CLOCK; } break; case 4: - if (luckyNumber < helper_.item_coffee_odds) { + if (LUCKY_NUMBER < helper_.item_coffee_odds) { helper_.item_coffee_odds = ITEM_COFFEE_ODDS; return Item::Id::COFFEE; } else { @@ -1996,15 +1973,11 @@ auto Game::dropItem() -> Item::Id { break; case 5: - if (luckyNumber < helper_.item_coffee_machine_odds) { + if (LUCKY_NUMBER < helper_.item_coffee_machine_odds) { helper_.item_coffee_machine_odds = ITEM_COFFEE_MACHINE_ODDS; - if ((!coffee_machine_enabled_) && (helper_.need_coffee_machine)) { - return Item::Id::COFFEE_MACHINE; - } + if ((!coffee_machine_enabled_) && (helper_.need_coffee_machine)) { return Item::Id::COFFEE_MACHINE; } } else { - if (helper_.need_coffee_machine) { - helper_.item_coffee_machine_odds++; - } + if (helper_.need_coffee_machine) { helper_.item_coffee_machine_odds++; } } break; @@ -2017,8 +1990,8 @@ auto Game::dropItem() -> Item::Id { // Crea un objeto item void Game::createItem(Item::Id kind, float x, float y) { - const auto index = static_cast(kind) - 1; - Item *item = new Item(kind, x, y, item_textures_[index], item_animations_[index], renderer_); + const auto INDEX = static_cast(kind) - 1; + Item *item = new Item(kind, x, y, item_textures_[INDEX], item_animations_[INDEX], renderer_); items_.push_back(item); } @@ -2317,13 +2290,13 @@ void Game::updateBackground() { } // Calcula la velocidad en función de los globos explotados y el total de globos a explotar para acabar el juego - const float speed = (-0.2F) + (-3.00F * ((float)clouds_speed_ / (float)total_power_to_complete_game_)); + const float SPEED = (-0.2F) + (-3.00F * ((float)clouds_speed_ / (float)total_power_to_complete_game_)); // Aplica la velocidad calculada a las nubes - clouds1_a_->setVelX(speed); - clouds1_b_->setVelX(speed); - clouds2_a_->setVelX(speed / 2); - clouds2_b_->setVelX(speed / 2); + clouds1_a_->setVelX(SPEED); + clouds1_b_->setVelX(SPEED); + clouds2_a_->setVelX(SPEED / 2); + clouds2_b_->setVelX(SPEED / 2); // Mueve las nubes clouds1_a_->move(); @@ -2353,8 +2326,8 @@ void Game::updateBackground() { // Mueve los edificios en funcion de si está activo el efecto de agitarlos if (death_shake_.active) { - const int v[] = {-1, 1, -1, 1, -1, 1, -1, 0}; - buildings_sprite_->setPosX(v[death_shake_.step]); + const int V[] = {-1, 1, -1, 1, -1, 1, -1, 0}; + buildings_sprite_->setPosX(V[death_shake_.step]); } else if (effect_.shake) { buildings_sprite_->setPosX(((effect_.shake_counter % 2) * 2) - 1); } else { @@ -2364,18 +2337,18 @@ void Game::updateBackground() { // Dibuja el fondo void Game::renderBackground() { - const float gradientNumber = std::min(((float)balloons_popped_ / 1250.0F), 3.0F); - const float percent = gradientNumber - (int)gradientNumber; - const int alpha = std::max((255 - (int)(255 * percent)), 0); + const float GRADIENT_NUMBER = std::min(((float)balloons_popped_ / 1250.0F), 3.0F); + const float PERCENT = GRADIENT_NUMBER - (int)GRADIENT_NUMBER; + const int ALPHA = std::max((255 - (int)(255 * PERCENT)), 0); // Dibuja el gradiente 2 - sky_colors_sprite_->setSpriteClip(sky_colors_rect_[((int)gradientNumber + 1) % 4]); + sky_colors_sprite_->setSpriteClip(sky_colors_rect_[((int)GRADIENT_NUMBER + 1) % 4]); game_sky_colors_texture_->setAlpha(255); sky_colors_sprite_->render(); // Dibuja el gradiente 1 con una opacidad cada vez menor - sky_colors_sprite_->setSpriteClip(sky_colors_rect_[(int)gradientNumber]); - game_sky_colors_texture_->setAlpha(alpha); + sky_colors_sprite_->setSpriteClip(sky_colors_rect_[(int)GRADIENT_NUMBER]); + game_sky_colors_texture_->setAlpha(ALPHA); sky_colors_sprite_->render(); // Dibuja las nubes @@ -2429,11 +2402,11 @@ void Game::updateMenace() { return; } - const float percent = stage_[current_stage_].current_power / stage_[current_stage_].power_to_complete; - const Uint8 difference = stage_[current_stage_].max_menace - stage_[current_stage_].min_menace; + const float PERCENT = stage_[current_stage_].current_power / stage_[current_stage_].power_to_complete; + const Uint8 DIFFERENCE = stage_[current_stage_].max_menace - stage_[current_stage_].min_menace; // Aumenta el nivel de amenaza en función de la puntuación - menace_threshold_ = stage_[current_stage_].min_menace + (difference * percent); + menace_threshold_ = stage_[current_stage_].min_menace + (DIFFERENCE * PERCENT); // Si el nivel de amenza es inferior al umbral if (menace_current_ < menace_threshold_) { @@ -2459,40 +2432,40 @@ void Game::checkGameInput() { // Modo Demo activo if (demo_.enabled) { - const int index = 0; + const int INDEX = 0; if (demo_.data_file[demo_.counter].left == 1) { - players_[index]->setInput(input_left); + players_[INDEX]->setInput(input_left); } if (demo_.data_file[demo_.counter].right == 1) { - players_[index]->setInput(input_right); + players_[INDEX]->setInput(input_right); } if (demo_.data_file[demo_.counter].noInput == 1) { - players_[index]->setInput(input_null); + players_[INDEX]->setInput(input_null); } if (demo_.data_file[demo_.counter].fire == 1) { - if (players_[index]->canFire()) { - players_[index]->setInput(input_fire_center); - createBullet(players_[index]->getPosX() + (players_[index]->getWidth() / 2) - 4, players_[index]->getPosY() + (players_[index]->getHeight() / 2), Bullet::Kind::UP, players_[index]->isPowerUp(), index); - players_[index]->setFireCooldown(10); + if (players_[INDEX]->canFire()) { + players_[INDEX]->setInput(input_fire_center); + createBullet(players_[INDEX]->getPosX() + (players_[INDEX]->getWidth() / 2) - 4, players_[INDEX]->getPosY() + (players_[INDEX]->getHeight() / 2), Bullet::Kind::UP, players_[INDEX]->isPowerUp(), INDEX); + players_[INDEX]->setFireCooldown(10); } } if (demo_.data_file[demo_.counter].fireLeft == 1) { - if (players_[index]->canFire()) { - players_[index]->setInput(input_fire_left); - createBullet(players_[index]->getPosX() + (players_[index]->getWidth() / 2) - 4, players_[index]->getPosY() + (players_[index]->getHeight() / 2), Bullet::Kind::LEFT, players_[index]->isPowerUp(), index); - players_[index]->setFireCooldown(10); + if (players_[INDEX]->canFire()) { + players_[INDEX]->setInput(input_fire_left); + createBullet(players_[INDEX]->getPosX() + (players_[INDEX]->getWidth() / 2) - 4, players_[INDEX]->getPosY() + (players_[INDEX]->getHeight() / 2), Bullet::Kind::LEFT, players_[INDEX]->isPowerUp(), INDEX); + players_[INDEX]->setFireCooldown(10); } } if (demo_.data_file[demo_.counter].fireRight == 1) { - if (players_[index]->canFire()) { - players_[index]->setInput(input_fire_right); - createBullet(players_[index]->getPosX() + (players_[index]->getWidth() / 2) - 4, players_[index]->getPosY() + (players_[index]->getHeight() / 2), Bullet::Kind::RIGHT, players_[index]->isPowerUp(), index); - players_[index]->setFireCooldown(10); + if (players_[INDEX]->canFire()) { + players_[INDEX]->setInput(input_fire_right); + createBullet(players_[INDEX]->getPosX() + (players_[INDEX]->getWidth() / 2) - 4, players_[INDEX]->getPosY() + (players_[INDEX]->getHeight() / 2), Bullet::Kind::RIGHT, players_[INDEX]->isPowerUp(), INDEX); + players_[INDEX]->setFireCooldown(10); } } @@ -2624,20 +2597,20 @@ void Game::renderMessages() { // STAGE NUMBER if (stage_bitmap_counter_ < STAGE_COUNTER) { - const int stageNum = stage_[current_stage_].number; - std::string stageText; + const int STAGE_NUM = stage_[current_stage_].number; + std::string stage_text; - if (stageNum == 10) { // Ultima fase - stageText = Lang::get()->getText(79); + if (STAGE_NUM == 10) { // Ultima fase + stage_text = Lang::get()->getText(79); } else { // X fases restantes - stageText = std::to_string(11 - stage_[current_stage_].number) + Lang::get()->getText(38); + stage_text = std::to_string(11 - stage_[current_stage_].number) + Lang::get()->getText(38); } if (!game_completed_) { // Escribe el numero de fases restantes - text_nokia_big2_->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, stage_bitmap_path_[stage_bitmap_counter_], stageText, -2, noColor, 2, shdwTxtColor); + text_nokia_big2_->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, stage_bitmap_path_[stage_bitmap_counter_], stage_text, -2, noColor, 2, shdwTxtColor); } else { // Escribe el texto de juego completado - stageText = Lang::get()->getText(50); - text_nokia_big2_->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, stage_bitmap_path_[stage_bitmap_counter_], stageText, -2, noColor, 1, shdwTxtColor); + stage_text = Lang::get()->getText(50); + text_nokia_big2_->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, stage_bitmap_path_[stage_bitmap_counter_], stage_text, -2, noColor, 1, shdwTxtColor); text_nokia2_->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, stage_bitmap_path_[stage_bitmap_counter_] + text_nokia_big2_->getCharacterSize() + 2, Lang::get()->getText(76), -1, noColor, 1, shdwTxtColor); } } @@ -2804,10 +2777,10 @@ void Game::updatePausedGame() { if (leaving_pause_menu_) { if (pause_counter_ > 0) { // El contador está descendiendo - const bool a = pause_counter_ == 90; - const bool b = pause_counter_ == 60; - const bool c = pause_counter_ == 30; - if (a || b || c) { + const bool A = pause_counter_ == 90; + const bool B = pause_counter_ == 60; + const bool C = pause_counter_ == 30; + if (A || B || C) { Audio::get()->playSound(clock_sound_); } pause_counter_--; @@ -3053,52 +3026,52 @@ void Game::initPaths() { } // Letrero de STAGE # - const int firstPart = STAGE_COUNTER / 4; // 50 - const int secondPart = firstPart * 3; // 150 - const int centerPoint = PLAY_AREA_CENTER_Y - (BLOCK * 2); - const int distance = (PLAY_AREA_BOTTOM) - (PLAY_AREA_CENTER_Y - 16); + const int FIRST_PART = STAGE_COUNTER / 4; // 50 + const int SECOND_PART = FIRST_PART * 3; // 150 + const int CENTER_POINT = PLAY_AREA_CENTER_Y - (BLOCK * 2); + const int DISTANCE = (PLAY_AREA_BOTTOM) - (PLAY_AREA_CENTER_Y - 16); for (int i = 0; i < STAGE_COUNTER; ++i) { - if (i < firstPart) { - stage_bitmap_path_[i] = (sin[(int)((i * 1.8F) + 90)] * (distance) + centerPoint); + if (i < FIRST_PART) { + stage_bitmap_path_[i] = (sin[(int)((i * 1.8F) + 90)] * (DISTANCE) + CENTER_POINT); } - else if (i < secondPart) { - stage_bitmap_path_[i] = (int)centerPoint; + else if (i < SECOND_PART) { + stage_bitmap_path_[i] = (int)CENTER_POINT; } else { - stage_bitmap_path_[i] = (sin[(int)(((i - 149) * 1.8F) + 90)] * (centerPoint + 17) - 17); + stage_bitmap_path_[i] = (sin[(int)(((i - 149) * 1.8F) + 90)] * (CENTER_POINT + 17) - 17); } } // Letrero de GetReady - const int size = text_nokia_big2_->lenght(Lang::get()->getText(75), -2); + const int SIZE = text_nokia_big2_->lenght(Lang::get()->getText(75), -2); - const float start1 = PLAY_AREA_LEFT - size; - const float finish1 = PLAY_AREA_CENTER_X - (size / 2); + const float START1 = PLAY_AREA_LEFT - SIZE; + const float FINISH1 = PLAY_AREA_CENTER_X - (SIZE / 2); - const float start2 = finish1; - const float finish2 = PLAY_AREA_RIGHT; + const float START2 = FINISH1; + const float FINISH2 = PLAY_AREA_RIGHT; - const float distance1 = finish1 - start1; - const float distance2 = finish2 - start2; + const float DISTANCE1 = FINISH1 - START1; + const float DISTANCE2 = FINISH2 - START2; for (int i = 0; i < STAGE_COUNTER; ++i) { - if (i < firstPart) { + if (i < FIRST_PART) { get_ready_bitmap_path_[i] = sin[(int)(i * 1.8F)]; - get_ready_bitmap_path_[i] *= distance1; - get_ready_bitmap_path_[i] -= size; + get_ready_bitmap_path_[i] *= DISTANCE1; + get_ready_bitmap_path_[i] -= SIZE; } - else if (i < secondPart) { - get_ready_bitmap_path_[i] = (int)finish1; + else if (i < SECOND_PART) { + get_ready_bitmap_path_[i] = (int)FINISH1; } else { get_ready_bitmap_path_[i] = sin[(int)((i - 150) * 1.8F)]; - get_ready_bitmap_path_[i] *= distance2; - get_ready_bitmap_path_[i] += finish1; + get_ready_bitmap_path_[i] *= DISTANCE2; + get_ready_bitmap_path_[i] += FINISH1; } } } @@ -3161,8 +3134,8 @@ void Game::deleteAllVectorObjects() { }; items_.clear(); - for (auto *smartSprite : smart_sprites_) { - delete smartSprite; + for (auto *smart_sprite : smart_sprites_) { + delete smart_sprite; }; smart_sprites_.clear(); } diff --git a/source/game/game.h b/source/game/game.h index 8ce05e3..4241289 100644 --- a/source/game/game.h +++ b/source/game/game.h @@ -52,16 +52,16 @@ constexpr int TIME_STOPPED_COUNTER = 300; class Game { private: struct EnemyInit { - int x; // Posición en el eje X donde crear al enemigo - int y; // Posición en el eje Y donde crear al enemigo + int x; // Posición en el eje X donde crear al enemigo + int y; // Posición en el eje Y donde crear al enemigo float vel_x; // Velocidad inicial en el eje X - Uint8 kind; // Tipo de enemigo + Uint8 kind; // Tipo de enemigo Uint16 creation_counter; // Temporizador para la creación del enemigo }; struct EnemyFormation // Contiene la información de una formación enemiga { - Uint8 number_of_enemies; // Cantidad de enemigos que forman la formación + Uint8 number_of_enemies; // Cantidad de enemigos que forman la formación EnemyInit init[MAX_NUMBER_OF_ENEMIES_IN_A_FORMATION]; // Vector con todas las inicializaciones de los enemigos de la formación }; @@ -71,60 +71,60 @@ class Game { struct Stage // Contiene todas las variables relacionadas con una fase { - EnemyPool *enemy_pool; // El conjunto de formaciones enemigas de la fase - Uint16 current_power; // Cantidad actual de poder + EnemyPool *enemy_pool; // El conjunto de formaciones enemigas de la fase + Uint16 current_power; // Cantidad actual de poder Uint16 power_to_complete; // Cantidad de poder que se necesita para completar la fase - Uint8 max_menace; // Umbral máximo de amenaza de la fase - Uint8 min_menace; // Umbral mínimo de amenaza de la fase - Uint8 number; // Numero de fase + Uint8 max_menace; // Umbral máximo de amenaza de la fase + Uint8 min_menace; // Umbral mínimo de amenaza de la fase + Uint8 number; // Numero de fase }; struct Effect { - bool flash; // Indica si se ha de pintar la pantalla de blanco - bool shake; // Indica si se ha de agitar la pantalla + bool flash; // Indica si se ha de pintar la pantalla de blanco + bool shake; // Indica si se ha de agitar la pantalla Uint8 shake_counter; // Contador para medir el tiempo que dura el efecto }; // Estado para el efecto de agitación intensa (muerte del jugador) struct DeathShake { - bool active; // Indica si el efecto está activo - Uint8 step; // Paso actual del efecto (0-7) + bool active; // Indica si el efecto está activo + Uint8 step; // Paso actual del efecto (0-7) Uint32 last_step_ticks; // Ticks del último paso }; // Fases de la secuencia de muerte del jugador - enum class DeathPhase : std::uint8_t { + enum class DeathPhase : std::uint8_t { NONE, SHAKING, WAITING, DONE - }; + }; // Estado de la secuencia de muerte del jugador struct DeathSequence { - DeathPhase phase; // Fase actual + DeathPhase phase; // Fase actual Uint32 phase_start_ticks; // Ticks del inicio de la fase actual - Player *player; // Jugador que está muriendo + Player *player; // Jugador que está muriendo }; struct Helper { - bool need_coffee; // Indica si se necesitan cafes - bool need_coffee_machine; // Indica si se necesita PowerUp - bool need_power_ball; // Indica si se necesita una PowerBall - int counter; // Contador para no dar ayudas consecutivas - int item_disk_odds; // Probabilidad de aparición del objeto - int item_gavina_odds; // Probabilidad de aparición del objeto - int item_paco_odds; // Probabilidad de aparición del objeto - int item_clock_odds; // Probabilidad de aparición del objeto - int item_coffee_odds; // Probabilidad de aparición del objeto + bool need_coffee; // Indica si se necesitan cafes + bool need_coffee_machine; // Indica si se necesita PowerUp + bool need_power_ball; // Indica si se necesita una PowerBall + int counter; // Contador para no dar ayudas consecutivas + int item_disk_odds; // Probabilidad de aparición del objeto + int item_gavina_odds; // Probabilidad de aparición del objeto + int item_paco_odds; // Probabilidad de aparición del objeto + int item_clock_odds; // Probabilidad de aparición del objeto + int item_coffee_odds; // Probabilidad de aparición del objeto int item_coffee_machine_odds; // Probabilidad de aparición del objeto }; struct Demo { - bool enabled; // Indica si está activo el modo demo - bool recording; // Indica si está activado el modo para grabar la demo - Uint16 counter; // Contador para el modo demo - DemoKeys keys; // Variable con las pulsaciones de teclas del modo demo + bool enabled; // Indica si está activo el modo demo + bool recording; // Indica si está activado el modo para grabar la demo + Uint16 counter; // Contador para el modo demo + DemoKeys keys; // Variable con las pulsaciones de teclas del modo demo DemoKeys data_file[TOTAL_DEMO_DATA]; // Datos del fichero con los movimientos para la demo }; @@ -132,10 +132,10 @@ class Game { SDL_Renderer *renderer_; // El renderizador de la ventana Section *section_; // Seccion actual dentro del juego - std::vector players_; // Vector con los jugadores - std::vector balloons_; // Vector con los globos - std::vector bullets_; // Vector con las balas - std::vector items_; // Vector con los items + std::vector players_; // Vector con los jugadores + std::vector balloons_; // Vector con los globos + std::vector bullets_; // Vector con las balas + std::vector items_; // Vector con los items std::vector smart_sprites_; // Vector con los smartsprites Texture *bullet_texture_; // Textura para las balas @@ -145,29 +145,29 @@ class Game { std::vector player2_textures_; // Vector con las texturas del jugador std::vector> player_textures_; // Vector con todas las texturas de los jugadores; - Texture *game_buildings_texture_; // Textura con los edificios de fondo - Texture *game_clouds_texture_; // Textura con las nubes de fondo - Texture *game_grass_texture_; // Textura con la hierba del suelo + Texture *game_buildings_texture_; // Textura con los edificios de fondo + Texture *game_clouds_texture_; // Textura con las nubes de fondo + Texture *game_grass_texture_; // Textura con la hierba del suelo Texture *game_power_meter_texture_; // Textura con el marcador de poder de la fase Texture *game_sky_colors_texture_; // Textura con los diferentes colores de fondo del juego - Texture *game_text_texture_; // Textura para los sprites con textos - Texture *game_over_texture_; // Textura para la pantalla de game over + Texture *game_text_texture_; // Textura para los sprites con textos + Texture *game_over_texture_; // Textura para la pantalla de game over Texture *game_over_end_texture_; // Textura para la pantalla de game over de acabar el juego std::vector *> item_animations_; // Vector con las animaciones de los items std::vector *> player_animations_; // Vector con las animaciones del jugador std::vector *> balloon_animations_; // Vector con las animaciones de los globos - Text *text_; // Fuente para los textos del juego + Text *text_; // Fuente para los textos del juego Text *text_big_; // Fuente de texto grande Text *text_scoreboard_; // Fuente para el marcador del juego Text *text_nokia2_; // Otra fuente de texto para mensajes - Text *text_nokia_big2_; // Y la versión en grande + Text *text_nokia_big2_; // Y la versión en grande Menu *game_over_menu_; // Menú de la pantalla de game over - Menu *pause_menu_; // Menú de la pantalla de pausa + Menu *pause_menu_; // Menú de la pantalla de pausa - Fade *fade_; // Objeto para renderizar fades + Fade *fade_; // Objeto para renderizar fades SDL_Event *event_handler_; // Manejador de eventos MovingSprite *clouds1_a_; // Sprite para las nubes superiores @@ -178,26 +178,26 @@ class Game { SmartSprite *n2500_sprite_; // Sprite con el texto 2.500 SmartSprite *n5000_sprite_; // Sprite con el texto 5.000 - Sprite *buildings_sprite_; // Sprite con los edificios de fondo - Sprite *sky_colors_sprite_; // Sprite con los graficos del degradado de color de fondo - Sprite *grass_sprite_; // Sprite para la hierba - Sprite *power_meter_sprite_; // Sprite para el medidor de poder de la fase - Sprite *game_over_sprite_; // Sprite para dibujar los graficos del game over + Sprite *buildings_sprite_; // Sprite con los edificios de fondo + Sprite *sky_colors_sprite_; // Sprite con los graficos del degradado de color de fondo + Sprite *grass_sprite_; // Sprite para la hierba + Sprite *power_meter_sprite_; // Sprite para el medidor de poder de la fase + Sprite *game_over_sprite_; // Sprite para dibujar los graficos del game over Sprite *game_over_end_sprite_; // Sprite para dibujar los graficos del game over de acabar el juego - JA_Sound_t *balloon_sound_; // Sonido para la explosión del globo - JA_Sound_t *bullet_sound_; // Sonido para los disparos + JA_Sound_t *balloon_sound_; // Sonido para la explosión del globo + JA_Sound_t *bullet_sound_; // Sonido para los disparos JA_Sound_t *player_collision_sound_; // Sonido para la colisión del jugador con un enemigo JA_Sound_t *hi_score_sound_; // Sonido para cuando se alcanza la máxima puntuación JA_Sound_t *item_drop_sound_; // Sonido para cuando se genera un item - JA_Sound_t *item_pick_up_sound_; // Sonido para cuando se recoge un item + JA_Sound_t *item_pick_up_sound_; // Sonido para cuando se recoge un item JA_Sound_t *coffee_out_sound_; // Sonido para cuando el jugador pierde el café al recibir un impacto JA_Sound_t *stage_change_sound_; // Sonido para cuando se cambia de fase - JA_Sound_t *bubble1_sound_; // Sonido para cuando el jugador muere - JA_Sound_t *bubble2_sound_; // Sonido para cuando el jugador muere - JA_Sound_t *bubble3_sound_; // Sonido para cuando el jugador muere - JA_Sound_t *bubble4_sound_; // Sonido para cuando el jugador muere - JA_Sound_t *clock_sound_; // Sonido para cuando se detiene el tiempo con el item reloj + JA_Sound_t *bubble1_sound_; // Sonido para cuando el jugador muere + JA_Sound_t *bubble2_sound_; // Sonido para cuando el jugador muere + JA_Sound_t *bubble3_sound_; // Sonido para cuando el jugador muere + JA_Sound_t *bubble4_sound_; // Sonido para cuando el jugador muere + JA_Sound_t *clock_sound_; // Sonido para cuando se detiene el tiempo con el item reloj JA_Sound_t *power_ball_sound_; // Sonido para cuando se explota una Power Ball JA_Sound_t *coffee_machine_sound_; // Sonido para cuando la máquina de café toca el suelo @@ -205,53 +205,53 @@ class Game { // Variables int num_players_; // Numero de jugadores - Uint32 ticks_; // Contador de ticks para ajustar la velocidad del programa + Uint32 ticks_; // Contador de ticks para ajustar la velocidad del programa Uint8 ticks_speed_; // Velocidad a la que se repiten los bucles del programa Uint32 hi_score_; // Puntuación máxima - bool hi_score_achieved_; // Indica si se ha superado la puntuación máxima - std::string hi_score_name_; // Nombre del jugador que ostenta la máxima puntuación - Stage stage_[10]; // Variable con los datos de cada pantalla + bool hi_score_achieved_; // Indica si se ha superado la puntuación máxima + std::string hi_score_name_; // Nombre del jugador que ostenta la máxima puntuación + Stage stage_[10]; // Variable con los datos de cada pantalla Uint8 current_stage_; // Indica la fase actual - Uint8 stage_bitmap_counter_; // Contador para el tiempo visible del texto de Stage - float stage_bitmap_path_[STAGE_COUNTER]; // Vector con los puntos Y por donde se desplaza el texto - float get_ready_bitmap_path_[STAGE_COUNTER]; // Vector con los puntos X por donde se desplaza el texto + Uint8 stage_bitmap_counter_; // Contador para el tiempo visible del texto de Stage + float stage_bitmap_path_[STAGE_COUNTER]; // Vector con los puntos Y por donde se desplaza el texto + float get_ready_bitmap_path_[STAGE_COUNTER]; // Vector con los puntos X por donde se desplaza el texto Uint16 death_counter_; // Contador para la animación de muerte del jugador Uint8 menace_current_; // Nivel de amenaza actual Uint8 menace_threshold_; // Umbral del nivel de amenaza. Si el nivel de amenaza cae por debajo del umbral, se generan más globos. Si el umbral aumenta, aumenta el numero de globos bool time_stopped_; // Indica si el tiempo está detenido - Uint16 time_stopped_counter_; // Temporizador para llevar la cuenta del tiempo detenido - Uint32 counter_; // Contador para el juego - Uint32 score_data_file_[TOTAL_SCORE_DATA]; // Datos del fichero de puntos - SDL_Rect sky_colors_rect_[4]; // Vector con las coordenadas de los 4 colores de cielo + Uint16 time_stopped_counter_; // Temporizador para llevar la cuenta del tiempo detenido + Uint32 counter_; // Contador para el juego + Uint32 score_data_file_[TOTAL_SCORE_DATA]; // Datos del fichero de puntos + SDL_Rect sky_colors_rect_[4]; // Vector con las coordenadas de los 4 colores de cielo Uint16 balloons_popped_; // Lleva la cuenta de los globos explotados - Uint8 last_enemy_deploy_; // Guarda cual ha sido la última formación desplegada para no repetir; - int enemy_deploy_counter_; // Cuando se lanza una formación, se le da un valor y no sale otra hasta que llegue a cero + Uint8 last_enemy_deploy_; // Guarda cual ha sido la última formación desplegada para no repetir; + int enemy_deploy_counter_; // Cuando se lanza una formación, se le da un valor y no sale otra hasta que llegue a cero float enemy_speed_; // Velocidad a la que se mueven los enemigos - float default_enemy_speed_; // Velocidad base de los enemigos, sin incrementar - Effect effect_; // Variable para gestionar los efectos visuales + float default_enemy_speed_; // Velocidad base de los enemigos, sin incrementar + Effect effect_; // Variable para gestionar los efectos visuales DeathShake death_shake_; // Variable para gestionar el efecto de agitación intensa DeathSequence death_sequence_; // Variable para gestionar la secuencia de muerte - Helper helper_; // Variable para gestionar las ayudas - bool power_ball_enabled_; // Indica si hay una powerball ya activa - Uint8 power_ball_counter_; // Contador de formaciones enemigas entre la aparicion de una PowerBall y otra - bool coffee_machine_enabled_; // Indica si hay una máquina de café en el terreno de juego + Helper helper_; // Variable para gestionar las ayudas + bool power_ball_enabled_; // Indica si hay una powerball ya activa + Uint8 power_ball_counter_; // Contador de formaciones enemigas entre la aparicion de una PowerBall y otra + bool coffee_machine_enabled_; // Indica si hay una máquina de café en el terreno de juego bool game_completed_; // Indica si se ha completado la partida, llegando al final de la ultima pantalla - int game_completed_counter_; // Contador para el tramo final, cuando se ha completado la partida y ya no aparecen más enemigos - Uint8 difficulty_; // Dificultad del juego - float difficulty_score_multiplier_; // Multiplicador de puntos en función de la dificultad + int game_completed_counter_; // Contador para el tramo final, cuando se ha completado la partida y ya no aparecen más enemigos + Uint8 difficulty_; // Dificultad del juego + float difficulty_score_multiplier_; // Multiplicador de puntos en función de la dificultad Color difficulty_color_; // Color asociado a la dificultad - Uint8 player_one_control_; // Variable para almacenar el valor de las opciones + Uint8 player_one_control_; // Variable para almacenar el valor de las opciones EnemyFormation enemy_formation_[NUMBER_OF_ENEMY_FORMATIONS]; // Vector con todas las formaciones enemigas EnemyPool enemy_pool_[10]; // Variable con los diferentes conjuntos de formaciones enemigas - Uint8 last_stage_reached_; // Contiene el numero de la última pantalla que se ha alcanzado - Demo demo_; // Variable con todas las variables relacionadas con el modo demo - int total_power_to_complete_game_; // La suma del poder necesario para completar todas las fases + Uint8 last_stage_reached_; // Contiene el numero de la última pantalla que se ha alcanzado + Demo demo_; // Variable con todas las variables relacionadas con el modo demo + int total_power_to_complete_game_; // La suma del poder necesario para completar todas las fases int clouds_speed_{0}; // Velocidad a la que se desplazan las nubes int pause_counter_; // Contador para salir del menu de pausa y volver al juego - bool leaving_pause_menu_; // Indica si esta saliendo del menu de pausa para volver al juego + bool leaving_pause_menu_; // Indica si esta saliendo del menu de pausa para volver al juego bool pause_initialized_; // Indica si la pausa ha sido inicializada - bool game_over_initialized_; // Indica si el game over ha sido inicializado - int game_over_post_fade_; // Opción a realizar cuando termina el fundido del game over + bool game_over_initialized_; // Indica si el game over ha sido inicializado + int game_over_post_fade_; // Opción a realizar cuando termina el fundido del game over #ifdef PAUSE bool pause; #endif diff --git a/source/game/scenes/title.cpp b/source/game/scenes/title.cpp index 47f8532..dba6512 100644 --- a/source/game/scenes/title.cpp +++ b/source/game/scenes/title.cpp @@ -129,7 +129,7 @@ void Title::init() { // Pone valores por defecto. El primer jugador el teclado. El segundo jugador el primer mando device_index_.clear(); device_index_.push_back(available_input_devices_.size() - 1); // El último dispositivo encontrado es el teclado - device_index_.push_back(0); // El primer mando encontrado. Si no ha encontrado ninguno es el teclado + device_index_.push_back(0); // El primer mando encontrado. Si no ha encontrado ninguno es el teclado // Si ha encontrado un mando se lo asigna al segundo jugador if (Input::get()->gameControllerFound()) { @@ -220,10 +220,17 @@ void Title::update() { ticks_ = SDL_GetTicks(); switch (section_->subsection) { - case SUBSECTION_TITLE_1: updateTitle1(); break; - case SUBSECTION_TITLE_2: updateTitle2(); break; - case SUBSECTION_TITLE_3: updateTitle3(); break; - default: break; + case SUBSECTION_TITLE_1: + updateTitle1(); + break; + case SUBSECTION_TITLE_2: + updateTitle2(); + break; + case SUBSECTION_TITLE_3: + updateTitle3(); + break; + default: + break; } } diff --git a/source/game/scenes/title.h b/source/game/scenes/title.h index dd052d2..5bf3446 100644 --- a/source/game/scenes/title.h +++ b/source/game/scenes/title.h @@ -43,11 +43,11 @@ class Title { }; // Objetos y punteros - SDL_Renderer *renderer_; // El renderizador de la ventana - Instructions *instructions_{nullptr}; // Objeto para la sección de las instrucciones - Game *demo_game_{nullptr}; // Objeto para lanzar la demo del juego - SDL_Event *event_handler_; // Manejador de eventos - Section *section_; // Indicador para el bucle del titulo + SDL_Renderer *renderer_; // El renderizador de la ventana + Instructions *instructions_{nullptr}; // Objeto para la sección de las instrucciones + Game *demo_game_{nullptr}; // Objeto para lanzar la demo del juego + SDL_Event *event_handler_; // Manejador de eventos + Section *section_; // Indicador para el bucle del titulo Texture *dust_texture_; // Textura con los graficos del polvo Texture *coffee_texture_; // Textura con los graficos de la palabra coffee @@ -82,7 +82,7 @@ class Title { Section next_section_; // Indica cual es la siguiente sección a cargar cuando termine el contador del titulo Uint32 ticks_speed_; // Velocidad a la que se repiten los bucles del programa Uint8 post_fade_; // Opción a realizar cuando termina el fundido - MenuData menu_; // Variable con todos los objetos menus y sus variables + MenuData menu_; // Variable con todos los objetos menus y sus variables // Snapshot per a permetre CANCEL al menú d'opcions. Options::Video prev_video_; Options::Window prev_window_; @@ -103,10 +103,10 @@ class Title { Instructions::Mode instructions_mode_{Instructions::Mode::AUTO}; // Modo de las instrucciones activas bool demo_then_instructions_; // Indica si tras la demo hay que mostrar instrucciones - void init(); // Inicializa los valores - void update(); // Actualiza las variables del objeto - void render(); // Dibuja el objeto en pantalla - void checkInput(); // Comprueba las entradas + void init(); // Inicializa los valores + void update(); // Actualiza las variables del objeto + void render(); // Dibuja el objeto en pantalla + void checkInput(); // Comprueba las entradas // Helpers de update, uno por cada subsección y por cada switch dentro del título 3 void updateTitle1(); @@ -117,14 +117,14 @@ class Title { void handlePlayerSelectMenuSelection(); void handleOptionsMenuSelection(); - void updateBG(); // Actualiza el tileado de fondo - static void switchFullScreenModeVar(); // Cambia el valor de la variable de modo de pantalla completa - void updateMenuLabels() const; // Actualiza los elementos de los menus - void applyOptions(); // Aplica las opciones de menu seleccionadas - void runInstructions(Instructions::Mode mode); // Ejecuta la parte donde se muestran las instrucciones - void runDemoGame(); // Ejecuta el juego en modo demo - auto updatePlayerInputs(int num_player) -> bool; // Modifica las opciones para los controles de los jugadores - void createTiledBackground(); // Crea el mosaico de fondo del titulo - void checkInputDevices(); // Comprueba cuantos mandos hay conectados para gestionar el menu de opciones - void reLoadTextures(); // Recarga las texturas + void updateBG(); // Actualiza el tileado de fondo + static void switchFullScreenModeVar(); // Cambia el valor de la variable de modo de pantalla completa + void updateMenuLabels() const; // Actualiza los elementos de los menus + void applyOptions(); // Aplica las opciones de menu seleccionadas + void runInstructions(Instructions::Mode mode); // Ejecuta la parte donde se muestran las instrucciones + void runDemoGame(); // Ejecuta el juego en modo demo + auto updatePlayerInputs(int num_player) -> bool; // Modifica las opciones para los controles de los jugadores + void createTiledBackground(); // Crea el mosaico de fondo del titulo + void checkInputDevices(); // Comprueba cuantos mandos hay conectados para gestionar el menu de opciones + void reLoadTextures(); // Recarga las texturas };