diff --git a/source/game/entities/balloon.cpp b/source/game/entities/balloon.cpp index 1473ffd..7e9c85c 100644 --- a/source/game/entities/balloon.cpp +++ b/source/game/entities/balloon.cpp @@ -18,9 +18,9 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c switch (kind) { case BALLOON_1: // Alto y ancho del objeto - width_ = BALLOON_WIDTH_1; - height_ = BALLOON_WIDTH_1; - size_ = BALLOON_SIZE_1; + width_ = WIDTH_1; + height_ = WIDTH_1; + size_ = SIZE_1; power_ = 1; // Inicializa los valores de velocidad y gravedad @@ -31,7 +31,7 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c default_vel_y_ = 2.6F; // Puntos que da el globo al ser destruido - score_ = BALLOON_SCORE_1; + score_ = SCORE_1; // Amenaza que genera el globo menace_ = 1; @@ -40,9 +40,9 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c case BALLOON_2: // Alto y ancho del objeto - width_ = BALLOON_WIDTH_2; - height_ = BALLOON_WIDTH_2; - size_ = BALLOON_SIZE_2; + width_ = WIDTH_2; + height_ = WIDTH_2; + size_ = SIZE_2; power_ = 3; // Inicializa los valores de velocidad y gravedad @@ -53,7 +53,7 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c default_vel_y_ = 3.5F; // Puntos que da el globo al ser destruido - score_ = BALLOON_SCORE_2; + score_ = SCORE_2; // Amenaza que genera el globo menace_ = 2; @@ -62,9 +62,9 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c case BALLOON_3: // Alto y ancho del objeto - width_ = BALLOON_WIDTH_3; - height_ = BALLOON_WIDTH_3; - size_ = BALLOON_SIZE_3; + width_ = WIDTH_3; + height_ = WIDTH_3; + size_ = SIZE_3; power_ = 7; // Inicializa los valores de velocidad y gravedad @@ -75,7 +75,7 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c default_vel_y_ = 4.50F; // Puntos que da el globo al ser destruido - score_ = BALLOON_SCORE_3; + score_ = SCORE_3; // Amenaza que genera el globo menace_ = 4; @@ -84,9 +84,9 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c case BALLOON_4: // Alto y ancho del objeto - width_ = BALLOON_WIDTH_4; - height_ = BALLOON_WIDTH_4; - size_ = BALLOON_SIZE_4; + width_ = WIDTH_4; + height_ = WIDTH_4; + size_ = SIZE_4; power_ = 15; // Inicializa los valores de velocidad y gravedad @@ -97,7 +97,7 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c default_vel_y_ = 4.95F; // Puntos que da el globo al ser destruido - score_ = BALLOON_SCORE_4; + score_ = SCORE_4; // Amenaza que genera el globo menace_ = 8; @@ -106,9 +106,9 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c case HEXAGON_1: // Alto y ancho del objeto - width_ = BALLOON_WIDTH_1; - height_ = BALLOON_WIDTH_1; - size_ = BALLOON_SIZE_1; + width_ = WIDTH_1; + height_ = WIDTH_1; + size_ = SIZE_1; power_ = 1; // Inicializa los valores de velocidad y gravedad @@ -119,7 +119,7 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c default_vel_y_ = std::fabs(velx) * 2; // Puntos que da el globo al ser destruido - score_ = BALLOON_SCORE_1; + score_ = SCORE_1; // Amenaza que genera el globo menace_ = 1; @@ -128,9 +128,9 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c case HEXAGON_2: // Alto y ancho del objeto - width_ = BALLOON_WIDTH_2; - height_ = BALLOON_WIDTH_2; - size_ = BALLOON_SIZE_2; + width_ = WIDTH_2; + height_ = WIDTH_2; + size_ = SIZE_2; power_ = 3; // Inicializa los valores de velocidad y gravedad @@ -141,7 +141,7 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c default_vel_y_ = std::fabs(velx) * 2; // Puntos que da el globo al ser destruido - score_ = BALLOON_SCORE_2; + score_ = SCORE_2; // Amenaza que genera el globo menace_ = 2; @@ -150,9 +150,9 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c case HEXAGON_3: // Alto y ancho del objeto - width_ = BALLOON_WIDTH_3; - height_ = BALLOON_WIDTH_3; - size_ = BALLOON_SIZE_3; + width_ = WIDTH_3; + height_ = WIDTH_3; + size_ = SIZE_3; power_ = 7; // Inicializa los valores de velocidad y gravedad @@ -163,7 +163,7 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c default_vel_y_ = std::fabs(velx) * 2; // Puntos que da el globo al ser destruido - score_ = BALLOON_SCORE_3; + score_ = SCORE_3; // Amenaza que genera el globo menace_ = 4; @@ -172,9 +172,9 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c case HEXAGON_4: // Alto y ancho del objeto - width_ = BALLOON_WIDTH_4; - height_ = BALLOON_WIDTH_4; - size_ = BALLOON_SIZE_4; + width_ = WIDTH_4; + height_ = WIDTH_4; + size_ = SIZE_4; power_ = 15; // Inicializa los valores de velocidad y gravedad @@ -185,7 +185,7 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c default_vel_y_ = std::fabs(velx) * 2; // Puntos que da el globo al ser destruido - score_ = BALLOON_SCORE_4; + score_ = SCORE_4; // Amenaza que genera el globo menace_ = 8; @@ -194,8 +194,8 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c case POWER_BALL: // Alto y ancho del objeto - width_ = BALLOON_WIDTH_4; - height_ = BALLOON_WIDTH_4; + width_ = WIDTH_4; + height_ = WIDTH_4; size_ = 4; power_ = 0; diff --git a/source/game/entities/balloon.h b/source/game/entities/balloon.h index 9ce3edc..ee2cd8c 100644 --- a/source/game/entities/balloon.h +++ b/source/game/entities/balloon.h @@ -9,57 +9,57 @@ class AnimatedSprite; class Texture; -// Tipos de globo -constexpr int BALLOON_1 = 1; -constexpr int BALLOON_2 = 2; -constexpr int BALLOON_3 = 3; -constexpr int BALLOON_4 = 4; -constexpr int HEXAGON_1 = 5; -constexpr int HEXAGON_2 = 6; -constexpr int HEXAGON_3 = 7; -constexpr int HEXAGON_4 = 8; -constexpr int POWER_BALL = 9; - -// Puntos de globo -constexpr int BALLOON_SCORE_1 = 50; -constexpr int BALLOON_SCORE_2 = 100; -constexpr int BALLOON_SCORE_3 = 200; -constexpr int BALLOON_SCORE_4 = 400; - -// Tamaños de globo -constexpr int BALLOON_SIZE_1 = 1; -constexpr int BALLOON_SIZE_2 = 2; -constexpr int BALLOON_SIZE_3 = 3; -constexpr int BALLOON_SIZE_4 = 4; - -// Clases de globo -constexpr int BALLOON_CLASS = 0; -constexpr int HEXAGON_CLASS = 1; - -// Velocidad del globo -constexpr float BALLOON_VELX_POSITIVE = 0.7F; -constexpr float BALLOON_VELX_NEGATIVE = -0.7F; - -// Velocidades a las que se mueven los globos -constexpr float BALLOON_SPEED_1 = 0.60F; -constexpr float BALLOON_SPEED_2 = 0.70F; -constexpr float BALLOON_SPEED_3 = 0.80F; -constexpr float BALLOON_SPEED_4 = 0.90F; -constexpr float BALLOON_SPEED_5 = 1.00F; - -// Tamaño de los globos -constexpr int BALLOON_WIDTH_1 = 8; -constexpr int BALLOON_WIDTH_2 = 13; -constexpr int BALLOON_WIDTH_3 = 21; -constexpr int BALLOON_WIDTH_4 = 37; - -// PowerBall -constexpr int POWERBALL_SCREENPOWER_MINIMUM = 10; -constexpr int POWERBALL_COUNTER = 8; - // Clase Balloon class Balloon { public: + // Tipos de globo + static constexpr int BALLOON_1 = 1; + static constexpr int BALLOON_2 = 2; + static constexpr int BALLOON_3 = 3; + static constexpr int BALLOON_4 = 4; + static constexpr int HEXAGON_1 = 5; + static constexpr int HEXAGON_2 = 6; + static constexpr int HEXAGON_3 = 7; + static constexpr int HEXAGON_4 = 8; + static constexpr int POWER_BALL = 9; + + // Puntos de globo + static constexpr int SCORE_1 = 50; + static constexpr int SCORE_2 = 100; + static constexpr int SCORE_3 = 200; + static constexpr int SCORE_4 = 400; + + // Tamaños de globo + static constexpr int SIZE_1 = 1; + static constexpr int SIZE_2 = 2; + static constexpr int SIZE_3 = 3; + static constexpr int SIZE_4 = 4; + + // Clases de globo + static constexpr int BALLOON_CLASS = 0; + static constexpr int HEXAGON_CLASS = 1; + + // Velocidad del globo + static constexpr float VELX_POSITIVE = 0.7F; + static constexpr float VELX_NEGATIVE = -0.7F; + + // Velocidades a las que se mueven los globos + static constexpr float SPEED_1 = 0.60F; + static constexpr float SPEED_2 = 0.70F; + static constexpr float SPEED_3 = 0.80F; + static constexpr float SPEED_4 = 0.90F; + static constexpr float SPEED_5 = 1.00F; + + // Tamaño de los globos + static constexpr int WIDTH_1 = 8; + static constexpr int WIDTH_2 = 13; + static constexpr int WIDTH_3 = 21; + static constexpr int WIDTH_4 = 37; + + // PowerBall + static constexpr int POWERBALL_SCREENPOWER_MINIMUM = 10; + 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 diff --git a/source/game/game.cpp b/source/game/game.cpp index 8e0f4a2..0156682 100644 --- a/source/game/game.cpp +++ b/source/game/game.cpp @@ -22,7 +22,7 @@ #include "core/resources/asset.h" // for Asset #include "core/resources/resource.h" #include "game/defaults.hpp" // for PLAY_AREA_CENTER_X, BLOCK, PLAY_AREA_CEN... -#include "game/entities/balloon.h" // for Balloon, BALLOON_VELX_NEGATIVE, BALLOON_... +#include "game/entities/balloon.h" // for Balloon, Balloon::VELX_NEGATIVE, BALLOON_... #include "game/entities/bullet.h" // for Bullet, Bullet::Kind::LEFT, Bullet::Kind::RIGHT, BULLE... #include "game/entities/item.h" // for Item #include "game/entities/player.h" // for Player @@ -32,28 +32,28 @@ struct JA_Sound_t; // Constructor Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, bool demo, Section *section) - : lastStageReached(currentStage) { + : last_stage_reached_(currentStage) { // Copia los punteros - this->renderer = renderer; - this->section = section; + this->renderer_ = renderer; + this->section_ = section; // Pasa variables - this->demo.enabled = demo; - this->numPlayers = numPlayers; + this->demo_.enabled = demo; + this->num_players_ = numPlayers; #ifdef PAUSE this->currentStage = 3; #else - this->currentStage = currentStage; + this->current_stage_ = currentStage; #endif if (numPlayers == 1) { // Si solo juega un jugador, permite jugar tanto con teclado como con mando - onePlayerControl = Options::inputs[0].deviceType; + one_player_control_ = Options::inputs[0].deviceType; Options::inputs[0].deviceType = INPUT_USE_ANY; } - difficulty = Options::settings.difficulty; + difficulty_ = Options::settings.difficulty; // Crea los objetos - fade = new Fade(renderer); - eventHandler = new SDL_Event(); + fade_ = new Fade(renderer); + event_handler_ = new SDL_Event(); // Carga los recursos loadMedia(); @@ -64,22 +64,22 @@ Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, bool demo, // Establece la máxima puntuación desde fichero o desde las puntuaciones online setHiScore(); - clouds1A = new MovingSprite(0, 0, 256, 52, -0.4F, 0.0F, 0.0F, 0.0F, gameCloudsTexture, renderer); - clouds1B = new MovingSprite(256, 0, 256, 52, -0.4F, 0.0F, 0.0F, 0.0F, gameCloudsTexture, renderer); - clouds2A = new MovingSprite(0, 52, 256, 32, -0.2F, 0.0F, 0.0F, 0.0F, gameCloudsTexture, renderer); - clouds2B = new MovingSprite(256, 52, 256, 32, -0.2F, 0.0F, 0.0F, 0.0F, gameCloudsTexture, renderer); + clouds1_a_ = new MovingSprite(0, 0, 256, 52, -0.4F, 0.0F, 0.0F, 0.0F, game_clouds_texture_, renderer); + clouds1_b_ = new MovingSprite(256, 0, 256, 52, -0.4F, 0.0F, 0.0F, 0.0F, game_clouds_texture_, renderer); + clouds2_a_ = new MovingSprite(0, 52, 256, 32, -0.2F, 0.0F, 0.0F, 0.0F, game_clouds_texture_, renderer); + clouds2_b_ = new MovingSprite(256, 52, 256, 32, -0.2F, 0.0F, 0.0F, 0.0F, game_clouds_texture_, renderer); - n1000Sprite = new SmartSprite(gameTextTexture, renderer); - n2500Sprite = new SmartSprite(gameTextTexture, renderer); - n5000Sprite = new SmartSprite(gameTextTexture, renderer); + n1000_sprite_ = new SmartSprite(game_text_texture_, renderer); + n2500_sprite_ = new SmartSprite(game_text_texture_, renderer); + n5000_sprite_ = new SmartSprite(game_text_texture_, renderer); - buildingsSprite = new Sprite(0, 0, 256, 160, gameBuildingsTexture, renderer); + buildings_sprite_ = new Sprite(0, 0, 256, 160, game_buildings_texture_, renderer); - skyColorsSprite = new Sprite(0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT, gameSkyColorsTexture, renderer); - grassSprite = new Sprite(0, 0, 256, 6, gameGrassTexture, renderer); - powerMeterSprite = new Sprite(PLAY_AREA_CENTER_X - 20, 170, 40, 7, gamePowerMeterTexture, renderer); - gameOverSprite = new Sprite(16, 80, 128, 96, gameOverTexture, renderer); - gameOverEndSprite = new Sprite(PLAY_AREA_CENTER_X - (gameOverEndTexture->getWidth() / 2), 80, 128, 96, gameOverEndTexture, renderer); + sky_colors_sprite_ = new Sprite(0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT, game_sky_colors_texture_, renderer); + grass_sprite_ = new Sprite(0, 0, 256, 6, game_grass_texture_, renderer); + power_meter_sprite_ = new Sprite(PLAY_AREA_CENTER_X - 20, 170, 40, 7, game_power_meter_texture_, renderer); + game_over_sprite_ = new Sprite(16, 80, 128, 96, game_over_texture_, renderer); + game_over_end_sprite_ = new Sprite(PLAY_AREA_CENTER_X - (game_over_end_texture_->getWidth() / 2), 80, 128, 96, game_over_end_texture_, renderer); // Inicializa las variables necesarias para la sección 'Game' init(); @@ -93,8 +93,8 @@ Game::~Game() { saveDemoFile(); // Restaura el metodo de control - if (numPlayers == 1) { - Options::inputs[0].deviceType = onePlayerControl; + if (num_players_ == 1) { + Options::inputs[0].deviceType = one_player_control_; } // Elimina todos los objetos contenidos en vectores (jugadores, balas, etc.) @@ -102,137 +102,137 @@ Game::~Game() { // Las texturas, animaciones, Text, Menu, sonidos y música son propiedad // de Resource — no se liberan aquí. Solo limpiamos nuestras vistas. - playerAnimations.clear(); - balloonAnimations.clear(); - itemAnimations.clear(); - player1Textures.clear(); - player2Textures.clear(); - itemTextures.clear(); - balloonTextures.clear(); + player_animations_.clear(); + balloon_animations_.clear(); + item_animations_.clear(); + player1_textures_.clear(); + player2_textures_.clear(); + item_textures_.clear(); + balloon_textures_.clear(); - delete fade; - delete eventHandler; - delete clouds1A; - delete clouds1B; - delete clouds2A; - delete clouds2B; - delete n1000Sprite; - delete n2500Sprite; - delete n5000Sprite; - delete buildingsSprite; + delete fade_; + delete event_handler_; + delete clouds1_a_; + delete clouds1_b_; + delete clouds2_a_; + delete clouds2_b_; + delete n1000_sprite_; + delete n2500_sprite_; + delete n5000_sprite_; + delete buildings_sprite_; - delete skyColorsSprite; - delete grassSprite; - delete powerMeterSprite; - delete gameOverSprite; - delete gameOverEndSprite; + delete sky_colors_sprite_; + delete grass_sprite_; + delete power_meter_sprite_; + delete game_over_sprite_; + delete game_over_end_sprite_; } // Inicializa las variables necesarias para la sección 'Game' void Game::init() { - ticks = 0; - ticksSpeed = 15; + ticks_ = 0; + ticks_speed_ = 15; // Elimina qualquier jugador que hubiese antes de crear los nuevos - for (auto *player : players) { + for (auto *player : players_) { delete player; }; - players.clear(); + players_.clear(); // Crea los jugadores - if (numPlayers == 1) { - auto *player = new Player(PLAY_AREA_CENTER_X - 11, PLAY_AREA_BOTTOM - 24, renderer, playerTextures[Options::settings.player_selected], playerAnimations); - players.push_back(player); + if (num_players_ == 1) { + auto *player = new Player(PLAY_AREA_CENTER_X - 11, PLAY_AREA_BOTTOM - 24, renderer_, player_textures_[Options::settings.player_selected], player_animations_); + players_.push_back(player); } - else if (numPlayers == 2) { - auto *player1 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((0 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, renderer, playerTextures[0], playerAnimations); - auto *player2 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((1 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, renderer, playerTextures[1], playerAnimations); - players.push_back(player1); - players.push_back(player2); + else if (num_players_ == 2) { + auto *player1 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((0 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, renderer_, player_textures_[0], player_animations_); + auto *player2 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((1 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, renderer_, player_textures_[1], player_animations_); + players_.push_back(player1); + players_.push_back(player2); } // Inicializa las variables - switch (difficulty) { + switch (difficulty_) { case DIFFICULTY_EASY: - defaultEnemySpeed = BALLOON_SPEED_1; - difficultyScoreMultiplier = 0.5F; - difficultyColor = {75, 105, 47}; - pauseMenu->setSelectorColor(difficultyColor, 255); - gameOverMenu->setSelectorColor(difficultyColor, 255); + default_enemy_speed_ = Balloon::SPEED_1; + difficulty_score_multiplier_ = 0.5F; + difficulty_color_ = {75, 105, 47}; + pause_menu_->setSelectorColor(difficulty_color_, 255); + game_over_menu_->setSelectorColor(difficulty_color_, 255); break; case DIFFICULTY_NORMAL: - defaultEnemySpeed = BALLOON_SPEED_1; - difficultyScoreMultiplier = 1.0F; - difficultyColor = {255, 122, 0}; - pauseMenu->setSelectorColor(difficultyColor, 255); - gameOverMenu->setSelectorColor(difficultyColor, 255); + default_enemy_speed_ = Balloon::SPEED_1; + difficulty_score_multiplier_ = 1.0F; + difficulty_color_ = {255, 122, 0}; + pause_menu_->setSelectorColor(difficulty_color_, 255); + game_over_menu_->setSelectorColor(difficulty_color_, 255); break; case DIFFICULTY_HARD: - defaultEnemySpeed = BALLOON_SPEED_5; - difficultyScoreMultiplier = 1.5F; - difficultyColor = {118, 66, 138}; - pauseMenu->setSelectorColor(difficultyColor, 255); - gameOverMenu->setSelectorColor(difficultyColor, 255); + default_enemy_speed_ = Balloon::SPEED_5; + difficulty_score_multiplier_ = 1.5F; + difficulty_color_ = {118, 66, 138}; + pause_menu_->setSelectorColor(difficulty_color_, 255); + game_over_menu_->setSelectorColor(difficulty_color_, 255); break; default: break; } - gameCompleted = false; - gameCompletedCounter = 0; - section->name = SECTION_PROG_GAME; - section->subsection = SUBSECTION_GAME_PLAY_1P; - menaceCurrent = 0; - menaceThreshold = 0; - hiScoreAchieved = false; - stageBitmapCounter = STAGE_COUNTER; - deathCounter = Player::DEATH_COUNTER; - timeStopped = false; - timeStoppedCounter = 0; - counter = 0; - lastEnemyDeploy = 0; - enemyDeployCounter = 0; - enemySpeed = defaultEnemySpeed; - effect.flash = false; - effect.shake = false; - effect.shakeCounter = SHAKE_COUNTER; - deathShake.active = false; - deathShake.step = 0; - deathShake.lastStepTicks = 0; - deathSequence.phase = DeathPhase::None; - deathSequence.phaseStartTicks = 0; - deathSequence.player = nullptr; - helper.needCoffee = false; - helper.needCoffeeMachine = false; - helper.needPowerBall = false; - helper.counter = HELP_COUNTER; - helper.itemPoints1Odds = ITEM_POINTS_1_DISK_ODDS; - helper.itemPoints2Odds = ITEM_POINTS_2_GAVINA_ODDS; - helper.itemPoints3Odds = ITEM_POINTS_3_PACMAR_ODDS; - helper.itemClockOdds = ITEM_CLOCK_ODDS; - helper.itemCoffeeOdds = ITEM_COFFEE_ODDS; - helper.itemCoffeeMachineOdds = ITEM_COFFEE_MACHINE_ODDS; - powerBallEnabled = false; - powerBallCounter = 0; - coffeeMachineEnabled = false; - pauseCounter = 0; - leavingPauseMenu = false; - pauseInitialized = false; - gameOverInitialized = false; - gameOverPostFade = 0; + game_completed_ = false; + game_completed_counter_ = 0; + section_->name = SECTION_PROG_GAME; + section_->subsection = SUBSECTION_GAME_PLAY_1P; + menace_current_ = 0; + menace_threshold_ = 0; + hi_score_achieved_ = false; + stage_bitmap_counter_ = STAGE_COUNTER; + death_counter_ = Player::DEATH_COUNTER; + time_stopped_ = false; + time_stopped_counter_ = 0; + counter_ = 0; + last_enemy_deploy_ = 0; + enemy_deploy_counter_ = 0; + enemy_speed_ = default_enemy_speed_; + effect_.flash = false; + effect_.shake = false; + effect_.shake_counter = SHAKE_COUNTER; + death_shake_.active = false; + death_shake_.step = 0; + death_shake_.last_step_ticks = 0; + death_sequence_.phase = DeathPhase::NONE; + death_sequence_.phase_start_ticks = 0; + death_sequence_.player = nullptr; + helper_.need_coffee = false; + helper_.need_coffee_machine = false; + helper_.need_power_ball = false; + helper_.counter = HELP_COUNTER; + helper_.item_disk_odds = ITEM_POINTS_1_DISK_ODDS; + helper_.item_gavina_odds = ITEM_POINTS_2_GAVINA_ODDS; + helper_.item_paco_odds = ITEM_POINTS_3_PACMAR_ODDS; + helper_.item_clock_odds = ITEM_CLOCK_ODDS; + helper_.item_coffee_odds = ITEM_COFFEE_ODDS; + helper_.item_coffee_machine_odds = ITEM_COFFEE_MACHINE_ODDS; + power_ball_enabled_ = false; + power_ball_counter_ = 0; + coffee_machine_enabled_ = false; + pause_counter_ = 0; + leaving_pause_menu_ = false; + pause_initialized_ = false; + game_over_initialized_ = false; + game_over_post_fade_ = 0; - if (demo.enabled) { + if (demo_.enabled) { const int num = rand() % 2; if (num == 0) { - balloonsPopped = 1000; - currentStage = 3; + balloons_popped_ = 1000; + current_stage_ = 3; } else { - balloonsPopped = 1800; - currentStage = 6; + balloons_popped_ = 1800; + current_stage_ = 6; } } @@ -242,85 +242,85 @@ void Game::init() { initGameStages(); // Mas variables - balloonsPopped = 0; - for (int i = 0; i < currentStage; ++i) { - balloonsPopped += stage[i].powerToComplete; + balloons_popped_ = 0; + for (int i = 0; i < current_stage_; ++i) { + balloons_popped_ += stage_[i].power_to_complete; } - totalPowerToCompleteGame = 0; - for (auto &i : stage) { - totalPowerToCompleteGame += i.powerToComplete; + total_power_to_complete_game_ = 0; + for (auto &i : stage_) { + total_power_to_complete_game_ += i.power_to_complete; } // Modo demo - demo.recording = false; - demo.counter = 0; + demo_.recording = false; + demo_.counter = 0; // Inicializa el objeto para el fundido - fade->init(0x27, 0x27, 0x36); + fade_->init(0x27, 0x27, 0x36); // Sprites - clouds1A->setSpriteClip(0, 0, 256, 52); - clouds1B->setSpriteClip(0, 0, 256, 52); - clouds2A->setSpriteClip(0, 52, 256, 32); - clouds2B->setSpriteClip(0, 52, 256, 32); + clouds1_a_->setSpriteClip(0, 0, 256, 52); + clouds1_b_->setSpriteClip(0, 0, 256, 52); + clouds2_a_->setSpriteClip(0, 52, 256, 32); + clouds2_b_->setSpriteClip(0, 52, 256, 32); - grassSprite->setPosY(154); - powerMeterSprite->setSpriteClip(0, 0, 40, 7); + grass_sprite_->setPosY(154); + power_meter_sprite_->setSpriteClip(0, 0, 40, 7); // Con los globos creados, calcula el nivel de amenaza evaluateAndSetMenace(); // Inicializa el bitmap de 1000 puntos - n1000Sprite->setPosX(0); - n1000Sprite->setPosY(0); - n1000Sprite->setWidth(26); - n1000Sprite->setHeight(9); - n1000Sprite->setVelX(0.0F); - n1000Sprite->setVelY(-0.5F); - n1000Sprite->setAccelX(0.0F); - n1000Sprite->setAccelY(-0.1F); - n1000Sprite->setSpriteClip(0, 0, 26, 9); - n1000Sprite->setEnabled(false); - n1000Sprite->setEnabledCounter(0); - n1000Sprite->setDestX(0); - n1000Sprite->setDestY(0); + n1000_sprite_->setPosX(0); + n1000_sprite_->setPosY(0); + n1000_sprite_->setWidth(26); + n1000_sprite_->setHeight(9); + n1000_sprite_->setVelX(0.0F); + n1000_sprite_->setVelY(-0.5F); + n1000_sprite_->setAccelX(0.0F); + n1000_sprite_->setAccelY(-0.1F); + n1000_sprite_->setSpriteClip(0, 0, 26, 9); + n1000_sprite_->setEnabled(false); + n1000_sprite_->setEnabledCounter(0); + n1000_sprite_->setDestX(0); + n1000_sprite_->setDestY(0); // Inicializa el bitmap de 2500 puntos - n2500Sprite->setPosX(0); - n2500Sprite->setPosY(0); - n2500Sprite->setWidth(28); - n2500Sprite->setHeight(9); - n2500Sprite->setVelX(0.0F); - n2500Sprite->setVelY(-0.5F); - n2500Sprite->setAccelX(0.0F); - n2500Sprite->setAccelY(-0.1F); - n2500Sprite->setSpriteClip(26, 0, 28, 9); - n2500Sprite->setEnabled(false); - n2500Sprite->setEnabledCounter(0); - n2500Sprite->setDestX(0); - n2500Sprite->setDestY(0); + n2500_sprite_->setPosX(0); + n2500_sprite_->setPosY(0); + n2500_sprite_->setWidth(28); + n2500_sprite_->setHeight(9); + n2500_sprite_->setVelX(0.0F); + n2500_sprite_->setVelY(-0.5F); + n2500_sprite_->setAccelX(0.0F); + n2500_sprite_->setAccelY(-0.1F); + n2500_sprite_->setSpriteClip(26, 0, 28, 9); + n2500_sprite_->setEnabled(false); + n2500_sprite_->setEnabledCounter(0); + n2500_sprite_->setDestX(0); + n2500_sprite_->setDestY(0); // Inicializa el bitmap de 5000 puntos - n5000Sprite->setPosX(0); - n5000Sprite->setPosY(0); - n5000Sprite->setWidth(28); - n5000Sprite->setHeight(9); - n5000Sprite->setVelX(0.0F); - n5000Sprite->setVelY(-0.5F); - n5000Sprite->setAccelX(0.0F); - n5000Sprite->setAccelY(-0.1F); - n5000Sprite->setSpriteClip(54, 0, 28, 9); - n5000Sprite->setEnabled(false); - n5000Sprite->setEnabledCounter(0); - n5000Sprite->setDestX(0); - n5000Sprite->setDestY(0); + n5000_sprite_->setPosX(0); + n5000_sprite_->setPosY(0); + n5000_sprite_->setWidth(28); + n5000_sprite_->setHeight(9); + n5000_sprite_->setVelX(0.0F); + n5000_sprite_->setVelY(-0.5F); + n5000_sprite_->setAccelX(0.0F); + n5000_sprite_->setAccelY(-0.1F); + n5000_sprite_->setSpriteClip(54, 0, 28, 9); + n5000_sprite_->setEnabled(false); + n5000_sprite_->setEnabledCounter(0); + n5000_sprite_->setDestX(0); + n5000_sprite_->setDestY(0); // Los fondos - skyColorsRect[0] = {.x = 0, .y = 0, .w = GAMECANVAS_WIDTH, .h = GAMECANVAS_HEIGHT}; - skyColorsRect[1] = {.x = 256, .y = 0, .w = GAMECANVAS_WIDTH, .h = GAMECANVAS_HEIGHT}; - skyColorsRect[2] = {.x = 0, .y = 192, .w = GAMECANVAS_WIDTH, .h = GAMECANVAS_HEIGHT}; - skyColorsRect[3] = {.x = 256, .y = 192, .w = GAMECANVAS_WIDTH, .h = GAMECANVAS_HEIGHT}; + sky_colors_rect_[0] = {.x = 0, .y = 0, .w = GAMECANVAS_WIDTH, .h = GAMECANVAS_HEIGHT}; + sky_colors_rect_[1] = {.x = 256, .y = 0, .w = GAMECANVAS_WIDTH, .h = GAMECANVAS_HEIGHT}; + sky_colors_rect_[2] = {.x = 0, .y = 192, .w = GAMECANVAS_WIDTH, .h = GAMECANVAS_HEIGHT}; + sky_colors_rect_[3] = {.x = 256, .y = 192, .w = GAMECANVAS_WIDTH, .h = GAMECANVAS_HEIGHT}; } // Carga los recursos necesarios para la sección 'Game' @@ -333,103 +333,103 @@ void Game::loadMedia() { Resource *R = Resource::get(); // Texturas (handles compartidos — no se liberan aquí) - bulletTexture = R->getTexture("bullet.png"); - gameBuildingsTexture = R->getTexture("game_buildings.png"); - gameCloudsTexture = R->getTexture("game_clouds.png"); - gameGrassTexture = R->getTexture("game_grass.png"); - gamePowerMeterTexture = R->getTexture("game_power_meter.png"); - gameSkyColorsTexture = R->getTexture("game_sky_colors.png"); - gameTextTexture = R->getTexture("game_text.png"); - gameOverTexture = R->getTexture("menu_game_over.png"); - gameOverEndTexture = R->getTexture("menu_game_over_end.png"); + 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"); // Texturas - Globos - balloonTextures.push_back(R->getTexture("balloon1.png")); - balloonTextures.push_back(R->getTexture("balloon2.png")); - balloonTextures.push_back(R->getTexture("balloon3.png")); - balloonTextures.push_back(R->getTexture("balloon4.png")); + 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")); // Texturas - Items - itemTextures.push_back(R->getTexture("item_points1_disk.png")); - itemTextures.push_back(R->getTexture("item_points2_gavina.png")); - itemTextures.push_back(R->getTexture("item_points3_pacmar.png")); - itemTextures.push_back(R->getTexture("item_clock.png")); - itemTextures.push_back(R->getTexture("item_coffee.png")); - itemTextures.push_back(R->getTexture("item_coffee_machine.png")); + 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")); // Texturas - Player1 - player1Textures.push_back(R->getTexture("player_bal1_head.png")); - player1Textures.push_back(R->getTexture("player_bal1_body.png")); - player1Textures.push_back(R->getTexture("player_bal1_legs.png")); - player1Textures.push_back(R->getTexture("player_bal1_death.png")); - player1Textures.push_back(R->getTexture("player_bal1_fire.png")); - playerTextures.push_back(player1Textures); + 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")); + player_textures_.push_back(player1_textures_); // Texturas - Player2 - player2Textures.push_back(R->getTexture("player_arounder_head.png")); - player2Textures.push_back(R->getTexture("player_arounder_body.png")); - player2Textures.push_back(R->getTexture("player_arounder_legs.png")); - player2Textures.push_back(R->getTexture("player_arounder_death.png")); - player2Textures.push_back(R->getTexture("player_arounder_fire.png")); - playerTextures.push_back(player2Textures); + 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")); + player_textures_.push_back(player2_textures_); // Animaciones (handles a los vectores raw de Resource — no se liberan) - playerAnimations.push_back(&R->getAnimationLines("player_head.ani")); - playerAnimations.push_back(&R->getAnimationLines("player_body.ani")); - playerAnimations.push_back(&R->getAnimationLines("player_legs.ani")); - playerAnimations.push_back(&R->getAnimationLines("player_death.ani")); - playerAnimations.push_back(&R->getAnimationLines("player_fire.ani")); + 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")); - balloonAnimations.push_back(&R->getAnimationLines("balloon1.ani")); - balloonAnimations.push_back(&R->getAnimationLines("balloon2.ani")); - balloonAnimations.push_back(&R->getAnimationLines("balloon3.ani")); - balloonAnimations.push_back(&R->getAnimationLines("balloon4.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")); - itemAnimations.push_back(&R->getAnimationLines("item_points1_disk.ani")); - itemAnimations.push_back(&R->getAnimationLines("item_points2_gavina.ani")); - itemAnimations.push_back(&R->getAnimationLines("item_points3_pacmar.ani")); - itemAnimations.push_back(&R->getAnimationLines("item_clock.ani")); - itemAnimations.push_back(&R->getAnimationLines("item_coffee.ani")); - itemAnimations.push_back(&R->getAnimationLines("item_coffee_machine.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")); // Texto - text = R->getText("smb2"); - textScoreBoard = R->getText("8bithud"); - textBig = R->getText("smb2_big"); - textNokia2 = R->getText("nokia2"); - textNokiaBig2 = R->getText("nokia_big2"); + 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"); // Menus - gameOverMenu = R->getMenu("gameover"); - gameOverMenu->setItemCaption(0, Lang::get()->getText(48)); - gameOverMenu->setItemCaption(1, Lang::get()->getText(49)); - const int w = text->getCharacterSize() * Lang::get()->getText(45).length(); - gameOverMenu->setRectSize(w, 0); - gameOverMenu->centerMenuOnX(199); - pauseMenu = R->getMenu("pause"); - pauseMenu->setItemCaption(0, Lang::get()->getText(41)); - pauseMenu->setItemCaption(1, Lang::get()->getText(46)); - pauseMenu->setItemCaption(2, Lang::get()->getText(47)); + game_over_menu_ = R->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); + game_over_menu_->centerMenuOnX(199); + pause_menu_ = R->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 - balloonSound = R->getSound("balloon.wav"); - bubble1Sound = R->getSound("bubble1.wav"); - bubble2Sound = R->getSound("bubble2.wav"); - bubble3Sound = R->getSound("bubble3.wav"); - bubble4Sound = R->getSound("bubble4.wav"); - bulletSound = R->getSound("bullet.wav"); - clockSound = R->getSound("clock.wav"); - coffeeOutSound = R->getSound("coffeeout.wav"); - hiScoreSound = R->getSound("hiscore.wav"); - itemDropSound = R->getSound("itemdrop.wav"); - itemPickUpSound = R->getSound("itempickup.wav"); - playerCollisionSound = R->getSound("player_collision.wav"); - powerBallSound = R->getSound("powerball.wav"); - stageChangeSound = R->getSound("stage_change.wav"); - coffeeMachineSound = R->getSound("title.wav"); + 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"); // Musicas - gameMusic = R->getMusic("playing.ogg"); + game_music_ = R->getMusic("playing.ogg"); if (Options::settings.console) { std::cout << "** RESOURCES FOR GAME SECTION LOADED" << '\n' @@ -459,7 +459,7 @@ auto Game::loadScoreFile() -> bool { } // Inicializamos los datos - for (unsigned int &i : scoreDataFile) { + for (unsigned int &i : score_data_file_) { i = 0; SDL_WriteIO(file, &i, sizeof(Uint32)); } @@ -479,7 +479,7 @@ auto Game::loadScoreFile() -> bool { if (Options::settings.console) { std::cout << "Reading file " << filename.c_str() << '\n'; } - for (unsigned int &i : scoreDataFile) { + for (unsigned int &i : score_data_file_) { SDL_ReadIO(file, &i, sizeof(Uint32)); } @@ -489,10 +489,10 @@ auto Game::loadScoreFile() -> bool { // Estableix el hi-score si el fitxer és vàlid (≠ 0) i el checksum quadra; // en qualsevol altre cas (fitxer absent, corrupte o manipulat) usa el default. - if (scoreDataFile[0] != 0 && scoreDataFile[0] % 43 == scoreDataFile[1]) { - hiScore = scoreDataFile[0]; + if (score_data_file_[0] != 0 && score_data_file_[0] % 43 == score_data_file_[1]) { + hi_score_ = score_data_file_[0]; } else { - hiScore = 10000; + hi_score_ = 10000; } return success; @@ -505,7 +505,7 @@ auto Game::loadDemoFile() -> bool { const size_t expected = sizeof(DemoKeys) * TOTAL_DEMO_DATA; if (bytes.size() >= expected) { for (int i = 0; i < TOTAL_DEMO_DATA; ++i) { - memcpy(&demo.dataFile[i], bytes.data() + (i * sizeof(DemoKeys)), sizeof(DemoKeys)); + memcpy(&demo_.data_file[i], bytes.data() + (i * sizeof(DemoKeys)), sizeof(DemoKeys)); } if (Options::settings.console) { std::cout << "Demo data loaded (" << bytes.size() << " bytes)" << '\n'; @@ -515,14 +515,14 @@ auto Game::loadDemoFile() -> bool { if (Options::settings.console) { std::cout << "Warning: demo data missing or too small, initializing to zero" << '\n'; } - for (auto &i : demo.dataFile) { - demo.keys.left = 0; - demo.keys.right = 0; - demo.keys.noInput = 0; - demo.keys.fire = 0; - demo.keys.fireLeft = 0; - demo.keys.fireRight = 0; - i = demo.keys; + for (auto &i : demo_.data_file) { + demo_.keys.left = 0; + demo_.keys.right = 0; + demo_.keys.noInput = 0; + demo_.keys.fire = 0; + demo_.keys.fireLeft = 0; + demo_.keys.fireRight = 0; + i = demo_.keys; } } return true; @@ -536,7 +536,7 @@ auto Game::saveScoreFile() -> bool { SDL_IOStream *file = SDL_IOFromFile(p.c_str(), "w+b"); if (file != nullptr) { // Guardamos los datos - for (unsigned int &i : scoreDataFile) { + for (unsigned int &i : score_data_file_) { SDL_WriteIO(file, &i, sizeof(Uint32)); } @@ -559,11 +559,11 @@ 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); - if (demo.recording) { + if (demo_.recording) { SDL_IOStream *file = SDL_IOFromFile(p.c_str(), "w+b"); if (file != nullptr) { // Guardamos los datos - for (auto &i : demo.dataFile) { + for (auto &i : demo_.data_file) { SDL_WriteIO(file, &i, sizeof(DemoKeys)); } @@ -586,30 +586,30 @@ auto Game::saveDemoFile() -> bool { 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 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 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 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 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 : enemyFormation) { - i.numberOfEnemies = 0; + for (auto &i : enemy_formation_) { + i.number_of_enemies = 0; for (auto &j : i.init) { j.x = 0; j.y = 0; - j.velX = 0; + j.vel_x = 0; j.kind = 0; - j.creationCounter = 0; + j.creation_counter = 0; } } @@ -620,693 +620,693 @@ void Game::initEnemyFormations() { // #00 - Dos enemigos BALLOON4 uno a cada extremo j = 0; - enemyFormation[j].numberOfEnemies = 2; + enemy_formation_[j].number_of_enemies = 2; incX = x4_100; incTime = 0; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - enemyFormation[j].init[i].x = x4_0 + (i * incX); - enemyFormation[j].init[i].y = y4; - enemyFormation[j].init[i].velX = BALLOON_VELX_NEGATIVE * (((i % 2) * 2) - 1); - enemyFormation[j].init[i].kind = BALLOON_4; - enemyFormation[j].init[i].creationCounter = creationTime + (incTime * i); + 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].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); } // #01 - Dos enemigos BALLOON4 uno a cada cuarto. Ambos van hacia el centro j = 1; - enemyFormation[j].numberOfEnemies = 2; + enemy_formation_[j].number_of_enemies = 2; incX = PLAY_AREA_CENTER_X; incTime = 0; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - enemyFormation[j].init[i].x = PLAY_AREA_CENTER_FIRST_QUARTER_X - (BALLOON_WIDTH_4 / 2) + (i * incX); - enemyFormation[j].init[i].y = y4; - enemyFormation[j].init[i].velX = BALLOON_VELX_NEGATIVE * (((i % 2) * 2) - 1); - enemyFormation[j].init[i].kind = BALLOON_4; - enemyFormation[j].init[i].creationCounter = creationTime + (incTime * i); + 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].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); } // #02 - Cuatro enemigos BALLOON2 uno detras del otro. A la izquierda y hacia el centro j = 2; - enemyFormation[j].numberOfEnemies = 4; - incX = BALLOON_WIDTH_2 + 1; + enemy_formation_[j].number_of_enemies = 4; + incX = Balloon::WIDTH_2 + 1; incTime = 10; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - enemyFormation[j].init[i].x = x2_0 + (i * incX); - enemyFormation[j].init[i].y = y2; - enemyFormation[j].init[i].velX = BALLOON_VELX_POSITIVE; - enemyFormation[j].init[i].kind = BALLOON_2; - enemyFormation[j].init[i].creationCounter = creationTime - (incTime * i); + 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].vel_x = Balloon::VELX_POSITIVE; + enemy_formation_[j].init[i].kind = Balloon::BALLOON_2; + enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); } // #03 - Cuatro enemigos BALLOON2 uno detras del otro. A la derecha y hacia el centro j = 3; - enemyFormation[j].numberOfEnemies = 4; - incX = BALLOON_WIDTH_2 + 1; + enemy_formation_[j].number_of_enemies = 4; + incX = Balloon::WIDTH_2 + 1; incTime = 10; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - enemyFormation[j].init[i].x = x2_100 - (i * incX); - enemyFormation[j].init[i].y = y2; - enemyFormation[j].init[i].velX = BALLOON_VELX_NEGATIVE; - enemyFormation[j].init[i].kind = BALLOON_2; - enemyFormation[j].init[i].creationCounter = creationTime - (incTime * i); + 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].vel_x = Balloon::VELX_NEGATIVE; + enemy_formation_[j].init[i].kind = Balloon::BALLOON_2; + enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); } // #04 - Tres enemigos BALLOON3. 0, 25, 50. Hacia la derecha j = 4; - enemyFormation[j].numberOfEnemies = 3; - incX = BALLOON_WIDTH_3 * 2; + enemy_formation_[j].number_of_enemies = 3; + incX = Balloon::WIDTH_3 * 2; incTime = 10; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - enemyFormation[j].init[i].x = x3_0 + (i * incX); - enemyFormation[j].init[i].y = y3; - enemyFormation[j].init[i].velX = BALLOON_VELX_POSITIVE; - enemyFormation[j].init[i].kind = BALLOON_3; - enemyFormation[j].init[i].creationCounter = creationTime - (incTime * i); + 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].vel_x = Balloon::VELX_POSITIVE; + enemy_formation_[j].init[i].kind = Balloon::BALLOON_3; + enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); } // #05 - Tres enemigos BALLOON3. 50, 75, 100. Hacia la izquierda j = 5; - enemyFormation[j].numberOfEnemies = 3; - incX = BALLOON_WIDTH_3 * 2; + enemy_formation_[j].number_of_enemies = 3; + incX = Balloon::WIDTH_3 * 2; incTime = 10; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - enemyFormation[j].init[i].x = x3_100 - (i * incX); - enemyFormation[j].init[i].y = y3; - enemyFormation[j].init[i].velX = BALLOON_VELX_NEGATIVE; - enemyFormation[j].init[i].kind = BALLOON_3; - enemyFormation[j].init[i].creationCounter = creationTime - (incTime * i); + 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].vel_x = Balloon::VELX_NEGATIVE; + enemy_formation_[j].init[i].kind = Balloon::BALLOON_3; + enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); } // #06 - Tres enemigos BALLOON3. 0, 0, 0. Hacia la derecha j = 6; - enemyFormation[j].numberOfEnemies = 3; - incX = BALLOON_WIDTH_3 + 1; + enemy_formation_[j].number_of_enemies = 3; + incX = Balloon::WIDTH_3 + 1; incTime = 10; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - enemyFormation[j].init[i].x = x3_0 + (i * incX); - enemyFormation[j].init[i].y = y3; - enemyFormation[j].init[i].velX = BALLOON_VELX_POSITIVE; - enemyFormation[j].init[i].kind = BALLOON_3; - enemyFormation[j].init[i].creationCounter = creationTime - (incTime * i); + 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].vel_x = Balloon::VELX_POSITIVE; + enemy_formation_[j].init[i].kind = Balloon::BALLOON_3; + enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); } // #07 - Tres enemigos BALLOON3. 100, 100, 100. Hacia la izquierda j = 7; - enemyFormation[j].numberOfEnemies = 3; - incX = BALLOON_WIDTH_3 + 1; + enemy_formation_[j].number_of_enemies = 3; + incX = Balloon::WIDTH_3 + 1; incTime = 10; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - enemyFormation[j].init[i].x = x3_100 - (i * incX); - enemyFormation[j].init[i].y = y3; - enemyFormation[j].init[i].velX = BALLOON_VELX_NEGATIVE; - enemyFormation[j].init[i].kind = BALLOON_3; - enemyFormation[j].init[i].creationCounter = creationTime - (incTime * i); + 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].vel_x = Balloon::VELX_NEGATIVE; + enemy_formation_[j].init[i].kind = Balloon::BALLOON_3; + enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); } // #08 - Seis enemigos BALLOON1. 0, 0, 0, 0, 0, 0. Hacia la derecha j = 8; - enemyFormation[j].numberOfEnemies = 6; - incX = BALLOON_WIDTH_1 + 1; + enemy_formation_[j].number_of_enemies = 6; + incX = Balloon::WIDTH_1 + 1; incTime = 10; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - enemyFormation[j].init[i].x = x1_0 + (i * incX); - enemyFormation[j].init[i].y = 13; - enemyFormation[j].init[i].velX = BALLOON_VELX_POSITIVE; - enemyFormation[j].init[i].kind = BALLOON_1; - enemyFormation[j].init[i].creationCounter = creationTime - (incTime * i); + 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 = 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); } // #09 - Seis enemigos BALLOON1. 100, 100, 100, 100, 100, 100. Hacia la izquierda j = 9; - enemyFormation[j].numberOfEnemies = 6; - incX = BALLOON_WIDTH_1 + 1; + enemy_formation_[j].number_of_enemies = 6; + incX = Balloon::WIDTH_1 + 1; incTime = 10; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - enemyFormation[j].init[i].x = x1_100 - (i * incX); - enemyFormation[j].init[i].y = 13; - enemyFormation[j].init[i].velX = BALLOON_VELX_NEGATIVE; - enemyFormation[j].init[i].kind = BALLOON_1; - enemyFormation[j].init[i].creationCounter = creationTime - (incTime * i); + 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 = 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); } // #10 - Tres enemigos BALLOON4 seguidos desde la izquierda j = 10; - enemyFormation[j].numberOfEnemies = 3; - incX = BALLOON_WIDTH_4 + 1; + enemy_formation_[j].number_of_enemies = 3; + incX = Balloon::WIDTH_4 + 1; incTime = 15; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - enemyFormation[j].init[i].x = x4_0 + (i * incX); - enemyFormation[j].init[i].y = y4; - enemyFormation[j].init[i].velX = BALLOON_VELX_POSITIVE; - enemyFormation[j].init[i].kind = BALLOON_4; - enemyFormation[j].init[i].creationCounter = creationTime - (incTime * i); + 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].vel_x = Balloon::VELX_POSITIVE; + enemy_formation_[j].init[i].kind = Balloon::BALLOON_4; + enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); } // #11 - Tres enemigos BALLOON4 seguidos desde la derecha j = 11; - enemyFormation[j].numberOfEnemies = 3; - incX = BALLOON_WIDTH_4 + 1; + enemy_formation_[j].number_of_enemies = 3; + incX = Balloon::WIDTH_4 + 1; incTime = 15; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - enemyFormation[j].init[i].x = x4_100 - (i * incX); - enemyFormation[j].init[i].y = y4; - enemyFormation[j].init[i].velX = BALLOON_VELX_NEGATIVE; - enemyFormation[j].init[i].kind = BALLOON_4; - enemyFormation[j].init[i].creationCounter = creationTime - (incTime * i); + 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].vel_x = Balloon::VELX_NEGATIVE; + enemy_formation_[j].init[i].kind = Balloon::BALLOON_4; + enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); } // #12 - Seis enemigos BALLOON2 uno detras del otro. A la izquierda y hacia el centro j = 12; - enemyFormation[j].numberOfEnemies = 6; - incX = BALLOON_WIDTH_2 + 1; + enemy_formation_[j].number_of_enemies = 6; + incX = Balloon::WIDTH_2 + 1; incTime = 10; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - enemyFormation[j].init[i].x = x2_0 + (i * incX); - enemyFormation[j].init[i].y = y2; - enemyFormation[j].init[i].velX = BALLOON_VELX_POSITIVE; - enemyFormation[j].init[i].kind = BALLOON_2; - enemyFormation[j].init[i].creationCounter = creationTime - (incTime * i); + 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].vel_x = Balloon::VELX_POSITIVE; + enemy_formation_[j].init[i].kind = Balloon::BALLOON_2; + enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); } // #13 - Seis enemigos BALLOON2 uno detras del otro. A la derecha y hacia el centro j = 13; - enemyFormation[j].numberOfEnemies = 6; - incX = BALLOON_WIDTH_2 + 1; + enemy_formation_[j].number_of_enemies = 6; + incX = Balloon::WIDTH_2 + 1; incTime = 10; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - enemyFormation[j].init[i].x = x2_100 - (i * incX); - enemyFormation[j].init[i].y = y2; - enemyFormation[j].init[i].velX = BALLOON_VELX_NEGATIVE; - enemyFormation[j].init[i].kind = BALLOON_2; - enemyFormation[j].init[i].creationCounter = creationTime - (incTime * i); + 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].vel_x = Balloon::VELX_NEGATIVE; + enemy_formation_[j].init[i].kind = Balloon::BALLOON_2; + enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); } // #14 - Cinco enemigos BALLOON3. Hacia la derecha. Separados j = 14; - enemyFormation[j].numberOfEnemies = 5; - incX = BALLOON_WIDTH_3 * 2; + enemy_formation_[j].number_of_enemies = 5; + incX = Balloon::WIDTH_3 * 2; incTime = 10; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - enemyFormation[j].init[i].x = x3_0 + (i * incX); - enemyFormation[j].init[i].y = y3; - enemyFormation[j].init[i].velX = BALLOON_VELX_POSITIVE; - enemyFormation[j].init[i].kind = BALLOON_3; - enemyFormation[j].init[i].creationCounter = creationTime - (incTime * i); + 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].vel_x = Balloon::VELX_POSITIVE; + enemy_formation_[j].init[i].kind = Balloon::BALLOON_3; + enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); } // #15 - Cinco enemigos BALLOON3. Hacia la izquierda. Separados j = 15; - enemyFormation[j].numberOfEnemies = 5; - incX = BALLOON_WIDTH_3 * 2; + enemy_formation_[j].number_of_enemies = 5; + incX = Balloon::WIDTH_3 * 2; incTime = 10; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - enemyFormation[j].init[i].x = x3_100 - (i * incX); - enemyFormation[j].init[i].y = y3; - enemyFormation[j].init[i].velX = BALLOON_VELX_NEGATIVE; - enemyFormation[j].init[i].kind = BALLOON_3; - enemyFormation[j].init[i].creationCounter = creationTime - (incTime * i); + 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].vel_x = Balloon::VELX_NEGATIVE; + enemy_formation_[j].init[i].kind = Balloon::BALLOON_3; + enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); } // #16 - Cinco enemigos BALLOON3. Hacia la derecha. Juntos j = 16; - enemyFormation[j].numberOfEnemies = 5; - incX = BALLOON_WIDTH_3 + 1; + enemy_formation_[j].number_of_enemies = 5; + incX = Balloon::WIDTH_3 + 1; incTime = 10; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - enemyFormation[j].init[i].x = x3_0 + (i * incX); - enemyFormation[j].init[i].y = y3; - enemyFormation[j].init[i].velX = BALLOON_VELX_POSITIVE; - enemyFormation[j].init[i].kind = BALLOON_3; - enemyFormation[j].init[i].creationCounter = creationTime - (incTime * i); + 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].vel_x = Balloon::VELX_POSITIVE; + enemy_formation_[j].init[i].kind = Balloon::BALLOON_3; + enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); } // #17 - Cinco enemigos BALLOON3. Hacia la izquierda. Juntos j = 17; - enemyFormation[j].numberOfEnemies = 5; - incX = BALLOON_WIDTH_3 + 1; + enemy_formation_[j].number_of_enemies = 5; + incX = Balloon::WIDTH_3 + 1; incTime = 10; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - enemyFormation[j].init[i].x = x3_100 - (i * incX); - enemyFormation[j].init[i].y = y3; - enemyFormation[j].init[i].velX = BALLOON_VELX_NEGATIVE; - enemyFormation[j].init[i].kind = BALLOON_3; - enemyFormation[j].init[i].creationCounter = creationTime - (incTime * i); + 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].vel_x = Balloon::VELX_NEGATIVE; + enemy_formation_[j].init[i].kind = Balloon::BALLOON_3; + enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); } // #18 - Doce enemigos BALLOON1. Hacia la derecha. Juntos j = 18; - enemyFormation[j].numberOfEnemies = 12; - incX = BALLOON_WIDTH_1 + 1; + enemy_formation_[j].number_of_enemies = 12; + incX = Balloon::WIDTH_1 + 1; incTime = 10; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - enemyFormation[j].init[i].x = x1_0 + (i * incX); - enemyFormation[j].init[i].y = y1; - enemyFormation[j].init[i].velX = BALLOON_VELX_POSITIVE; - enemyFormation[j].init[i].kind = BALLOON_1; - enemyFormation[j].init[i].creationCounter = creationTime - (incTime * i); + 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].vel_x = Balloon::VELX_POSITIVE; + enemy_formation_[j].init[i].kind = Balloon::BALLOON_1; + enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); } // #19 - Doce enemigos BALLOON1. Hacia la izquierda. Juntos j = 19; - enemyFormation[j].numberOfEnemies = 12; - incX = BALLOON_WIDTH_1 + 1; + enemy_formation_[j].number_of_enemies = 12; + incX = Balloon::WIDTH_1 + 1; incTime = 10; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - enemyFormation[j].init[i].x = x1_100 - (i * incX); - enemyFormation[j].init[i].y = y1; - enemyFormation[j].init[i].velX = BALLOON_VELX_NEGATIVE; - enemyFormation[j].init[i].kind = BALLOON_1; - enemyFormation[j].init[i].creationCounter = creationTime - (incTime * i); + 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].vel_x = Balloon::VELX_NEGATIVE; + enemy_formation_[j].init[i].kind = Balloon::BALLOON_1; + enemy_formation_[j].init[i].creation_counter = creationTime - (incTime * i); } // #20 - Dos enemigos BALLOON4 seguidos desde la izquierda/derecha. Simetricos j = 20; - enemyFormation[j].numberOfEnemies = 4; - incX = BALLOON_WIDTH_4 + 1; + enemy_formation_[j].number_of_enemies = 4; + incX = Balloon::WIDTH_4 + 1; incTime = 0; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - Uint8 half = enemyFormation[j].numberOfEnemies / 2; + for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { + Uint8 half = enemy_formation_[j].number_of_enemies / 2; if (i < half) { - enemyFormation[j].init[i].x = x4_0 + (i * incX); - enemyFormation[j].init[i].velX = BALLOON_VELX_POSITIVE; + enemy_formation_[j].init[i].x = x4_0 + (i * incX); + enemy_formation_[j].init[i].vel_x = Balloon::VELX_POSITIVE; } else { - enemyFormation[j].init[i].x = x4_100 - ((i - half) * incX); - enemyFormation[j].init[i].velX = BALLOON_VELX_NEGATIVE; + enemy_formation_[j].init[i].x = x4_100 - ((i - half) * incX); + enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE; } - enemyFormation[j].init[i].y = y4; - enemyFormation[j].init[i].kind = BALLOON_4; - enemyFormation[j].init[i].creationCounter = creationTime + (incTime * i); + 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); } // #21 - Diez enemigos BALLOON2 uno detras del otro. Izquierda/derecha. Simetricos j = 21; - enemyFormation[j].numberOfEnemies = 10; - incX = BALLOON_WIDTH_2 + 1; + enemy_formation_[j].number_of_enemies = 10; + incX = Balloon::WIDTH_2 + 1; incTime = 3; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - Uint8 half = enemyFormation[j].numberOfEnemies / 2; + for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { + Uint8 half = enemy_formation_[j].number_of_enemies / 2; if (i < half) { - enemyFormation[j].init[i].x = x2_0 + (i * incX); - enemyFormation[j].init[i].velX = BALLOON_VELX_POSITIVE; - enemyFormation[j].init[i].creationCounter = (creationTime) - (incTime * i); + enemy_formation_[j].init[i].x = x2_0 + (i * incX); + enemy_formation_[j].init[i].vel_x = Balloon::VELX_POSITIVE; + enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * i); } else { - enemyFormation[j].init[i].x = x2_100 - ((i - half) * incX); - enemyFormation[j].init[i].velX = BALLOON_VELX_NEGATIVE; - enemyFormation[j].init[i].creationCounter = (creationTime) - (incTime * (i - half)); + enemy_formation_[j].init[i].x = x2_100 - ((i - half) * incX); + enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE; + enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * (i - half)); } - enemyFormation[j].init[i].y = y2; - enemyFormation[j].init[i].kind = BALLOON_2; + 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; - enemyFormation[j].numberOfEnemies = 10; - incX = BALLOON_WIDTH_3 * 2; + enemy_formation_[j].number_of_enemies = 10; + incX = Balloon::WIDTH_3 * 2; incTime = 10; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - Uint8 half = enemyFormation[j].numberOfEnemies / 2; + for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { + Uint8 half = enemy_formation_[j].number_of_enemies / 2; if (i < half) { - enemyFormation[j].init[i].x = x3_0 + (i * incX); - enemyFormation[j].init[i].velX = BALLOON_VELX_POSITIVE; - enemyFormation[j].init[i].creationCounter = (creationTime) - (incTime * i); + enemy_formation_[j].init[i].x = x3_0 + (i * incX); + enemy_formation_[j].init[i].vel_x = Balloon::VELX_POSITIVE; + enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * i); } else { - enemyFormation[j].init[i].x = x3_100 - ((i - half) * incX); - enemyFormation[j].init[i].velX = BALLOON_VELX_NEGATIVE; - enemyFormation[j].init[i].creationCounter = (creationTime) - (incTime * (i - half)); + enemy_formation_[j].init[i].x = x3_100 - ((i - half) * incX); + enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE; + enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * (i - half)); } - enemyFormation[j].init[i].y = y3; - enemyFormation[j].init[i].kind = BALLOON_3; + 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; - enemyFormation[j].numberOfEnemies = 10; - incX = BALLOON_WIDTH_3 + 1; + enemy_formation_[j].number_of_enemies = 10; + incX = Balloon::WIDTH_3 + 1; incTime = 10; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - Uint8 half = enemyFormation[j].numberOfEnemies / 2; + for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { + Uint8 half = enemy_formation_[j].number_of_enemies / 2; if (i < half) { - enemyFormation[j].init[i].x = x3_0 + (i * incX); - enemyFormation[j].init[i].velX = BALLOON_VELX_POSITIVE; - enemyFormation[j].init[i].creationCounter = (creationTime) - (incTime * i); + enemy_formation_[j].init[i].x = x3_0 + (i * incX); + enemy_formation_[j].init[i].vel_x = Balloon::VELX_POSITIVE; + enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * i); } else { - enemyFormation[j].init[i].x = x3_100 - ((i - half) * incX); - enemyFormation[j].init[i].velX = BALLOON_VELX_NEGATIVE; - enemyFormation[j].init[i].creationCounter = (creationTime) - (incTime * (i - half)); + enemy_formation_[j].init[i].x = x3_100 - ((i - half) * incX); + enemy_formation_[j].init[i].vel_x = Balloon::VELX_NEGATIVE; + enemy_formation_[j].init[i].creation_counter = (creationTime) - (incTime * (i - half)); } - enemyFormation[j].init[i].y = y3; - enemyFormation[j].init[i].kind = BALLOON_3; + 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; - enemyFormation[j].numberOfEnemies = 30; + enemy_formation_[j].number_of_enemies = 30; incTime = 5; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - Uint8 half = enemyFormation[j].numberOfEnemies / 2; + for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { + Uint8 half = enemy_formation_[j].number_of_enemies / 2; if (i < half) { - enemyFormation[j].init[i].x = x1_50; - enemyFormation[j].init[i].velX = BALLOON_VELX_POSITIVE; - enemyFormation[j].init[i].creationCounter = (creationTime) + (incTime * i); + 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); } else { - enemyFormation[j].init[i].x = x1_50; - enemyFormation[j].init[i].velX = BALLOON_VELX_NEGATIVE; - enemyFormation[j].init[i].creationCounter = (creationTime) + (incTime * (i - half)); + 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)); } - enemyFormation[j].init[i].y = y1; - enemyFormation[j].init[i].kind = BALLOON_1; + 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; - enemyFormation[j].numberOfEnemies = 30; + enemy_formation_[j].number_of_enemies = 30; incTime = 5; - for (int i = 0; i < enemyFormation[j].numberOfEnemies; i++) { - Uint8 half = enemyFormation[j].numberOfEnemies / 2; + for (int i = 0; i < enemy_formation_[j].number_of_enemies; i++) { + Uint8 half = enemy_formation_[j].number_of_enemies / 2; if (i < half) { - enemyFormation[j].init[i].x = x1_50 + 20; - enemyFormation[j].init[i].velX = BALLOON_VELX_NEGATIVE; - enemyFormation[j].init[i].creationCounter = (creationTime) - (incTime * i); + 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); } else { - enemyFormation[j].init[i].x = x1_50 - 20; - enemyFormation[j].init[i].velX = BALLOON_VELX_POSITIVE; - enemyFormation[j].init[i].creationCounter = (creationTime) - (incTime * (i - half)); + 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)); } - enemyFormation[j].init[i].y = y1; - enemyFormation[j].init[i].kind = BALLOON_1; + enemy_formation_[j].init[i].y = y1; + enemy_formation_[j].init[i].kind = Balloon::BALLOON_1; } // Crea las mismas formaciones pero con hexagonos a partir de la posición 50 del vector for (int k = 0; k < j + 1; k++) { - enemyFormation[k + 50].numberOfEnemies = enemyFormation[k].numberOfEnemies; - for (int i = 0; i < enemyFormation[k + 50].numberOfEnemies; i++) { - enemyFormation[k + 50].init[i].x = enemyFormation[k].init[i].x; - enemyFormation[k + 50].init[i].y = enemyFormation[k].init[i].y; - enemyFormation[k + 50].init[i].velX = enemyFormation[k].init[i].velX; - enemyFormation[k + 50].init[i].creationCounter = enemyFormation[k].init[i].creationCounter; - enemyFormation[k + 50].init[i].kind = enemyFormation[k].init[i].kind + 4; + enemy_formation_[k + 50].number_of_enemies = enemy_formation_[k].number_of_enemies; + for (int i = 0; i < enemy_formation_[k + 50].number_of_enemies; i++) { + enemy_formation_[k + 50].init[i].x = enemy_formation_[k].init[i].x; + enemy_formation_[k + 50].init[i].y = enemy_formation_[k].init[i].y; + enemy_formation_[k + 50].init[i].vel_x = enemy_formation_[k].init[i].vel_x; + enemy_formation_[k + 50].init[i].creation_counter = enemy_formation_[k].init[i].creation_counter; + enemy_formation_[k + 50].init[i].kind = enemy_formation_[k].init[i].kind + 4; } } // TEST - enemyFormation[99].numberOfEnemies = 4; + enemy_formation_[99].number_of_enemies = 4; - enemyFormation[99].init[0].x = 10; - enemyFormation[99].init[0].y = y1; - enemyFormation[99].init[0].velX = 0; - enemyFormation[99].init[0].kind = BALLOON_1; - enemyFormation[99].init[0].creationCounter = 200; + enemy_formation_[99].init[0].x = 10; + 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; - enemyFormation[99].init[1].x = 50; - enemyFormation[99].init[1].y = y1; - enemyFormation[99].init[1].velX = 0; - enemyFormation[99].init[1].kind = BALLOON_2; - enemyFormation[99].init[1].creationCounter = 200; + enemy_formation_[99].init[1].x = 50; + 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; - enemyFormation[99].init[2].x = 90; - enemyFormation[99].init[2].y = y1; - enemyFormation[99].init[2].velX = 0; - enemyFormation[99].init[2].kind = BALLOON_3; - enemyFormation[99].init[2].creationCounter = 200; + enemy_formation_[99].init[2].x = 90; + 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; - enemyFormation[99].init[3].x = 140; - enemyFormation[99].init[3].y = y1; - enemyFormation[99].init[3].velX = 0; - enemyFormation[99].init[3].kind = BALLOON_4; - enemyFormation[99].init[3].creationCounter = 200; + enemy_formation_[99].init[3].x = 140; + 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; } // Inicializa los conjuntos de formaciones void Game::initEnemyPools() { // EnemyPool #0 - enemyPool[0].set[0] = &enemyFormation[0]; - enemyPool[0].set[1] = &enemyFormation[1]; - enemyPool[0].set[2] = &enemyFormation[2]; - enemyPool[0].set[3] = &enemyFormation[3]; - enemyPool[0].set[4] = &enemyFormation[4]; - enemyPool[0].set[5] = &enemyFormation[5]; - enemyPool[0].set[6] = &enemyFormation[6]; - enemyPool[0].set[7] = &enemyFormation[7]; - enemyPool[0].set[8] = &enemyFormation[8]; - enemyPool[0].set[9] = &enemyFormation[9]; + enemy_pool_[0].set[0] = &enemy_formation_[0]; + enemy_pool_[0].set[1] = &enemy_formation_[1]; + enemy_pool_[0].set[2] = &enemy_formation_[2]; + enemy_pool_[0].set[3] = &enemy_formation_[3]; + enemy_pool_[0].set[4] = &enemy_formation_[4]; + enemy_pool_[0].set[5] = &enemy_formation_[5]; + enemy_pool_[0].set[6] = &enemy_formation_[6]; + enemy_pool_[0].set[7] = &enemy_formation_[7]; + enemy_pool_[0].set[8] = &enemy_formation_[8]; + enemy_pool_[0].set[9] = &enemy_formation_[9]; // EnemyPool #1 - enemyPool[1].set[0] = &enemyFormation[10]; - enemyPool[1].set[1] = &enemyFormation[11]; - enemyPool[1].set[2] = &enemyFormation[12]; - enemyPool[1].set[3] = &enemyFormation[13]; - enemyPool[1].set[4] = &enemyFormation[14]; - enemyPool[1].set[5] = &enemyFormation[15]; - enemyPool[1].set[6] = &enemyFormation[16]; - enemyPool[1].set[7] = &enemyFormation[17]; - enemyPool[1].set[8] = &enemyFormation[18]; - enemyPool[1].set[9] = &enemyFormation[19]; + enemy_pool_[1].set[0] = &enemy_formation_[10]; + enemy_pool_[1].set[1] = &enemy_formation_[11]; + enemy_pool_[1].set[2] = &enemy_formation_[12]; + enemy_pool_[1].set[3] = &enemy_formation_[13]; + enemy_pool_[1].set[4] = &enemy_formation_[14]; + enemy_pool_[1].set[5] = &enemy_formation_[15]; + enemy_pool_[1].set[6] = &enemy_formation_[16]; + enemy_pool_[1].set[7] = &enemy_formation_[17]; + enemy_pool_[1].set[8] = &enemy_formation_[18]; + enemy_pool_[1].set[9] = &enemy_formation_[19]; // EnemyPool #2 - enemyPool[2].set[0] = &enemyFormation[0]; - enemyPool[2].set[1] = &enemyFormation[1]; - enemyPool[2].set[2] = &enemyFormation[2]; - enemyPool[2].set[3] = &enemyFormation[3]; - enemyPool[2].set[4] = &enemyFormation[4]; - enemyPool[2].set[5] = &enemyFormation[55]; - enemyPool[2].set[6] = &enemyFormation[56]; - enemyPool[2].set[7] = &enemyFormation[57]; - enemyPool[2].set[8] = &enemyFormation[58]; - enemyPool[2].set[9] = &enemyFormation[59]; + enemy_pool_[2].set[0] = &enemy_formation_[0]; + enemy_pool_[2].set[1] = &enemy_formation_[1]; + enemy_pool_[2].set[2] = &enemy_formation_[2]; + enemy_pool_[2].set[3] = &enemy_formation_[3]; + enemy_pool_[2].set[4] = &enemy_formation_[4]; + enemy_pool_[2].set[5] = &enemy_formation_[55]; + enemy_pool_[2].set[6] = &enemy_formation_[56]; + enemy_pool_[2].set[7] = &enemy_formation_[57]; + enemy_pool_[2].set[8] = &enemy_formation_[58]; + enemy_pool_[2].set[9] = &enemy_formation_[59]; // EnemyPool #3 - enemyPool[3].set[0] = &enemyFormation[50]; - enemyPool[3].set[1] = &enemyFormation[51]; - enemyPool[3].set[2] = &enemyFormation[52]; - enemyPool[3].set[3] = &enemyFormation[53]; - enemyPool[3].set[4] = &enemyFormation[54]; - enemyPool[3].set[5] = &enemyFormation[5]; - enemyPool[3].set[6] = &enemyFormation[6]; - enemyPool[3].set[7] = &enemyFormation[7]; - enemyPool[3].set[8] = &enemyFormation[8]; - enemyPool[3].set[9] = &enemyFormation[9]; + enemy_pool_[3].set[0] = &enemy_formation_[50]; + enemy_pool_[3].set[1] = &enemy_formation_[51]; + enemy_pool_[3].set[2] = &enemy_formation_[52]; + enemy_pool_[3].set[3] = &enemy_formation_[53]; + enemy_pool_[3].set[4] = &enemy_formation_[54]; + enemy_pool_[3].set[5] = &enemy_formation_[5]; + enemy_pool_[3].set[6] = &enemy_formation_[6]; + enemy_pool_[3].set[7] = &enemy_formation_[7]; + enemy_pool_[3].set[8] = &enemy_formation_[8]; + enemy_pool_[3].set[9] = &enemy_formation_[9]; // EnemyPool #4 - enemyPool[4].set[0] = &enemyFormation[60]; - enemyPool[4].set[1] = &enemyFormation[61]; - enemyPool[4].set[2] = &enemyFormation[62]; - enemyPool[4].set[3] = &enemyFormation[63]; - enemyPool[4].set[4] = &enemyFormation[64]; - enemyPool[4].set[5] = &enemyFormation[65]; - enemyPool[4].set[6] = &enemyFormation[66]; - enemyPool[4].set[7] = &enemyFormation[67]; - enemyPool[4].set[8] = &enemyFormation[68]; - enemyPool[4].set[9] = &enemyFormation[69]; + enemy_pool_[4].set[0] = &enemy_formation_[60]; + enemy_pool_[4].set[1] = &enemy_formation_[61]; + enemy_pool_[4].set[2] = &enemy_formation_[62]; + enemy_pool_[4].set[3] = &enemy_formation_[63]; + enemy_pool_[4].set[4] = &enemy_formation_[64]; + enemy_pool_[4].set[5] = &enemy_formation_[65]; + enemy_pool_[4].set[6] = &enemy_formation_[66]; + enemy_pool_[4].set[7] = &enemy_formation_[67]; + enemy_pool_[4].set[8] = &enemy_formation_[68]; + enemy_pool_[4].set[9] = &enemy_formation_[69]; // EnemyPool #5 - enemyPool[5].set[0] = &enemyFormation[10]; - enemyPool[5].set[1] = &enemyFormation[61]; - enemyPool[5].set[2] = &enemyFormation[12]; - enemyPool[5].set[3] = &enemyFormation[63]; - enemyPool[5].set[4] = &enemyFormation[14]; - enemyPool[5].set[5] = &enemyFormation[65]; - enemyPool[5].set[6] = &enemyFormation[16]; - enemyPool[5].set[7] = &enemyFormation[67]; - enemyPool[5].set[8] = &enemyFormation[18]; - enemyPool[5].set[9] = &enemyFormation[69]; + enemy_pool_[5].set[0] = &enemy_formation_[10]; + enemy_pool_[5].set[1] = &enemy_formation_[61]; + enemy_pool_[5].set[2] = &enemy_formation_[12]; + enemy_pool_[5].set[3] = &enemy_formation_[63]; + enemy_pool_[5].set[4] = &enemy_formation_[14]; + enemy_pool_[5].set[5] = &enemy_formation_[65]; + enemy_pool_[5].set[6] = &enemy_formation_[16]; + enemy_pool_[5].set[7] = &enemy_formation_[67]; + enemy_pool_[5].set[8] = &enemy_formation_[18]; + enemy_pool_[5].set[9] = &enemy_formation_[69]; // EnemyPool #6 - enemyPool[6].set[0] = &enemyFormation[60]; - enemyPool[6].set[1] = &enemyFormation[11]; - enemyPool[6].set[2] = &enemyFormation[62]; - enemyPool[6].set[3] = &enemyFormation[13]; - enemyPool[6].set[4] = &enemyFormation[64]; - enemyPool[6].set[5] = &enemyFormation[15]; - enemyPool[6].set[6] = &enemyFormation[66]; - enemyPool[6].set[7] = &enemyFormation[17]; - enemyPool[6].set[8] = &enemyFormation[68]; - enemyPool[6].set[9] = &enemyFormation[19]; + enemy_pool_[6].set[0] = &enemy_formation_[60]; + enemy_pool_[6].set[1] = &enemy_formation_[11]; + enemy_pool_[6].set[2] = &enemy_formation_[62]; + enemy_pool_[6].set[3] = &enemy_formation_[13]; + enemy_pool_[6].set[4] = &enemy_formation_[64]; + enemy_pool_[6].set[5] = &enemy_formation_[15]; + enemy_pool_[6].set[6] = &enemy_formation_[66]; + enemy_pool_[6].set[7] = &enemy_formation_[17]; + enemy_pool_[6].set[8] = &enemy_formation_[68]; + enemy_pool_[6].set[9] = &enemy_formation_[19]; // EnemyPool #7 - enemyPool[7].set[0] = &enemyFormation[20]; - enemyPool[7].set[1] = &enemyFormation[21]; - enemyPool[7].set[2] = &enemyFormation[22]; - enemyPool[7].set[3] = &enemyFormation[23]; - enemyPool[7].set[4] = &enemyFormation[24]; - enemyPool[7].set[5] = &enemyFormation[65]; - enemyPool[7].set[6] = &enemyFormation[66]; - enemyPool[7].set[7] = &enemyFormation[67]; - enemyPool[7].set[8] = &enemyFormation[68]; - enemyPool[7].set[9] = &enemyFormation[69]; + enemy_pool_[7].set[0] = &enemy_formation_[20]; + enemy_pool_[7].set[1] = &enemy_formation_[21]; + enemy_pool_[7].set[2] = &enemy_formation_[22]; + enemy_pool_[7].set[3] = &enemy_formation_[23]; + enemy_pool_[7].set[4] = &enemy_formation_[24]; + enemy_pool_[7].set[5] = &enemy_formation_[65]; + enemy_pool_[7].set[6] = &enemy_formation_[66]; + enemy_pool_[7].set[7] = &enemy_formation_[67]; + enemy_pool_[7].set[8] = &enemy_formation_[68]; + enemy_pool_[7].set[9] = &enemy_formation_[69]; // EnemyPool #8 - enemyPool[8].set[0] = &enemyFormation[70]; - enemyPool[8].set[1] = &enemyFormation[71]; - enemyPool[8].set[2] = &enemyFormation[72]; - enemyPool[8].set[3] = &enemyFormation[73]; - enemyPool[8].set[4] = &enemyFormation[74]; - enemyPool[8].set[5] = &enemyFormation[15]; - enemyPool[8].set[6] = &enemyFormation[16]; - enemyPool[8].set[7] = &enemyFormation[17]; - enemyPool[8].set[8] = &enemyFormation[18]; - enemyPool[8].set[9] = &enemyFormation[19]; + enemy_pool_[8].set[0] = &enemy_formation_[70]; + enemy_pool_[8].set[1] = &enemy_formation_[71]; + enemy_pool_[8].set[2] = &enemy_formation_[72]; + enemy_pool_[8].set[3] = &enemy_formation_[73]; + enemy_pool_[8].set[4] = &enemy_formation_[74]; + enemy_pool_[8].set[5] = &enemy_formation_[15]; + enemy_pool_[8].set[6] = &enemy_formation_[16]; + enemy_pool_[8].set[7] = &enemy_formation_[17]; + enemy_pool_[8].set[8] = &enemy_formation_[18]; + enemy_pool_[8].set[9] = &enemy_formation_[19]; // EnemyPool #9 - enemyPool[9].set[0] = &enemyFormation[20]; - enemyPool[9].set[1] = &enemyFormation[21]; - enemyPool[9].set[2] = &enemyFormation[22]; - enemyPool[9].set[3] = &enemyFormation[23]; - enemyPool[9].set[4] = &enemyFormation[24]; - enemyPool[9].set[5] = &enemyFormation[70]; - enemyPool[9].set[6] = &enemyFormation[71]; - enemyPool[9].set[7] = &enemyFormation[72]; - enemyPool[9].set[8] = &enemyFormation[73]; - enemyPool[9].set[9] = &enemyFormation[74]; + enemy_pool_[9].set[0] = &enemy_formation_[20]; + enemy_pool_[9].set[1] = &enemy_formation_[21]; + enemy_pool_[9].set[2] = &enemy_formation_[22]; + enemy_pool_[9].set[3] = &enemy_formation_[23]; + enemy_pool_[9].set[4] = &enemy_formation_[24]; + enemy_pool_[9].set[5] = &enemy_formation_[70]; + enemy_pool_[9].set[6] = &enemy_formation_[71]; + enemy_pool_[9].set[7] = &enemy_formation_[72]; + enemy_pool_[9].set[8] = &enemy_formation_[73]; + enemy_pool_[9].set[9] = &enemy_formation_[74]; } // Inicializa las fases del juego void Game::initGameStages() { // STAGE 1 - stage[0].number = 1; - stage[0].currentPower = 0; - stage[0].powerToComplete = 200; - stage[0].minMenace = 7 + (4 * 1); - stage[0].maxMenace = 7 + (4 * 3); - stage[0].enemyPool = &enemyPool[0]; + stage_[0].number = 1; + stage_[0].current_power = 0; + stage_[0].power_to_complete = 200; + stage_[0].min_menace = 7 + (4 * 1); + stage_[0].max_menace = 7 + (4 * 3); + stage_[0].enemy_pool = &enemy_pool_[0]; // STAGE 2 - stage[1].number = 2; - stage[1].currentPower = 0; - stage[1].powerToComplete = 300; - stage[1].minMenace = 7 + (4 * 2); - stage[1].maxMenace = 7 + (4 * 4); - stage[1].enemyPool = &enemyPool[1]; + stage_[1].number = 2; + stage_[1].current_power = 0; + stage_[1].power_to_complete = 300; + stage_[1].min_menace = 7 + (4 * 2); + stage_[1].max_menace = 7 + (4 * 4); + stage_[1].enemy_pool = &enemy_pool_[1]; // STAGE 3 - stage[2].number = 3; - stage[2].currentPower = 0; - stage[2].powerToComplete = 600; - stage[2].minMenace = 7 + (4 * 3); - stage[2].maxMenace = 7 + (4 * 5); - stage[2].enemyPool = &enemyPool[2]; + stage_[2].number = 3; + stage_[2].current_power = 0; + stage_[2].power_to_complete = 600; + stage_[2].min_menace = 7 + (4 * 3); + stage_[2].max_menace = 7 + (4 * 5); + stage_[2].enemy_pool = &enemy_pool_[2]; // STAGE 4 - stage[3].number = 4; - stage[3].currentPower = 0; - stage[3].powerToComplete = 600; - stage[3].minMenace = 7 + (4 * 3); - stage[3].maxMenace = 7 + (4 * 5); - stage[3].enemyPool = &enemyPool[3]; + stage_[3].number = 4; + stage_[3].current_power = 0; + stage_[3].power_to_complete = 600; + stage_[3].min_menace = 7 + (4 * 3); + stage_[3].max_menace = 7 + (4 * 5); + stage_[3].enemy_pool = &enemy_pool_[3]; // STAGE 5 - stage[4].number = 5; - stage[4].currentPower = 0; - stage[4].powerToComplete = 600; - stage[4].minMenace = 7 + (4 * 4); - stage[4].maxMenace = 7 + (4 * 6); - stage[4].enemyPool = &enemyPool[4]; + stage_[4].number = 5; + stage_[4].current_power = 0; + stage_[4].power_to_complete = 600; + stage_[4].min_menace = 7 + (4 * 4); + stage_[4].max_menace = 7 + (4 * 6); + stage_[4].enemy_pool = &enemy_pool_[4]; // STAGE 6 - stage[5].number = 6; - stage[5].currentPower = 0; - stage[5].powerToComplete = 600; - stage[5].minMenace = 7 + (4 * 4); - stage[5].maxMenace = 7 + (4 * 6); - stage[5].enemyPool = &enemyPool[5]; + stage_[5].number = 6; + stage_[5].current_power = 0; + stage_[5].power_to_complete = 600; + stage_[5].min_menace = 7 + (4 * 4); + stage_[5].max_menace = 7 + (4 * 6); + stage_[5].enemy_pool = &enemy_pool_[5]; // STAGE 7 - stage[6].number = 7; - stage[6].currentPower = 0; - stage[6].powerToComplete = 650; - stage[6].minMenace = 7 + (4 * 5); - stage[6].maxMenace = 7 + (4 * 7); - stage[6].enemyPool = &enemyPool[6]; + stage_[6].number = 7; + stage_[6].current_power = 0; + stage_[6].power_to_complete = 650; + stage_[6].min_menace = 7 + (4 * 5); + stage_[6].max_menace = 7 + (4 * 7); + stage_[6].enemy_pool = &enemy_pool_[6]; // STAGE 8 - stage[7].number = 8; - stage[7].currentPower = 0; - stage[7].powerToComplete = 750; - stage[7].minMenace = 7 + (4 * 5); - stage[7].maxMenace = 7 + (4 * 7); - stage[7].enemyPool = &enemyPool[7]; + stage_[7].number = 8; + stage_[7].current_power = 0; + stage_[7].power_to_complete = 750; + stage_[7].min_menace = 7 + (4 * 5); + stage_[7].max_menace = 7 + (4 * 7); + stage_[7].enemy_pool = &enemy_pool_[7]; // STAGE 9 - stage[8].number = 9; - stage[8].currentPower = 0; - stage[8].powerToComplete = 850; - stage[8].minMenace = 7 + (4 * 6); - stage[8].maxMenace = 7 + (4 * 8); - stage[8].enemyPool = &enemyPool[8]; + stage_[8].number = 9; + stage_[8].current_power = 0; + stage_[8].power_to_complete = 850; + stage_[8].min_menace = 7 + (4 * 6); + stage_[8].max_menace = 7 + (4 * 8); + stage_[8].enemy_pool = &enemy_pool_[8]; // STAGE 10 - stage[9].number = 10; - stage[9].currentPower = 0; - stage[9].powerToComplete = 950; - stage[9].minMenace = 7 + (4 * 7); - stage[9].maxMenace = 7 + (4 * 10); - stage[9].enemyPool = &enemyPool[9]; + stage_[9].number = 10; + stage_[9].current_power = 0; + stage_[9].power_to_complete = 950; + stage_[9].min_menace = 7 + (4 * 7); + stage_[9].max_menace = 7 + (4 * 10); + stage_[9].enemy_pool = &enemy_pool_[9]; } // Crea una formación de enemigos void Game::deployEnemyFormation() { // Solo despliega una formación enemiga si ha pasado cierto tiempo desde la última - if (enemyDeployCounter == 0) { + if (enemy_deploy_counter_ == 0) { // En este punto se decide entre crear una powerball o una formación enemiga if ((rand() % 100 < 15) && (canPowerBallBeCreated())) { // Crea una powerball createPowerBall(); // Da un poco de margen para que se creen mas enemigos - enemyDeployCounter = 50; + enemy_deploy_counter_ = 50; } else { // Decrementa el contador de despliegues enemigos de la PowerBall - powerBallCounter > 0 ? powerBallCounter-- : powerBallCounter = 0; + power_ball_counter_ > 0 ? power_ball_counter_-- : power_ball_counter_ = 0; // Elige una formación enemiga la azar Uint8 set = (rand() % 10); // Evita repetir la ultima formación enemiga desplegada - if (set == lastEnemyDeploy) { + if (set == last_enemy_deploy_) { ++set %= 10; } - lastEnemyDeploy = set; + last_enemy_deploy_ = set; - const Uint8 numEnemies = stage[currentStage].enemyPool->set[set]->numberOfEnemies; + const Uint8 numEnemies = stage_[current_stage_].enemy_pool->set[set]->number_of_enemies; for (int i = 0; i < numEnemies; ++i) { - createBalloon(stage[currentStage].enemyPool->set[set]->init[i].x, - stage[currentStage].enemyPool->set[set]->init[i].y, - stage[currentStage].enemyPool->set[set]->init[i].kind, - stage[currentStage].enemyPool->set[set]->init[i].velX, - enemySpeed, - stage[currentStage].enemyPool->set[set]->init[i].creationCounter); + 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, + stage_[current_stage_].enemy_pool->set[set]->init[i].vel_x, + enemy_speed_, + stage_[current_stage_].enemy_pool->set[set]->init[i].creation_counter); } - enemyDeployCounter = 300; + enemy_deploy_counter_ = 300; } } } // Aumenta el poder de la fase void Game::increaseStageCurrentPower(Uint8 power) { - stage[currentStage].currentPower += power; + stage_[current_stage_].current_power += power; } // Establece el valor de la variable void Game::setHiScore(Uint32 score) { - hiScore = score; + hi_score_ = score; } // Actualiza el valor de hiScore en caso necesario void Game::updateHiScore() { // Si la puntuación actual es mayor que la máxima puntuación - for (auto *player : players) { - if (player->getScore() > hiScore) { + for (auto *player : players_) { + if (player->getScore() > hi_score_) { // Actualiza la máxima puntuación - hiScore = player->getScore(); + hi_score_ = player->getScore(); // Almacena la máxima puntuación en el fichero junto con un checksum - scoreDataFile[0] = hiScore; - scoreDataFile[1] = hiScore % 43; + score_data_file_[0] = hi_score_; + score_data_file_[1] = hi_score_ % 43; // Si se supera la máxima puntuación emite sonido - if (!hiScoreAchieved) { - hiScoreAchieved = true; - Audio::get()->playSound(hiScoreSound); + if (!hi_score_achieved_) { + hi_score_achieved_ = true; + Audio::get()->playSound(hi_score_sound_); } } } @@ -1348,17 +1348,17 @@ auto Game::updateScoreText(Uint32 num) -> std::string { // Pinta el marcador en pantalla usando un objeto texto void Game::renderScoreBoard() { // Dibuja el fondo del marcador - if (difficulty == DIFFICULTY_NORMAL) { // Pone el color gris de siempre - SDL_SetRenderDrawColor(renderer, 46, 63, 71, 255); + if (difficulty_ == DIFFICULTY_NORMAL) { // Pone el color gris de siempre + SDL_SetRenderDrawColor(renderer_, 46, 63, 71, 255); } else { // Pinta el fondo del marcador del color de la dificultad - SDL_SetRenderDrawColor(renderer, difficultyColor.r, difficultyColor.g, difficultyColor.b, 255); + 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_RenderFillRect(renderer_, &fRect); // 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); + SDL_SetRenderDrawColor(renderer_, 13, 26, 43, 255); + SDL_RenderLine(renderer_, 0, 160, 255, 160); // Anclas para los elementos const int offset1 = 162; @@ -1370,58 +1370,58 @@ void Game::renderScoreBoard() { const int offsetRight = PLAY_AREA_RIGHT - 45; // PLAYER1 - SCORE - textScoreBoard->writeCentered(offsetLeft, offset1, Lang::get()->getText(53)); - textScoreBoard->writeCentered(offsetLeft, offset2, updateScoreText(players[0]->getScore())); + text_scoreboard_->writeCentered(offsetLeft, offset1, Lang::get()->getText(53)); + text_scoreboard_->writeCentered(offsetLeft, offset2, updateScoreText(players_[0]->getScore())); // PLAYER1 - MULT - textScoreBoard->writeCentered(offsetLeft, offset3, Lang::get()->getText(55)); - textScoreBoard->writeCentered(offsetLeft, offset4, std::to_string(players[0]->getScoreMultiplier()).substr(0, 3)); + text_scoreboard_->writeCentered(offsetLeft, offset3, Lang::get()->getText(55)); + text_scoreboard_->writeCentered(offsetLeft, offset4, std::to_string(players_[0]->getScoreMultiplier()).substr(0, 3)); - if (numPlayers == 2) { + if (num_players_ == 2) { // PLAYER2 - SCORE - textScoreBoard->writeCentered(offsetRight, offset1, Lang::get()->getText(54)); - textScoreBoard->writeCentered(offsetRight, offset2, updateScoreText(players[1]->getScore())); + text_scoreboard_->writeCentered(offsetRight, offset1, Lang::get()->getText(54)); + text_scoreboard_->writeCentered(offsetRight, offset2, updateScoreText(players_[1]->getScore())); // PLAYER2 - MULT - textScoreBoard->writeCentered(offsetRight, offset3, Lang::get()->getText(55)); - textScoreBoard->writeCentered(offsetRight, offset4, std::to_string(players[1]->getScoreMultiplier()).substr(0, 3)); + text_scoreboard_->writeCentered(offsetRight, offset3, Lang::get()->getText(55)); + text_scoreboard_->writeCentered(offsetRight, offset4, std::to_string(players_[1]->getScoreMultiplier()).substr(0, 3)); } else { // PLAYER2 - SCORE - textScoreBoard->writeCentered(offsetRight, offset1, Lang::get()->getText(54)); - textScoreBoard->writeCentered(offsetRight, offset2, "0000000"); + text_scoreboard_->writeCentered(offsetRight, offset1, Lang::get()->getText(54)); + text_scoreboard_->writeCentered(offsetRight, offset2, "0000000"); // PLAYER2 - MULT - textScoreBoard->writeCentered(offsetRight, offset3, Lang::get()->getText(55)); - textScoreBoard->writeCentered(offsetRight, offset4, "1.0"); + text_scoreboard_->writeCentered(offsetRight, offset3, Lang::get()->getText(55)); + text_scoreboard_->writeCentered(offsetRight, offset4, "1.0"); } // STAGE - textScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset1, Lang::get()->getText(57) + std::to_string(stage[currentStage].number)); + text_scoreboard_->writeCentered(PLAY_AREA_CENTER_X, offset1, Lang::get()->getText(57) + std::to_string(stage_[current_stage_].number)); // POWERMETER - powerMeterSprite->setPosY(offset2); - powerMeterSprite->setSpriteClip(0, 0, 40, 7); - powerMeterSprite->render(); - const float percent = (stage[currentStage].currentPower * 40.0F) / stage[currentStage].powerToComplete; - powerMeterSprite->setSpriteClip(40, 0, (int)percent, 7); - powerMeterSprite->render(); + 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); + power_meter_sprite_->render(); // HI-SCORE - textScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset3, Lang::get()->getText(56)); - textScoreBoard->writeCentered(PLAY_AREA_CENTER_X, offset4, hiScoreName + updateScoreText(hiScore)); + 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 void Game::updatePlayers() { - for (auto *player : players) { + for (auto *player : players_) { player->update(); // Comprueba la colisión entre el jugador y los globos if (checkPlayerBalloonCollision(player)) { if (player->isAlive()) { - if (demo.enabled) { - section->name = SECTION_PROG_TITLE; - section->subsection = SUBSECTION_TITLE_INSTRUCTIONS; + if (demo_.enabled) { + section_->name = SECTION_PROG_TITLE; + section_->subsection = SUBSECTION_TITLE_INSTRUCTIONS; } else { killPlayer(player); } @@ -1435,25 +1435,25 @@ void Game::updatePlayers() { // Dibuja a los jugadores void Game::renderPlayers() { - for (auto *player : players) { + for (auto *player : players_) { player->render(); } } // Actualiza las variables de la fase void Game::updateStage() { - if (stage[currentStage].currentPower >= stage[currentStage].powerToComplete) { + if (stage_[current_stage_].current_power >= stage_[current_stage_].power_to_complete) { // Cambio de fase - currentStage++; - lastStageReached = currentStage; - if (currentStage == 10) { // Ha llegado al final el juego - gameCompleted = true; // Marca el juego como completado - currentStage = 9; // Deja el valor dentro de los limites - stage[currentStage].currentPower = 0; // Deja el poder a cero para que no vuelva a entrar en esta condición + 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 + 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 - stage[currentStage].currentPower = 0; // Vuelve a dejar el poder a cero, por lo que hubiera podido subir al destruir todos lo globos - menaceCurrent = 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 + 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 if (player->isAlive()) { player->addScore(1000000); } @@ -1461,22 +1461,22 @@ void Game::updateStage() { updateHiScore(); Audio::get()->stopMusic(); } - Audio::get()->playSound(stageChangeSound); - stageBitmapCounter = 0; - enemySpeed = defaultEnemySpeed; - setBalloonSpeed(enemySpeed); - effect.flash = true; - effect.shake = true; + Audio::get()->playSound(stage_change_sound_); + stage_bitmap_counter_ = 0; + enemy_speed_ = default_enemy_speed_; + setBalloonSpeed(enemy_speed_); + effect_.flash = true; + effect_.shake = true; } // Incrementa el contador del bitmap que aparece mostrando el cambio de fase - if (stageBitmapCounter < STAGE_COUNTER) { - stageBitmapCounter++; + if (stage_bitmap_counter_ < STAGE_COUNTER) { + stage_bitmap_counter_++; } // Si el juego se ha completado, el bitmap se detiene en el centro de la pantalla - if (gameCompleted) { - stageBitmapCounter = std::min(stageBitmapCounter, 100); + if (game_completed_) { + stage_bitmap_counter_ = std::min(stage_bitmap_counter_, 100); } } @@ -1484,31 +1484,31 @@ void Game::updateStage() { void Game::updateDeath() { // Comprueba si todos los jugadores estan muertos bool allDead = true; - for (auto *player : players) { + for (auto *player : players_) { allDead &= (!player->isAlive()); } if (allDead) { - if (deathCounter > 0) { - deathCounter--; + if (death_counter_ > 0) { + death_counter_--; - if ((deathCounter == 250) || (deathCounter == 200) || (deathCounter == 180) || (deathCounter == 120) || (deathCounter == 60)) { + 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) { + if (!demo_.enabled) { const Uint8 index = rand() % 4; - JA_Sound_t *sound[4] = {bubble1Sound, bubble2Sound, bubble3Sound, bubble4Sound}; + JA_Sound_t *sound[4] = {bubble1_sound_, bubble2_sound_, bubble3_sound_, bubble4_sound_}; Audio::get()->playSound(sound[index]); } } } else { - section->subsection = SUBSECTION_GAME_GAMEOVER; + section_->subsection = SUBSECTION_GAME_GAMEOVER; } } } // Renderiza el fade final cuando se acaba la partida void Game::renderDeathFade(int counter) { // Counter debe ir de 0 a 150 - SDL_SetRenderDrawColor(renderer, 0x27, 0x27, 0x36, 255); + SDL_SetRenderDrawColor(renderer_, 0x27, 0x27, 0x36, 255); if (counter < 150) { // 192 / 6 = 32, 6 cuadrados de 32 pixeles @@ -1523,24 +1523,24 @@ void Game::renderDeathFade(int counter) { // Counter debe ir de 0 a 150 } else { rect[i].h = std::max(rect[i - 1].h - 3.0F, 0.0F); } - SDL_RenderFillRect(renderer, &rect[i]); + SDL_RenderFillRect(renderer_, &rect[i]); } } else { SDL_FRect rect = {0, 0, (float)GAMECANVAS_WIDTH, (float)GAMECANVAS_HEIGHT}; - SDL_RenderFillRect(renderer, &rect); + SDL_RenderFillRect(renderer_, &rect); } } // Actualiza los globos void Game::updateBalloons() { - for (auto *balloon : balloons) { + for (auto *balloon : balloons_) { balloon->update(); } } // Pinta en pantalla todos los globos activos void Game::renderBalloons() { - for (auto *balloon : balloons) { + for (auto *balloon : balloons_) { balloon->render(); } } @@ -1548,9 +1548,9 @@ 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, balloonTextures[index], balloonAnimations[index], renderer); - balloons.push_back(b); - return (Uint8)(balloons.size() - 1); + 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 @@ -1558,23 +1558,23 @@ void Game::createPowerBall() { const int posY = 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 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 float vx[3] = {Balloon::VELX_POSITIVE, Balloon::VELX_POSITIVE, Balloon::VELX_NEGATIVE}; - auto *b = new Balloon(x[luck], posY, POWER_BALL, vx[luck], enemySpeed, 100, balloonTextures[3], balloonAnimations[3], renderer); - balloons.push_back(b); + auto *b = new Balloon(x[luck], posY, Balloon::POWER_BALL, vx[luck], enemy_speed_, 100, balloon_textures_[3], balloon_animations_[3], renderer_); + balloons_.push_back(b); - powerBallEnabled = true; - powerBallCounter = POWERBALL_COUNTER; + power_ball_enabled_ = true; + power_ball_counter_ = Balloon::POWERBALL_COUNTER; } // Establece la velocidad de los globos void Game::setBalloonSpeed(float speed) { - for (auto *balloon : balloons) { + for (auto *balloon : balloons_) { if (balloon->isEnabled()) { balloon->setSpeed(speed); } @@ -1584,49 +1584,49 @@ void Game::setBalloonSpeed(float speed) { // Incrementa la velocidad de los globos void Game::incBalloonSpeed() { // La velocidad solo se incrementa en el modo normal - if (difficulty == DIFFICULTY_NORMAL) { - if (enemySpeed == BALLOON_SPEED_1) { - enemySpeed = BALLOON_SPEED_2; + if (difficulty_ == DIFFICULTY_NORMAL) { + if (enemy_speed_ == Balloon::SPEED_1) { + enemy_speed_ = Balloon::SPEED_2; } - else if (enemySpeed == BALLOON_SPEED_2) { - enemySpeed = BALLOON_SPEED_3; + else if (enemy_speed_ == Balloon::SPEED_2) { + enemy_speed_ = Balloon::SPEED_3; } - else if (enemySpeed == BALLOON_SPEED_3) { - enemySpeed = BALLOON_SPEED_4; + else if (enemy_speed_ == Balloon::SPEED_3) { + enemy_speed_ = Balloon::SPEED_4; } - else if (enemySpeed == BALLOON_SPEED_4) { - enemySpeed = BALLOON_SPEED_5; + else if (enemy_speed_ == Balloon::SPEED_4) { + enemy_speed_ = Balloon::SPEED_5; } - setBalloonSpeed(enemySpeed); + setBalloonSpeed(enemy_speed_); } } // Actualiza la velocidad de los globos en funcion del poder acumulado de la fase void Game::updateBalloonSpeed() { - const float percent = (float)stage[currentStage].currentPower / (float)stage[currentStage].powerToComplete; - if (enemySpeed == BALLOON_SPEED_1) { + 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 (enemySpeed == BALLOON_SPEED_2) { + else if (enemy_speed_ == Balloon::SPEED_2) { if (percent > 0.4F) { incBalloonSpeed(); } } - else if (enemySpeed == BALLOON_SPEED_3) { + else if (enemy_speed_ == Balloon::SPEED_3) { if (percent > 0.6F) { incBalloonSpeed(); } } - else if (enemySpeed == BALLOON_SPEED_4) { + else if (enemy_speed_ == Balloon::SPEED_4) { if (percent > 0.8F) { incBalloonSpeed(); } @@ -1637,39 +1637,39 @@ void Game::updateBalloonSpeed() { void Game::popBalloon(Balloon *balloon) { // Aumenta el poder de la fase increaseStageCurrentPower(1); - balloonsPopped++; + balloons_popped_++; const Uint8 kind = balloon->getKind(); switch (kind) { // Tipus més petits: simplement elimina el globó - case BALLOON_1: - case HEXAGON_1: + case Balloon::BALLOON_1: + case Balloon::HEXAGON_1: balloon->pop(); break; // Si es del tipo PowerBall, destruye todos los globos - case POWER_BALL: + case Balloon::POWER_BALL: destroyAllBalloons(); - powerBallEnabled = false; - enemyDeployCounter = 20; + power_ball_enabled_ = false; + enemy_deploy_counter_ = 20; break; // 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, enemySpeed, 0); - balloons[index]->allignTo(balloon->getPosX() + (balloon->getWidth() / 2)); - if (balloons[index]->getClass() == 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, enemySpeed, 0); - balloons[index2]->allignTo(balloon->getPosX() + (balloon->getWidth() / 2)); - if (balloons[index2]->getClass() == 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 @@ -1688,23 +1688,23 @@ void Game::destroyBalloon(Balloon *balloon) { // Calcula la puntuación y el poder que generaria el globo en caso de romperlo a él y a sus hijos switch (balloon->getSize()) { - case BALLOON_SIZE_4: - score = BALLOON_SCORE_4 + (2 * BALLOON_SCORE_3) + (4 * BALLOON_SCORE_2) + (8 * BALLOON_SCORE_1); + case Balloon::SIZE_4: + score = Balloon::SCORE_4 + (2 * Balloon::SCORE_3) + (4 * Balloon::SCORE_2) + (8 * Balloon::SCORE_1); power = 15; break; - case BALLOON_SIZE_3: - score = BALLOON_SCORE_3 + (2 * BALLOON_SCORE_2) + (4 * BALLOON_SCORE_1); + case Balloon::SIZE_3: + score = Balloon::SCORE_3 + (2 * Balloon::SCORE_2) + (4 * Balloon::SCORE_1); power = 7; break; - case BALLOON_SIZE_2: - score = BALLOON_SCORE_2 + (2 * BALLOON_SCORE_1); + case Balloon::SIZE_2: + score = Balloon::SCORE_2 + (2 * Balloon::SCORE_1); power = 3; break; - case BALLOON_SIZE_1: - score = BALLOON_SCORE_1; + case Balloon::SIZE_1: + score = Balloon::SCORE_1; power = 1; break; @@ -1715,14 +1715,14 @@ void Game::destroyBalloon(Balloon *balloon) { } // Otorga los puntos correspondientes al globo - for (auto *player : players) { - player->addScore(Uint32(score * player->getScoreMultiplier() * difficultyScoreMultiplier)); + for (auto *player : players_) { + player->addScore(Uint32(score * player->getScoreMultiplier() * difficulty_score_multiplier_)); } updateHiScore(); // Aumenta el poder de la fase increaseStageCurrentPower(power); - balloonsPopped += power; + balloons_popped_ += power; // Destruye el globo balloon->pop(); @@ -1733,23 +1733,23 @@ void Game::destroyBalloon(Balloon *balloon) { // Destruye todos los globos void Game::destroyAllBalloons() { - for (auto *balloon : balloons) { + for (auto *balloon : balloons_) { if ((balloon->isEnabled()) && (!balloon->isPopping())) { destroyBalloon(balloon); } } - enemyDeployCounter = 255; - if (!demo.enabled) { - Audio::get()->playSound(powerBallSound); + enemy_deploy_counter_ = 255; + if (!demo_.enabled) { + Audio::get()->playSound(power_ball_sound_); } - effect.flash = true; - effect.shake = true; + effect_.flash = true; + effect_.shake = true; } // Detiene todos los globos void Game::stopAllBalloons(Uint16 time) { - for (auto *balloon : balloons) { + for (auto *balloon : balloons_) { if (balloon->isEnabled()) { balloon->setStop(true); balloon->setStoppedTimer(time); @@ -1759,7 +1759,7 @@ void Game::stopAllBalloons(Uint16 time) { // Pone en marcha todos los globos void Game::startAllBalloons() { - for (auto *balloon : balloons) { + for (auto *balloon : balloons_) { if ((balloon->isEnabled()) && (!balloon->isBeingCreated())) { balloon->setStop(false); balloon->setStoppedTimer(0); @@ -1769,11 +1769,11 @@ void Game::startAllBalloons() { // Vacia el vector de globos void Game::freeBalloons() { - if (!balloons.empty()) { - for (int i = balloons.size() - 1; i >= 0; --i) { - if (!balloons[i]->isEnabled()) { - delete balloons[i]; - balloons.erase(balloons.begin() + i); + if (!balloons_.empty()) { + for (int i = balloons_.size() - 1; i >= 0; --i) { + if (!balloons_[i]->isEnabled()) { + delete balloons_[i]; + balloons_.erase(balloons_.begin() + i); } } } @@ -1781,7 +1781,7 @@ void Game::freeBalloons() { // Comprueba la colisión entre el jugador y los globos activos auto Game::checkPlayerBalloonCollision(Player *player) -> bool { - for (auto *balloon : balloons) { + for (auto *balloon : balloons_) { if ((balloon->isEnabled()) && !(balloon->isStopped()) && !(balloon->isInvulnerable())) { if (checkCollision(player->getCollider(), balloon->getCollider())) { return true; @@ -1798,50 +1798,50 @@ void Game::checkPlayerItemCollision(Player *player) { return; } - for (auto *item : items) { + for (auto *item : items_) { if (item->isEnabled()) { if (checkCollision(player->getCollider(), item->getCollider())) { switch (item->getId()) { case Item::Id::DISK: player->addScore(1000); updateHiScore(); - createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (n1000Sprite->getWidth() / 2), player->getPosY(), n1000Sprite); - Audio::get()->playSound(itemPickUpSound); + createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (n1000_sprite_->getWidth() / 2), player->getPosY(), n1000_sprite_); + Audio::get()->playSound(item_pick_up_sound_); break; case Item::Id::GAVINA: player->addScore(2500); updateHiScore(); - createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (n2500Sprite->getWidth() / 2), player->getPosY(), n2500Sprite); - Audio::get()->playSound(itemPickUpSound); + createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (n2500_sprite_->getWidth() / 2), player->getPosY(), n2500_sprite_); + Audio::get()->playSound(item_pick_up_sound_); break; case Item::Id::PACMAR: player->addScore(5000); updateHiScore(); - createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (n5000Sprite->getWidth() / 2), player->getPosY(), n5000Sprite); - Audio::get()->playSound(itemPickUpSound); + createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (n5000_sprite_->getWidth() / 2), player->getPosY(), n5000_sprite_); + Audio::get()->playSound(item_pick_up_sound_); break; case Item::Id::CLOCK: enableTimeStopItem(); - Audio::get()->playSound(itemPickUpSound); + Audio::get()->playSound(item_pick_up_sound_); break; case Item::Id::COFFEE: if (player->getCoffees() == 2) { player->addScore(5000); updateHiScore(); - createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (n5000Sprite->getWidth() / 2), player->getPosY(), n5000Sprite); + createItemScoreSprite(item->getPosX() + (item->getWidth() / 2) - (n5000_sprite_->getWidth() / 2), player->getPosY(), n5000_sprite_); } player->giveExtraHit(); - Audio::get()->playSound(itemPickUpSound); + Audio::get()->playSound(item_pick_up_sound_); break; case Item::Id::COFFEE_MACHINE: player->setPowerUp(true); - Audio::get()->playSound(itemPickUpSound); - coffeeMachineEnabled = false; + Audio::get()->playSound(item_pick_up_sound_); + coffee_machine_enabled_ = false; break; default: @@ -1856,22 +1856,22 @@ void Game::checkPlayerItemCollision(Player *player) { // Comprueba y procesa la colisión entre las balas y los globos void Game::checkBulletBalloonCollision() { - for (auto *bullet : bullets) { - for (auto *balloon : balloons) { + for (auto *bullet : bullets_) { + for (auto *balloon : balloons_) { if (balloon->isEnabled() && (!balloon->isInvulnerable()) && bullet->isEnabled()) { if (checkCollision(balloon->getCollider(), bullet->getCollider())) { // Otorga los puntos correspondientes al globo al jugador que disparó la bala int index = bullet->getOwner(); - players[index]->incScoreMultiplier(); - players[index]->addScore(Uint32(balloon->getScore() * players[index]->getScoreMultiplier() * difficultyScoreMultiplier)); + players_[index]->incScoreMultiplier(); + players_[index]->addScore(Uint32(balloon->getScore() * players_[index]->getScoreMultiplier() * difficulty_score_multiplier_)); updateHiScore(); // Explota el globo popBalloon(balloon); // Si no es el modo demo, genera un sonido - if (!demo.enabled) { - Audio::get()->playSound(balloonSound); + if (!demo_.enabled) { + Audio::get()->playSound(balloon_sound_); } // Deshabilita la bala @@ -1879,13 +1879,13 @@ void Game::checkBulletBalloonCollision() { // Suelta el item en caso de que salga uno const Item::Id droppeditem = dropItem(); - if ((droppeditem != Item::Id::NONE) && !(demo.enabled) && !(demo.recording)) { + if ((droppeditem != Item::Id::NONE) && !(demo_.enabled) && !(demo_.recording)) { if (droppeditem != Item::Id::COFFEE_MACHINE) { createItem(droppeditem, balloon->getPosX(), balloon->getPosY()); - Audio::get()->playSound(itemDropSound); + Audio::get()->playSound(item_drop_sound_); } else { - createItem(droppeditem, players[index]->getPosX(), 0); - coffeeMachineEnabled = true; + createItem(droppeditem, players_[index]->getPosX(), 0); + coffee_machine_enabled_ = true; } } @@ -1898,10 +1898,10 @@ void Game::checkBulletBalloonCollision() { // Mueve las balas activas void Game::moveBullets() { - for (auto *bullet : bullets) { + for (auto *bullet : bullets_) { if (bullet->isEnabled()) { if (bullet->move() == Bullet::MoveResult::OUT) { - players[bullet->getOwner()]->decScoreMultiplier(); + players_[bullet->getOwner()]->decScoreMultiplier(); } } } @@ -1909,7 +1909,7 @@ void Game::moveBullets() { // Pinta las balas activas void Game::renderBullets() { - for (auto *bullet : bullets) { + for (auto *bullet : bullets_) { if (bullet->isEnabled()) { bullet->render(); } @@ -1918,17 +1918,17 @@ 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, bulletTexture, renderer); - bullets.push_back(b); + auto *b = new Bullet(x, y, kind, poweredUp, owner, bullet_texture_, renderer_); + bullets_.push_back(b); } // Vacia el vector de balas void Game::freeBullets() { - if (!bullets.empty()) { - for (int i = bullets.size() - 1; i >= 0; --i) { - if (!bullets[i]->isEnabled()) { - delete bullets[i]; - bullets.erase(bullets.begin() + i); + if (!bullets_.empty()) { + for (int i = bullets_.size() - 1; i >= 0; --i) { + if (!bullets_[i]->isEnabled()) { + delete bullets_[i]; + bullets_.erase(bullets_.begin() + i); } } } @@ -1936,12 +1936,12 @@ void Game::freeBullets() { // Actualiza los items void Game::updateItems() { - for (auto *item : items) { + for (auto *item : items_) { if (item->isEnabled()) { item->update(); if (item->isOnFloor()) { - Audio::get()->playSound(coffeeMachineSound); - effect.shake = true; + Audio::get()->playSound(coffee_machine_sound_); + effect_.shake = true; } } } @@ -1949,7 +1949,7 @@ void Game::updateItems() { // Pinta los items activos void Game::renderItems() { - for (auto *item : items) { + for (auto *item : items_) { item->render(); } } @@ -1961,49 +1961,49 @@ auto Game::dropItem() -> Item::Id { switch (item) { case 0: - if (luckyNumber < helper.itemPoints1Odds) { + if (luckyNumber < helper_.item_disk_odds) { return Item::Id::DISK; } break; case 1: - if (luckyNumber < helper.itemPoints2Odds) { + if (luckyNumber < helper_.item_gavina_odds) { return Item::Id::GAVINA; } break; case 2: - if (luckyNumber < helper.itemPoints3Odds) { + if (luckyNumber < helper_.item_paco_odds) { return Item::Id::PACMAR; } break; case 3: - if (luckyNumber < helper.itemClockOdds) { + if (luckyNumber < helper_.item_clock_odds) { return Item::Id::CLOCK; } break; case 4: - if (luckyNumber < helper.itemCoffeeOdds) { - helper.itemCoffeeOdds = ITEM_COFFEE_ODDS; + if (luckyNumber < helper_.item_coffee_odds) { + helper_.item_coffee_odds = ITEM_COFFEE_ODDS; return Item::Id::COFFEE; } else { - if (helper.needCoffee) { - helper.itemCoffeeOdds++; + if (helper_.need_coffee) { + helper_.item_coffee_odds++; } } break; case 5: - if (luckyNumber < helper.itemCoffeeMachineOdds) { - helper.itemCoffeeMachineOdds = ITEM_COFFEE_MACHINE_ODDS; - if ((!coffeeMachineEnabled) && (helper.needCoffeeMachine)) { + if (luckyNumber < 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; } } else { - if (helper.needCoffeeMachine) { - helper.itemCoffeeMachineOdds++; + if (helper_.need_coffee_machine) { + helper_.item_coffee_machine_odds++; } } break; @@ -2018,17 +2018,17 @@ 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, itemTextures[index], itemAnimations[index], renderer); - items.push_back(item); + Item *item = new Item(kind, x, y, item_textures_[index], item_animations_[index], renderer_); + items_.push_back(item); } // Vacia el vector de items void Game::freeItems() { - if (!items.empty()) { - for (int i = items.size() - 1; i >= 0; --i) { - if (!items[i]->isEnabled()) { - delete items[i]; - items.erase(items.begin() + i); + if (!items_.empty()) { + for (int i = items_.size() - 1; i >= 0; --i) { + if (!items_[i]->isEnabled()) { + delete items_[i]; + items_.erase(items_.begin() + i); } } } @@ -2036,8 +2036,8 @@ void Game::freeItems() { // Crea un objeto SmartSprite para mostrar la puntuación al coger un objeto void Game::createItemScoreSprite(int x, int y, const SmartSprite *sprite) { - auto *ss = new SmartSprite(nullptr, renderer); - smartSprites.push_back(ss); + auto *ss = new SmartSprite(nullptr, renderer_); + smart_sprites_.push_back(ss); // Crea una copia del objeto *ss = *sprite; @@ -2051,11 +2051,11 @@ void Game::createItemScoreSprite(int x, int y, const SmartSprite *sprite) { // Vacia el vector de smartsprites void Game::freeSmartSprites() { - if (!smartSprites.empty()) { - for (int i = smartSprites.size() - 1; i >= 0; --i) { - if (smartSprites[i]->hasFinished()) { - delete smartSprites[i]; - smartSprites.erase(smartSprites.begin() + i); + if (!smart_sprites_.empty()) { + for (int i = smart_sprites_.size() - 1; i >= 0; --i) { + if (smart_sprites_[i]->hasFinished()) { + delete smart_sprites_[i]; + smart_sprites_.erase(smart_sprites_.begin() + i); } } } @@ -2063,31 +2063,31 @@ void Game::freeSmartSprites() { // Dibuja el efecto de flash void Game::renderFlashEffect() { - if (effect.flash) { + if (effect_.flash) { // Pantallazo blanco - SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF); - SDL_RenderClear(renderer); + SDL_SetRenderDrawColor(renderer_, 0xFF, 0xFF, 0xFF, 0xFF); + SDL_RenderClear(renderer_); - effect.flash = false; + effect_.flash = false; } } // Actualiza el efecto de agitar la pantalla void Game::updateShakeEffect() { - if (effect.shake) { - if (effect.shakeCounter > 0) { - effect.shakeCounter--; + if (effect_.shake) { + if (effect_.shake_counter > 0) { + effect_.shake_counter--; } else { - effect.shake = false; - effect.shakeCounter = SHAKE_COUNTER; + effect_.shake = false; + effect_.shake_counter = SHAKE_COUNTER; } } } // Crea un SmartSprite para arrojar el item café al recibir un impacto void Game::throwCoffee(int x, int y) { - auto *ss = new SmartSprite(itemTextures[4], renderer); - smartSprites.push_back(ss); + auto *ss = new SmartSprite(item_textures_[4], renderer_); + smart_sprites_.push_back(ss); ss->setPosX(x - 8); ss->setPosY(y - 8); @@ -2109,14 +2109,14 @@ void Game::throwCoffee(int x, int y) { // Actualiza los SmartSprites void Game::updateSmartSprites() { - for (auto *ss : smartSprites) { + for (auto *ss : smart_sprites_) { ss->update(); } } // Pinta los SmartSprites activos void Game::renderSmartSprites() { - for (auto *ss : smartSprites) { + for (auto *ss : smart_sprites_) { ss->render(); } } @@ -2127,52 +2127,52 @@ void Game::killPlayer(Player *player) { if (player->hasExtraHit()) { player->removeExtraHit(); throwCoffee(player->getPosX() + (player->getWidth() / 2), player->getPosY() + (player->getHeight() / 2)); - if (!demo.enabled) { - Audio::get()->playSound(coffeeOutSound); + if (!demo_.enabled) { + Audio::get()->playSound(coffee_out_sound_); } - } else if (deathSequence.phase == DeathPhase::None) { - if (!demo.enabled) { + } else if (death_sequence_.phase == DeathPhase::NONE) { + if (!demo_.enabled) { Audio::get()->pauseMusic(); - Audio::get()->playSound(playerCollisionSound); + Audio::get()->playSound(player_collision_sound_); } stopAllBalloons(10); shakeScreen(); - deathSequence.phase = DeathPhase::Shaking; - deathSequence.phaseStartTicks = SDL_GetTicks(); - deathSequence.player = player; + death_sequence_.phase = DeathPhase::SHAKING; + death_sequence_.phase_start_ticks = SDL_GetTicks(); + death_sequence_.player = player; } } } // Actualiza la secuencia de muerte del jugador void Game::updateDeathSequence() { - switch (deathSequence.phase) { - case DeathPhase::None: - case DeathPhase::Done: + switch (death_sequence_.phase) { + case DeathPhase::NONE: + case DeathPhase::DONE: break; - case DeathPhase::Shaking: + case DeathPhase::SHAKING: // Espera a que termine el efecto de agitación if (!isDeathShaking()) { - deathSequence.phase = DeathPhase::Waiting; - deathSequence.phaseStartTicks = SDL_GetTicks(); + death_sequence_.phase = DeathPhase::WAITING; + death_sequence_.phase_start_ticks = SDL_GetTicks(); } break; - case DeathPhase::Waiting: + case DeathPhase::WAITING: // Espera 500ms antes de completar la muerte - if (SDL_GetTicks() - deathSequence.phaseStartTicks >= 500) { - if (!demo.enabled) { - Audio::get()->playSound(coffeeOutSound); + if (SDL_GetTicks() - death_sequence_.phase_start_ticks >= 500) { + if (!demo_.enabled) { + Audio::get()->playSound(coffee_out_sound_); if (allPlayersAreDead()) { Audio::get()->stopMusic(); } else { Audio::get()->resumeMusic(); } } - deathSequence.player->setAlive(false); - deathSequence.phase = DeathPhase::Done; - deathSequence.player = nullptr; + death_sequence_.player->setAlive(false); + death_sequence_.phase = DeathPhase::DONE; + death_sequence_.player = nullptr; } break; } @@ -2180,39 +2180,39 @@ void Game::updateDeathSequence() { // Calcula y establece el valor de amenaza en funcion de los globos activos void Game::evaluateAndSetMenace() { - menaceCurrent = std::accumulate(balloons.begin(), balloons.end(), Uint8(0), [](Uint8 acc, Balloon *b) { return b->isEnabled() ? acc + b->getMenace() : acc; }); + menace_current_ = std::accumulate(balloons_.begin(), balloons_.end(), Uint8(0), [](Uint8 acc, Balloon *b) { return b->isEnabled() ? acc + b->getMenace() : acc; }); } // Obtiene el valor de la variable auto Game::getMenace() const -> Uint8 { - return menaceCurrent; + return menace_current_; } // Establece el valor de la variable void Game::setTimeStopped(bool value) { - timeStopped = value; + time_stopped_ = value; } // Obtiene el valor de la variable auto Game::isTimeStopped() const -> bool { - return timeStopped; + return time_stopped_; } // Establece el valor de la variable void Game::setTimeStoppedCounter(Uint16 value) { - timeStoppedCounter = value; + time_stopped_counter_ = value; } // Incrementa el valor de la variable void Game::incTimeStoppedCounter(Uint16 value) { - timeStoppedCounter += value; + time_stopped_counter_ += value; } // Actualiza y comprueba el valor de la variable void Game::updateTimeStoppedCounter() { if (isTimeStopped()) { - if (timeStoppedCounter > 0) { - timeStoppedCounter--; + if (time_stopped_counter_ > 0) { + time_stopped_counter_--; stopAllBalloons(TIME_STOPPED_COUNTER); } else { disableTimeStopItem(); @@ -2222,8 +2222,8 @@ void Game::updateTimeStoppedCounter() { // Actualiza la variable enemyDeployCounter void Game::updateEnemyDeployCounter() { - if (enemyDeployCounter > 0) { - enemyDeployCounter--; + if (enemy_deploy_counter_ > 0) { + enemy_deploy_counter_--; } } @@ -2237,17 +2237,17 @@ void Game::update() { updateDeathSequence(); // Durante la secuencia de muerte, congela el resto del juego - if (deathSequence.phase == DeathPhase::Shaking || deathSequence.phase == DeathPhase::Waiting) { + if (death_sequence_.phase == DeathPhase::SHAKING || death_sequence_.phase == DeathPhase::WAITING) { return; } // Comprueba que la diferencia de ticks sea mayor a la velocidad del juego - if (SDL_GetTicks() - ticks > ticksSpeed) { + if (SDL_GetTicks() - ticks_ > ticks_speed_) { // Actualiza el contador de ticks - ticks = SDL_GetTicks(); + ticks_ = SDL_GetTicks(); // Actualiza el contador de juego - counter++; + counter_++; // Comprueba el teclado/mando checkGameInput(); @@ -2306,89 +2306,89 @@ void Game::update() { // Actualiza el fondo void Game::updateBackground() { - if (!gameCompleted) { // Si el juego no esta completo, la velocidad de las nubes es igual a los globos explotados - cloudsSpeed = balloonsPopped; + if (!game_completed_) { // Si el juego no esta completo, la velocidad de las nubes es igual a los globos explotados + clouds_speed_ = balloons_popped_; } else { // Si el juego está completado, se reduce la velocidad de las nubes - if (cloudsSpeed > 400) { - cloudsSpeed -= 25; + if (clouds_speed_ > 400) { + clouds_speed_ -= 25; } else { - cloudsSpeed = 200; + clouds_speed_ = 200; } } // 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)cloudsSpeed / (float)totalPowerToCompleteGame)); + const float speed = (-0.2F) + (-3.00F * ((float)clouds_speed_ / (float)total_power_to_complete_game_)); // Aplica la velocidad calculada a las nubes - clouds1A->setVelX(speed); - clouds1B->setVelX(speed); - clouds2A->setVelX(speed / 2); - clouds2B->setVelX(speed / 2); + clouds1_a_->setVelX(speed); + clouds1_b_->setVelX(speed); + clouds2_a_->setVelX(speed / 2); + clouds2_b_->setVelX(speed / 2); // Mueve las nubes - clouds1A->move(); - clouds1B->move(); - clouds2A->move(); - clouds2B->move(); + clouds1_a_->move(); + clouds1_b_->move(); + clouds2_a_->move(); + clouds2_b_->move(); // Calcula el offset de las nubes - if (clouds1A->getPosX() < -clouds1A->getWidth()) { - clouds1A->setPosX(clouds1A->getWidth()); + if (clouds1_a_->getPosX() < -clouds1_a_->getWidth()) { + clouds1_a_->setPosX(clouds1_a_->getWidth()); } - if (clouds1B->getPosX() < -clouds1B->getWidth()) { - clouds1B->setPosX(clouds1B->getWidth()); + if (clouds1_b_->getPosX() < -clouds1_b_->getWidth()) { + clouds1_b_->setPosX(clouds1_b_->getWidth()); } - if (clouds2A->getPosX() < -clouds2A->getWidth()) { - clouds2A->setPosX(clouds2A->getWidth()); + if (clouds2_a_->getPosX() < -clouds2_a_->getWidth()) { + clouds2_a_->setPosX(clouds2_a_->getWidth()); } - if (clouds2B->getPosX() < -clouds2B->getWidth()) { - clouds2B->setPosX(clouds2B->getWidth()); + if (clouds2_b_->getPosX() < -clouds2_b_->getWidth()) { + clouds2_b_->setPosX(clouds2_b_->getWidth()); } // Calcula el frame de la hierba - grassSprite->setSpriteClip(0, (6 * (counter / 20 % 2)), 256, 6); + grass_sprite_->setSpriteClip(0, (6 * (counter_ / 20 % 2)), 256, 6); // Mueve los edificios en funcion de si está activo el efecto de agitarlos - if (deathShake.active) { + if (death_shake_.active) { const int v[] = {-1, 1, -1, 1, -1, 1, -1, 0}; - buildingsSprite->setPosX(v[deathShake.step]); - } else if (effect.shake) { - buildingsSprite->setPosX(((effect.shakeCounter % 2) * 2) - 1); + buildings_sprite_->setPosX(v[death_shake_.step]); + } else if (effect_.shake) { + buildings_sprite_->setPosX(((effect_.shake_counter % 2) * 2) - 1); } else { - buildingsSprite->setPosX(0); + buildings_sprite_->setPosX(0); } } // Dibuja el fondo void Game::renderBackground() { - const float gradientNumber = std::min(((float)balloonsPopped / 1250.0F), 3.0F); + 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); // Dibuja el gradiente 2 - skyColorsSprite->setSpriteClip(skyColorsRect[((int)gradientNumber + 1) % 4]); - gameSkyColorsTexture->setAlpha(255); - skyColorsSprite->render(); + sky_colors_sprite_->setSpriteClip(sky_colors_rect_[((int)gradientNumber + 1) % 4]); + game_sky_colors_texture_->setAlpha(255); + sky_colors_sprite_->render(); // Dibuja el gradiente 1 con una opacidad cada vez menor - skyColorsSprite->setSpriteClip(skyColorsRect[(int)gradientNumber]); - gameSkyColorsTexture->setAlpha(alpha); - skyColorsSprite->render(); + sky_colors_sprite_->setSpriteClip(sky_colors_rect_[(int)gradientNumber]); + game_sky_colors_texture_->setAlpha(alpha); + sky_colors_sprite_->render(); // Dibuja las nubes - clouds1A->render(); - clouds1B->render(); - clouds2A->render(); - clouds2B->render(); + clouds1_a_->render(); + clouds1_b_->render(); + clouds2_a_->render(); + clouds2_b_->render(); // Dinuja los edificios - buildingsSprite->render(); + buildings_sprite_->render(); // Dibuja la hierba - grassSprite->render(); + grass_sprite_->render(); } // Dibuja el juego @@ -2409,12 +2409,12 @@ void Game::render() { renderScoreBoard(); renderPlayers(); - if ((deathCounter <= 150) && !players[0]->isAlive()) { - renderDeathFade(150 - deathCounter); + if ((death_counter_ <= 150) && !players_[0]->isAlive()) { + renderDeathFade(150 - death_counter_); } - if ((gameCompleted) && (gameCompletedCounter >= GAME_COMPLETED_START_FADE)) { - renderDeathFade(gameCompletedCounter - GAME_COMPLETED_START_FADE); + if ((game_completed_) && (game_completed_counter_ >= GAME_COMPLETED_START_FADE)) { + renderDeathFade(game_completed_counter_ - GAME_COMPLETED_START_FADE); } renderFlashEffect(); @@ -2425,18 +2425,18 @@ void Game::render() { // Gestiona el nivel de amenaza void Game::updateMenace() { - if (gameCompleted) { + if (game_completed_) { return; } - const float percent = stage[currentStage].currentPower / stage[currentStage].powerToComplete; - const Uint8 difference = stage[currentStage].maxMenace - stage[currentStage].minMenace; + 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 - menaceThreshold = stage[currentStage].minMenace + (difference * percent); + menace_threshold_ = stage_[current_stage_].min_menace + (difference * percent); // Si el nivel de amenza es inferior al umbral - if (menaceCurrent < menaceThreshold) { + if (menace_current_ < menace_threshold_) { // Crea una formación de enemigos deployEnemyFormation(); @@ -2447,86 +2447,86 @@ void Game::updateMenace() { // Gestiona la entrada durante el juego void Game::checkGameInput() { - demo.keys.left = 0; - demo.keys.right = 0; - demo.keys.noInput = 0; - demo.keys.fire = 0; - demo.keys.fireLeft = 0; - demo.keys.fireRight = 0; + demo_.keys.left = 0; + demo_.keys.right = 0; + demo_.keys.noInput = 0; + demo_.keys.fire = 0; + demo_.keys.fireLeft = 0; + demo_.keys.fireRight = 0; // Atalls globals (zoom finestra, fullscreen, shaders, presets, ...) GlobalInputs::handle(); // Modo Demo activo - if (demo.enabled) { + if (demo_.enabled) { const int index = 0; - if (demo.dataFile[demo.counter].left == 1) { - players[index]->setInput(input_left); + if (demo_.data_file[demo_.counter].left == 1) { + players_[index]->setInput(input_left); } - if (demo.dataFile[demo.counter].right == 1) { - players[index]->setInput(input_right); + if (demo_.data_file[demo_.counter].right == 1) { + players_[index]->setInput(input_right); } - if (demo.dataFile[demo.counter].noInput == 1) { - players[index]->setInput(input_null); + if (demo_.data_file[demo_.counter].noInput == 1) { + players_[index]->setInput(input_null); } - if (demo.dataFile[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 (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 (demo.dataFile[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 (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 (demo.dataFile[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 (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); } } // Si se pulsa cualquier tecla, se sale del modo demo if (Input::get()->checkAnyInput()) { - section->name = SECTION_PROG_TITLE; + section_->name = SECTION_PROG_TITLE; } // Incrementa el contador de la demo - if (demo.counter < TOTAL_DEMO_DATA) { - demo.counter++; + if (demo_.counter < TOTAL_DEMO_DATA) { + demo_.counter++; } else { - section->name = SECTION_PROG_TITLE; - section->subsection = SUBSECTION_TITLE_INSTRUCTIONS; + section_->name = SECTION_PROG_TITLE; + section_->subsection = SUBSECTION_TITLE_INSTRUCTIONS; } } // Modo Demo no activo else { int i = 0; - for (auto *player : players) { + for (auto *player : players_) { if (player->isAlive()) { // Input a la izquierda if (Input::get()->checkInput(input_left, REPEAT_TRUE, Options::inputs[i].deviceType, Options::inputs[i].id)) { player->setInput(input_left); - demo.keys.left = 1; + demo_.keys.left = 1; } else { // Input a la derecha if (Input::get()->checkInput(input_right, REPEAT_TRUE, Options::inputs[i].deviceType, Options::inputs[i].id)) { player->setInput(input_right); - demo.keys.right = 1; + demo_.keys.right = 1; } else { // Ninguno de los dos inputs anteriores player->setInput(input_null); - demo.keys.noInput = 1; + demo_.keys.noInput = 1; } } // Comprueba el input de disparar al centro @@ -2537,9 +2537,9 @@ void Game::checkGameInput() { player->setFireCooldown(10); // Reproduce el sonido de disparo - Audio::get()->playSound(bulletSound); + Audio::get()->playSound(bullet_sound_); - demo.keys.fire = 1; + demo_.keys.fire = 1; } } @@ -2551,9 +2551,9 @@ void Game::checkGameInput() { player->setFireCooldown(10); // Reproduce el sonido de disparo - Audio::get()->playSound(bulletSound); + Audio::get()->playSound(bullet_sound_); - demo.keys.fireLeft = 1; + demo_.keys.fireLeft = 1; } } @@ -2565,24 +2565,24 @@ void Game::checkGameInput() { player->setFireCooldown(10); // Reproduce el sonido de disparo - Audio::get()->playSound(bulletSound); + Audio::get()->playSound(bullet_sound_); - demo.keys.fireRight = 1; + demo_.keys.fireRight = 1; } } // Comprueba el input de pausa if (Input::get()->checkInput(input_pause, REPEAT_FALSE, Options::inputs[i].deviceType, Options::inputs[i].id)) { - section->subsection = SUBSECTION_GAME_PAUSE; + section_->subsection = SUBSECTION_GAME_PAUSE; } - if (demo.counter < TOTAL_DEMO_DATA) { - if (demo.recording) { - demo.dataFile[demo.counter] = demo.keys; + if (demo_.counter < TOTAL_DEMO_DATA) { + if (demo_.recording) { + demo_.data_file[demo_.counter] = demo_.keys; } - demo.counter++; - } else if (demo.recording) { - section->name = SECTION_PROG_QUIT; + demo_.counter++; + } else if (demo_.recording) { + section_->name = SECTION_PROG_QUIT; } i++; @@ -2594,51 +2594,51 @@ void Game::checkGameInput() { // Pinta diferentes mensajes en la pantalla void Game::renderMessages() { // GetReady - if ((counter < STAGE_COUNTER) && (!demo.enabled)) { - textNokiaBig2->write((int)getReadyBitmapPath[counter], PLAY_AREA_CENTER_Y - 8, Lang::get()->getText(75), -2); + if ((counter_ < STAGE_COUNTER) && (!demo_.enabled)) { + text_nokia_big2_->write((int)get_ready_bitmap_path_[counter_], PLAY_AREA_CENTER_Y - 8, Lang::get()->getText(75), -2); } // Time Stopped - if (timeStopped) { - if ((timeStoppedCounter > 100) || (timeStoppedCounter % 10 > 4)) { - textNokia2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, Lang::get()->getText(36) + std::to_string(timeStoppedCounter / 10), -1, noColor, 1, shdwTxtColor); + if (time_stopped_) { + if ((time_stopped_counter_ > 100) || (time_stopped_counter_ % 10 > 4)) { + text_nokia2_->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, Lang::get()->getText(36) + std::to_string(time_stopped_counter_ / 10), -1, noColor, 1, shdwTxtColor); } - if (timeStoppedCounter > 100) { - if (timeStoppedCounter % 30 == 0) { - Audio::get()->playSound(clockSound); + if (time_stopped_counter_ > 100) { + if (time_stopped_counter_ % 30 == 0) { + Audio::get()->playSound(clock_sound_); } } else { - if (timeStoppedCounter % 15 == 0) { - Audio::get()->playSound(clockSound); + if (time_stopped_counter_ % 15 == 0) { + Audio::get()->playSound(clock_sound_); } } } // D E M O - if (demo.enabled) { - if (demo.counter % 30 > 14) { - textNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, Lang::get()->getText(37), 0, noColor, 2, shdwTxtColor); + if (demo_.enabled) { + if (demo_.counter % 30 > 14) { + text_nokia_big2_->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, Lang::get()->getText(37), 0, noColor, 2, shdwTxtColor); } } // STAGE NUMBER - if (stageBitmapCounter < STAGE_COUNTER) { - const int stageNum = stage[currentStage].number; + if (stage_bitmap_counter_ < STAGE_COUNTER) { + const int stageNum = stage_[current_stage_].number; std::string stageText; if (stageNum == 10) { // Ultima fase stageText = Lang::get()->getText(79); } else { // X fases restantes - stageText = std::to_string(11 - stage[currentStage].number) + Lang::get()->getText(38); + stageText = std::to_string(11 - stage_[current_stage_].number) + Lang::get()->getText(38); } - if (!gameCompleted) { // Escribe el numero de fases restantes - textNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, stageBitmapPath[stageBitmapCounter], stageText, -2, noColor, 2, shdwTxtColor); + 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); } else { // Escribe el texto de juego completado stageText = Lang::get()->getText(50); - textNokiaBig2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, stageBitmapPath[stageBitmapCounter], stageText, -2, noColor, 1, shdwTxtColor); - textNokia2->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, stageBitmapPath[stageBitmapCounter] + textNokiaBig2->getCharacterSize() + 2, Lang::get()->getText(76), -1, noColor, 1, shdwTxtColor); + text_nokia_big2_->writeDX(TXT_CENTER, PLAY_AREA_CENTER_X, stage_bitmap_path_[stage_bitmap_counter_], stageText, -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); } } } @@ -2655,7 +2655,7 @@ void Game::enableTimeStopItem() { // Deshabilita el efecto del item de detener el tiempo void Game::disableTimeStopItem() { - timeStopped = false; + time_stopped_ = false; setTimeStoppedCounter(0); startAllBalloons(); if (Audio::getRealMusicState() == Audio::MusicState::PAUSED) { @@ -2665,46 +2665,46 @@ void Game::disableTimeStopItem() { // Inicia el efecto de agitación intensa de la pantalla void Game::shakeScreen() { - deathShake.active = true; - deathShake.step = 0; - deathShake.lastStepTicks = SDL_GetTicks(); + death_shake_.active = true; + death_shake_.step = 0; + death_shake_.last_step_ticks = SDL_GetTicks(); } // Actualiza el efecto de agitación intensa void Game::updateDeathShake() { - if (!deathShake.active) { + if (!death_shake_.active) { return; } Uint32 now = SDL_GetTicks(); - if (now - deathShake.lastStepTicks >= 50) { - deathShake.lastStepTicks = now; - deathShake.step++; - if (deathShake.step >= 8) { - deathShake.active = false; + if (now - death_shake_.last_step_ticks >= 50) { + death_shake_.last_step_ticks = now; + death_shake_.step++; + if (death_shake_.step >= 8) { + death_shake_.active = false; } } } // Indica si el efecto de agitación intensa está activo auto Game::isDeathShaking() const -> bool { - return deathShake.active; + return death_shake_.active; } // Ejecuta un frame del juego void Game::iterate() { // En modo demo, no hay pausa ni game over - if (demo.enabled) { - if (section->subsection == SUBSECTION_GAME_PAUSE || section->subsection == SUBSECTION_GAME_GAMEOVER) { - section->name = SECTION_PROG_TITLE; - section->subsection = SUBSECTION_TITLE_INSTRUCTIONS; + if (demo_.enabled) { + if (section_->subsection == SUBSECTION_GAME_PAUSE || section_->subsection == SUBSECTION_GAME_GAMEOVER) { + section_->name = SECTION_PROG_TITLE; + section_->subsection = SUBSECTION_TITLE_INSTRUCTIONS; return; } } // Sección juego en pausa - if (section->subsection == SUBSECTION_GAME_PAUSE) { - if (!pauseInitialized) { + if (section_->subsection == SUBSECTION_GAME_PAUSE) { + if (!pause_initialized_) { enterPausedGame(); } updatePausedGame(); @@ -2712,8 +2712,8 @@ void Game::iterate() { } // Sección Game Over - else if (section->subsection == SUBSECTION_GAME_GAMEOVER) { - if (!gameOverInitialized) { + else if (section_->subsection == SUBSECTION_GAME_GAMEOVER) { + if (!game_over_initialized_) { enterGameOverScreen(); } updateGameOverScreen(); @@ -2721,17 +2721,17 @@ void Game::iterate() { } // Sección juego jugando - else if ((section->subsection == SUBSECTION_GAME_PLAY_1P) || (section->subsection == SUBSECTION_GAME_PLAY_2P)) { + else if ((section_->subsection == SUBSECTION_GAME_PLAY_1P) || (section_->subsection == SUBSECTION_GAME_PLAY_2P)) { // Resetea los flags de inicialización de sub-estados - pauseInitialized = false; - gameOverInitialized = false; + pause_initialized_ = false; + game_over_initialized_ = false; // Si la música no está sonando if ((Audio::getRealMusicState() == Audio::MusicState::STOPPED) || (Audio::getRealMusicState() == Audio::MusicState::STOPPED)) { // Reproduce la música (nunca en modo demo: deja sonar la del título) - if (!gameCompleted && !demo.enabled) { - if (players[0]->isAlive()) { - Audio::get()->playMusic(gameMusic); + if (!game_completed_ && !demo_.enabled) { + if (players_[0]->isAlive()) { + Audio::get()->playMusic(game_music_); } } } @@ -2751,7 +2751,7 @@ void Game::iterate() { // Indica si el juego ha terminado auto Game::hasFinished() const -> bool { - return section->name != SECTION_PROG_GAME; + return section_->name != SECTION_PROG_GAME; } // Procesa un evento individual @@ -2760,8 +2760,8 @@ void Game::handleEvent(const SDL_Event *event) { if (event->type == SDL_EVENT_WINDOW_FOCUS_LOST) { // Solo pausar durante el juego activo (no en demo, game over, ni ya en pausa) - if (!demo.enabled && (section->subsection == SUBSECTION_GAME_PLAY_1P || section->subsection == SUBSECTION_GAME_PLAY_2P)) { - section->subsection = SUBSECTION_GAME_PAUSE; + if (!demo_.enabled && (section_->subsection == SUBSECTION_GAME_PLAY_1P || section_->subsection == SUBSECTION_GAME_PLAY_2P)) { + section_->subsection = SUBSECTION_GAME_PAUSE; } } @@ -2774,12 +2774,12 @@ void Game::handleEvent(const SDL_Event *event) { #endif // Eventos específicos de la pantalla de game over - if (section->subsection == SUBSECTION_GAME_GAMEOVER) { + if (section_->subsection == SUBSECTION_GAME_GAMEOVER) { if (event->type == SDL_EVENT_KEY_DOWN && static_cast(event->key.repeat) == 0) { - if (gameCompleted) { - gameOverPostFade = 1; - fade->activateFade(); - Audio::get()->playSound(itemPickUpSound); + if (game_completed_) { + game_over_post_fade_ = 1; + fade_->activateFade(); + Audio::get()->playSound(item_pick_up_sound_); } } } @@ -2795,45 +2795,45 @@ void Game::run() { // Actualiza las variables del menu de pausa del juego void Game::updatePausedGame() { // Calcula la lógica de los objetos - if (SDL_GetTicks() - ticks > ticksSpeed) { + if (SDL_GetTicks() - ticks_ > ticks_speed_) { // Actualiza el contador de ticks - ticks = SDL_GetTicks(); + ticks_ = SDL_GetTicks(); // Atalls globals (zoom finestra, fullscreen, shaders, presets, ...) GlobalInputs::handle(); - if (leavingPauseMenu) { - if (pauseCounter > 0) { // El contador está descendiendo - const bool a = pauseCounter == 90; - const bool b = pauseCounter == 60; - const bool c = pauseCounter == 30; + 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) { - Audio::get()->playSound(clockSound); + Audio::get()->playSound(clock_sound_); } - pauseCounter--; + pause_counter_--; } else { // Ha finalizado el contador - section->name = SECTION_PROG_GAME; - section->subsection = numPlayers == 1 ? SUBSECTION_GAME_PLAY_1P : SUBSECTION_GAME_PLAY_2P; + section_->name = SECTION_PROG_GAME; + section_->subsection = num_players_ == 1 ? SUBSECTION_GAME_PLAY_1P : SUBSECTION_GAME_PLAY_2P; if (Audio::getRealMusicState() == Audio::MusicState::PAUSED) { Audio::get()->resumeMusic(); } } } else { // Actualiza la lógica del menu de pausa - pauseMenu->update(); + pause_menu_->update(); // Comprueba las entradas para el menu - pauseMenu->checkInput(); + pause_menu_->checkInput(); // Comprueba si se ha seleccionado algún item del menú - switch (pauseMenu->getItemSelected()) { + switch (pause_menu_->getItemSelected()) { case 1: - leavingPauseMenu = true; + leaving_pause_menu_ = true; break; case 2: - fade->setFadeType(FADE_CENTER); - fade->activateFade(); + fade_->setFadeType(FADE_CENTER); + fade_->activateFade(); break; default: @@ -2841,10 +2841,10 @@ void Game::updatePausedGame() { } // Actualiza el fade - fade->update(); - if (fade->hasEnded()) { - section->name = SECTION_PROG_TITLE; - section->subsection = SUBSECTION_TITLE_1; + fade_->update(); + if (fade_->hasEnded()) { + section_->name = SECTION_PROG_TITLE; + section_->subsection = SUBSECTION_TITLE_1; Audio::get()->stopMusic(); } } @@ -2870,23 +2870,23 @@ void Game::renderPausedGame() { renderScoreBoard(); renderPlayers(); - if ((deathCounter <= 150) && !players[0]->isAlive()) { - renderDeathFade(150 - deathCounter); + if ((death_counter_ <= 150) && !players_[0]->isAlive()) { + renderDeathFade(150 - death_counter_); } - if ((gameCompleted) && (gameCompletedCounter >= GAME_COMPLETED_START_FADE)) { - renderDeathFade(gameCompletedCounter - GAME_COMPLETED_START_FADE); + if ((game_completed_) && (game_completed_counter_ >= GAME_COMPLETED_START_FADE)) { + renderDeathFade(game_completed_counter_ - GAME_COMPLETED_START_FADE); } renderFlashEffect(); } - if (leavingPauseMenu) { - textNokiaBig2->writeCentered(GAMECANVAS_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, std::to_string((pauseCounter / 30) + 1)); + if (leaving_pause_menu_) { + text_nokia_big2_->writeCentered(GAMECANVAS_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, std::to_string((pause_counter_ / 30) + 1)); } else { - pauseMenu->render(); + pause_menu_->render(); } - fade->render(); + fade_->render(); // Vuelca el contenido del renderizador en pantalla Screen::get()->blit(); @@ -2900,43 +2900,43 @@ void Game::enterPausedGame() { } // Reinicia el menu - pauseMenu->reset(); - leavingPauseMenu = false; + pause_menu_->reset(); + leaving_pause_menu_ = false; // Inicializa variables - pauseCounter = 90; - pauseInitialized = true; + pause_counter_ = 90; + pause_initialized_ = true; } // Actualiza los elementos de la pantalla de game over void Game::updateGameOverScreen() { // Calcula la lógica de los objetos - if (SDL_GetTicks() - ticks > ticksSpeed) { + if (SDL_GetTicks() - ticks_ > ticks_speed_) { // Actualiza el contador de ticks - ticks = SDL_GetTicks(); + ticks_ = SDL_GetTicks(); // Atalls globals (zoom finestra, fullscreen, shaders, presets, ...) GlobalInputs::handle(); // Actualiza la lógica del menu - gameOverMenu->update(); + game_over_menu_->update(); // Actualiza el fade - fade->update(); + fade_->update(); // Si ha terminado el fade, actua segun se haya operado - if (fade->hasEnded()) { - switch (gameOverPostFade) { + if (fade_->hasEnded()) { + switch (game_over_post_fade_) { case 0: // YES - section->name = SECTION_PROG_GAME; + section_->name = SECTION_PROG_GAME; deleteAllVectorObjects(); init(); - section->subsection = numPlayers == 1 ? SUBSECTION_GAME_PLAY_1P : SUBSECTION_GAME_PLAY_2P; + section_->subsection = num_players_ == 1 ? SUBSECTION_GAME_PLAY_1P : SUBSECTION_GAME_PLAY_2P; break; case 1: // NO - section->name = SECTION_PROG_TITLE; - section->subsection = SUBSECTION_TITLE_1; + section_->name = SECTION_PROG_TITLE; + section_->subsection = SUBSECTION_TITLE_1; break; default: @@ -2945,19 +2945,19 @@ void Game::updateGameOverScreen() { } // Comprueba las entradas para el menu solo si no esta el juego completo - if (!gameCompleted) { - gameOverMenu->checkInput(); + if (!game_completed_) { + game_over_menu_->checkInput(); // Comprueba si se ha seleccionado algún item del menú - switch (gameOverMenu->getItemSelected()) { + switch (game_over_menu_->getItemSelected()) { case 0: // YES - gameOverPostFade = 0; - fade->activateFade(); + game_over_post_fade_ = 0; + fade_->activateFade(); break; case 1: // NO - gameOverPostFade = 1; - fade->activateFade(); + game_over_post_fade_ = 1; + fade_->activateFade(); break; default: @@ -2976,48 +2976,48 @@ void Game::renderGameOverScreen() { Screen::get()->clean(bgColor); // Dibujo - if (!gameCompleted) { // Dibujo de haber perdido la partida - gameOverSprite->render(); + if (!game_completed_) { // Dibujo de haber perdido la partida + game_over_sprite_->render(); } else { // Dinujo de haber completado la partida - gameOverEndSprite->render(); + game_over_end_sprite_->render(); } // Dibuja los objetos - if (numPlayers == 1) { + if (num_players_ == 1) { // Congratulations!! - if (gameCompleted) { - text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 8), Lang::get()->getText(50)); + if (game_completed_) { + text_->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 8), Lang::get()->getText(50)); } // Game Over - textBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 6), Lang::get()->getText(43)); + text_big_->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 6), Lang::get()->getText(43)); // Your Score - text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 3), Lang::get()->getText(44) + std::to_string(players[0]->getScore())); + text_->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 3), Lang::get()->getText(44) + std::to_string(players_[0]->getScore())); } else { // Congratulations!! - if (gameCompleted) { - text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 9), Lang::get()->getText(50)); + if (game_completed_) { + text_->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 9), Lang::get()->getText(50)); } // Game Over - textBig->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 7), Lang::get()->getText(43)); + text_big_->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 7), Lang::get()->getText(43)); // Player1 Score - text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 4), Lang::get()->getText(77) + std::to_string(players[0]->getScore())); + text_->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 4), Lang::get()->getText(77) + std::to_string(players_[0]->getScore())); // Player2 Score - text->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 2), Lang::get()->getText(78) + std::to_string(players[1]->getScore())); + text_->writeCentered(PLAY_AREA_CENTER_X, PLAY_AREA_CENTER_Y - (BLOCK * 2), Lang::get()->getText(78) + std::to_string(players_[1]->getScore())); } // Continue? - if (!gameCompleted) { // Solo dibuja el menu de continuar en el caso de no haber completado la partida - text->writeCentered(199, PLAY_AREA_CENTER_Y + (BLOCK * 3), Lang::get()->getText(45)); - gameOverMenu->render(); + if (!game_completed_) { // Solo dibuja el menu de continuar en el caso de no haber completado la partida + text_->writeCentered(199, PLAY_AREA_CENTER_Y + (BLOCK * 3), Lang::get()->getText(45)); + game_over_menu_->render(); } // Pinta el fade - fade->render(); + fade_->render(); // Vuelca el contenido del renderizador en pantalla Screen::get()->blit(); @@ -3029,19 +3029,19 @@ void Game::enterGameOverScreen() { saveScoreFile(); // Reinicia el menu - gameOverMenu->reset(); - gameOverPostFade = 0; - gameOverInitialized = true; + game_over_menu_->reset(); + game_over_post_fade_ = 0; + game_over_initialized_ = true; } // Indica si se puede crear una powerball auto Game::canPowerBallBeCreated() -> bool { - return (!powerBallEnabled) && (calculateScreenPower() > POWERBALL_SCREENPOWER_MINIMUM) && (powerBallCounter == 0); + return (!power_ball_enabled_) && (calculateScreenPower() > Balloon::POWERBALL_SCREENPOWER_MINIMUM) && (power_ball_counter_ == 0); } // Calcula el poder actual de los globos en pantalla auto Game::calculateScreenPower() -> int { - return std::accumulate(balloons.begin(), balloons.end(), 0, [](int acc, Balloon *b) { return b->isEnabled() ? acc + b->getPower() : acc; }); + return std::accumulate(balloons_.begin(), balloons_.end(), 0, [](int acc, Balloon *b) { return b->isEnabled() ? acc + b->getPower() : acc; }); } // Inicializa las variables que contienen puntos de ruta para mover objetos @@ -3060,20 +3060,20 @@ void Game::initPaths() { for (int i = 0; i < STAGE_COUNTER; ++i) { if (i < firstPart) { - stageBitmapPath[i] = (sin[(int)((i * 1.8F) + 90)] * (distance) + centerPoint); + stage_bitmap_path_[i] = (sin[(int)((i * 1.8F) + 90)] * (distance) + centerPoint); } else if (i < secondPart) { - stageBitmapPath[i] = (int)centerPoint; + stage_bitmap_path_[i] = (int)centerPoint; } else { - stageBitmapPath[i] = (sin[(int)(((i - 149) * 1.8F) + 90)] * (centerPoint + 17) - 17); + stage_bitmap_path_[i] = (sin[(int)(((i - 149) * 1.8F) + 90)] * (centerPoint + 17) - 17); } } // Letrero de GetReady - const int size = textNokiaBig2->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); @@ -3086,53 +3086,53 @@ void Game::initPaths() { for (int i = 0; i < STAGE_COUNTER; ++i) { if (i < firstPart) { - getReadyBitmapPath[i] = sin[(int)(i * 1.8F)]; - getReadyBitmapPath[i] *= distance1; - getReadyBitmapPath[i] -= size; + get_ready_bitmap_path_[i] = sin[(int)(i * 1.8F)]; + get_ready_bitmap_path_[i] *= distance1; + get_ready_bitmap_path_[i] -= size; } else if (i < secondPart) { - getReadyBitmapPath[i] = (int)finish1; + get_ready_bitmap_path_[i] = (int)finish1; } else { - getReadyBitmapPath[i] = sin[(int)((i - 150) * 1.8F)]; - getReadyBitmapPath[i] *= distance2; - getReadyBitmapPath[i] += finish1; + get_ready_bitmap_path_[i] = sin[(int)((i - 150) * 1.8F)]; + get_ready_bitmap_path_[i] *= distance2; + get_ready_bitmap_path_[i] += finish1; } } } // Actualiza el tramo final de juego, una vez completado void Game::updateGameCompleted() { - if (gameCompleted) { - gameCompletedCounter++; + if (game_completed_) { + game_completed_counter_++; } - if (gameCompletedCounter == GAME_COMPLETED_END) { - section->subsection = SUBSECTION_GAME_GAMEOVER; + if (game_completed_counter_ == GAME_COMPLETED_END) { + section_->subsection = SUBSECTION_GAME_GAMEOVER; } } // Actualiza las variables de ayuda void Game::updateHelper() { // Solo ofrece ayuda cuando la amenaza es elevada - if (menaceCurrent > 15) { - for (auto *player : players) { - helper.needCoffee = player->getCoffees() == 0; + if (menace_current_ > 15) { + for (auto *player : players_) { + helper_.need_coffee = player->getCoffees() == 0; - helper.needCoffeeMachine = !player->isPowerUp(); + helper_.need_coffee_machine = !player->isPowerUp(); } } else { - helper.needCoffee = false; - helper.needCoffeeMachine = false; + helper_.need_coffee = false; + helper_.need_coffee_machine = false; } } // Comprueba si todos los jugadores han muerto auto Game::allPlayersAreDead() -> bool { bool success = true; - for (auto *player : players) { + for (auto *player : players_) { success &= (!player->isAlive()); } @@ -3141,35 +3141,35 @@ auto Game::allPlayersAreDead() -> bool { // Elimina todos los objetos contenidos en vectores void Game::deleteAllVectorObjects() { - for (auto *player : players) { + for (auto *player : players_) { delete player; }; - players.clear(); + players_.clear(); - for (auto *ballon : balloons) { + for (auto *ballon : balloons_) { delete ballon; }; - balloons.clear(); + balloons_.clear(); - for (auto *bullet : bullets) { + for (auto *bullet : bullets_) { delete bullet; }; - bullets.clear(); + bullets_.clear(); - for (auto *item : items) { + for (auto *item : items_) { delete item; }; - items.clear(); + items_.clear(); - for (auto *smartSprite : smartSprites) { + for (auto *smartSprite : smart_sprites_) { delete smartSprite; }; - smartSprites.clear(); + smart_sprites_.clear(); } // Establece la máxima puntuación desde fichero o desde las puntuaciones online void Game::setHiScore() { // Carga el fichero de puntos loadScoreFile(); - hiScoreName = ""; + hi_score_name_ = ""; } \ No newline at end of file diff --git a/source/game/game.h b/source/game/game.h index bd2760f..8ce05e3 100644 --- a/source/game/game.h +++ b/source/game/game.h @@ -54,14 +54,14 @@ class Game { 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 - float velX; // Velocidad inicial en el eje X + float vel_x; // Velocidad inicial en el eje X Uint8 kind; // Tipo de enemigo - Uint16 creationCounter; // Temporizador para la creación del enemigo + Uint16 creation_counter; // Temporizador para la creación del enemigo }; struct EnemyFormation // Contiene la información de una formación enemiga { - Uint8 numberOfEnemies; // 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,51 +71,53 @@ class Game { struct Stage // Contiene todas las variables relacionadas con una fase { - EnemyPool *enemyPool; // El conjunto de formaciones enemigas de la fase - Uint16 currentPower; // Cantidad actual de poder - Uint16 powerToComplete; // Cantidad de poder que se necesita para completar la fase - Uint8 maxMenace; // Umbral máximo de amenaza de la fase - Uint8 minMenace; // Umbral mínimo de amenaza de la fase + 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 }; struct Effect { bool flash; // Indica si se ha de pintar la pantalla de blanco bool shake; // Indica si se ha de agitar la pantalla - Uint8 shakeCounter; // Contador para medir el tiempo que dura el efecto + 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) - Uint32 lastStepTicks; // Ticks del último paso + Uint32 last_step_ticks; // Ticks del último paso }; // Fases de la secuencia de muerte del jugador - enum class DeathPhase : std::uint8_t { None, - Shaking, - Waiting, - Done }; + enum class DeathPhase : std::uint8_t { + NONE, + SHAKING, + WAITING, + DONE + }; // Estado de la secuencia de muerte del jugador struct DeathSequence { DeathPhase phase; // Fase actual - Uint32 phaseStartTicks; // Ticks del inicio de la fase actual + Uint32 phase_start_ticks; // Ticks del inicio de la fase actual Player *player; // Jugador que está muriendo }; struct Helper { - bool needCoffee; // Indica si se necesitan cafes - bool needCoffeeMachine; // Indica si se necesita PowerUp - bool needPowerBall; // Indica si se necesita una PowerBall + 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 itemPoints1Odds; // Probabilidad de aparición del objeto - int itemPoints2Odds; // Probabilidad de aparición del objeto - int itemPoints3Odds; // Probabilidad de aparición del objeto - int itemClockOdds; // Probabilidad de aparición del objeto - int itemCoffeeOdds; // Probabilidad de aparición del objeto - int itemCoffeeMachineOdds; // Probabilidad de aparición del objeto + 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 { @@ -123,133 +125,133 @@ class Game { 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 dataFile[TOTAL_DEMO_DATA]; // Datos del fichero con los movimientos para la demo + DemoKeys data_file[TOTAL_DEMO_DATA]; // Datos del fichero con los movimientos para la demo }; // Objetos y punteros - SDL_Renderer *renderer; // El renderizador de la ventana - Section *section; // Seccion actual dentro del juego + 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 smartSprites; // Vector con los smartsprites + 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 *bulletTexture; // Textura para las balas - std::vector itemTextures; // Vector con las texturas de los items - std::vector balloonTextures; // Vector con las texturas de los globos - std::vector player1Textures; // Vector con las texturas del jugador - std::vector player2Textures; // Vector con las texturas del jugador - std::vector> playerTextures; // Vector con todas las texturas de los jugadores; + Texture *bullet_texture_; // Textura para las balas + std::vector item_textures_; // Vector con las texturas de los items + std::vector balloon_textures_; // Vector con las texturas de los globos + std::vector player1_textures_; // Vector con las texturas del jugador + std::vector player2_textures_; // Vector con las texturas del jugador + std::vector> player_textures_; // Vector con todas las texturas de los jugadores; - Texture *gameBuildingsTexture; // Textura con los edificios de fondo - Texture *gameCloudsTexture; // Textura con las nubes de fondo - Texture *gameGrassTexture; // Textura con la hierba del suelo - Texture *gamePowerMeterTexture; // Textura con el marcador de poder de la fase - Texture *gameSkyColorsTexture; // Textura con los diferentes colores de fondo del juego - Texture *gameTextTexture; // Textura para los sprites con textos - Texture *gameOverTexture; // Textura para la pantalla de game over - Texture *gameOverEndTexture; // Textura para la pantalla de game over de acabar el juego + 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_over_end_texture_; // Textura para la pantalla de game over de acabar el juego - std::vector *> itemAnimations; // Vector con las animaciones de los items - std::vector *> playerAnimations; // Vector con las animaciones del jugador - std::vector *> balloonAnimations; // Vector con las animaciones de los globos + 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 *textBig; // Fuente de texto grande - Text *textScoreBoard; // Fuente para el marcador del juego - Text *textNokia2; // Otra fuente de texto para mensajes - Text *textNokiaBig2; // Y la versión en grande + 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 - Menu *gameOverMenu; // Menú de la pantalla de game over - Menu *pauseMenu; // Menú de la pantalla de pausa + Menu *game_over_menu_; // Menú de la pantalla de game over + Menu *pause_menu_; // Menú de la pantalla de pausa - Fade *fade; // Objeto para renderizar fades - SDL_Event *eventHandler; // Manejador de eventos + Fade *fade_; // Objeto para renderizar fades + SDL_Event *event_handler_; // Manejador de eventos - MovingSprite *clouds1A; // Sprite para las nubes superiores - MovingSprite *clouds1B; // Sprite para las nubes superiores - MovingSprite *clouds2A; // Sprite para las nubes inferiores - MovingSprite *clouds2B; // Sprite para las nubes inferiores - SmartSprite *n1000Sprite; // Sprite con el texto 1.000 - SmartSprite *n2500Sprite; // Sprite con el texto 2.500 - SmartSprite *n5000Sprite; // Sprite con el texto 5.000 + MovingSprite *clouds1_a_; // Sprite para las nubes superiores + MovingSprite *clouds1_b_; // Sprite para las nubes superiores + MovingSprite *clouds2_a_; // Sprite para las nubes inferiores + MovingSprite *clouds2_b_; // Sprite para las nubes inferiores + SmartSprite *n1000_sprite_; // Sprite con el texto 1.000 + SmartSprite *n2500_sprite_; // Sprite con el texto 2.500 + SmartSprite *n5000_sprite_; // Sprite con el texto 5.000 - Sprite *buildingsSprite; // Sprite con los edificios de fondo - Sprite *skyColorsSprite; // Sprite con los graficos del degradado de color de fondo - Sprite *grassSprite; // Sprite para la hierba - Sprite *powerMeterSprite; // Sprite para el medidor de poder de la fase - Sprite *gameOverSprite; // Sprite para dibujar los graficos del game over - Sprite *gameOverEndSprite; // Sprite para dibujar los graficos del game over de acabar el juego + 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 *balloonSound; // Sonido para la explosión del globo - JA_Sound_t *bulletSound; // Sonido para los disparos - JA_Sound_t *playerCollisionSound; // Sonido para la colisión del jugador con un enemigo - JA_Sound_t *hiScoreSound; // Sonido para cuando se alcanza la máxima puntuación - JA_Sound_t *itemDropSound; // Sonido para cuando se genera un item - JA_Sound_t *itemPickUpSound; // Sonido para cuando se recoge un item - JA_Sound_t *coffeeOutSound; // Sonido para cuando el jugador pierde el café al recibir un impacto - JA_Sound_t *stageChangeSound; // Sonido para cuando se cambia de fase - JA_Sound_t *bubble1Sound; // Sonido para cuando el jugador muere - JA_Sound_t *bubble2Sound; // Sonido para cuando el jugador muere - JA_Sound_t *bubble3Sound; // Sonido para cuando el jugador muere - JA_Sound_t *bubble4Sound; // Sonido para cuando el jugador muere - JA_Sound_t *clockSound; // Sonido para cuando se detiene el tiempo con el item reloj - JA_Sound_t *powerBallSound; // Sonido para cuando se explota una Power Ball - JA_Sound_t *coffeeMachineSound; // Sonido para cuando la máquina de café toca el suelo + 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 *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 *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 - JA_Music_t *gameMusic; // Musica de fondo + JA_Music_t *game_music_; // Musica de fondo // Variables - int numPlayers; // Numero de jugadores - Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa - Uint8 ticksSpeed; // Velocidad a la que se repiten los bucles del programa - Uint32 hiScore; // Puntuación máxima - bool hiScoreAchieved; // Indica si se ha superado la puntuación máxima - std::string hiScoreName; // Nombre del jugador que ostenta la máxima puntuación - Stage stage[10]; // Variable con los datos de cada pantalla - Uint8 currentStage; // Indica la fase actual - Uint8 stageBitmapCounter; // Contador para el tiempo visible del texto de Stage - float stageBitmapPath[STAGE_COUNTER]; // Vector con los puntos Y por donde se desplaza el texto - float getReadyBitmapPath[STAGE_COUNTER]; // Vector con los puntos X por donde se desplaza el texto - Uint16 deathCounter; // Contador para la animación de muerte del jugador - Uint8 menaceCurrent; // Nivel de amenaza actual - Uint8 menaceThreshold; // 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 timeStopped; // Indica si el tiempo está detenido - Uint16 timeStoppedCounter; // Temporizador para llevar la cuenta del tiempo detenido - Uint32 counter; // Contador para el juego - Uint32 scoreDataFile[TOTAL_SCORE_DATA]; // Datos del fichero de puntos - SDL_Rect skyColorsRect[4]; // Vector con las coordenadas de los 4 colores de cielo - Uint16 balloonsPopped; // Lleva la cuenta de los globos explotados - Uint8 lastEnemyDeploy; // Guarda cual ha sido la última formación desplegada para no repetir; - int enemyDeployCounter; // Cuando se lanza una formación, se le da un valor y no sale otra hasta que llegue a cero - float enemySpeed; // Velocidad a la que se mueven los enemigos - float defaultEnemySpeed; // Velocidad base de los enemigos, sin incrementar - Effect effect; // Variable para gestionar los efectos visuales - DeathShake deathShake; // Variable para gestionar el efecto de agitación intensa - DeathSequence deathSequence; // Variable para gestionar la secuencia de muerte - Helper helper; // Variable para gestionar las ayudas - bool powerBallEnabled; // Indica si hay una powerball ya activa - Uint8 powerBallCounter; // Contador de formaciones enemigas entre la aparicion de una PowerBall y otra - bool coffeeMachineEnabled; // Indica si hay una máquina de café en el terreno de juego - bool gameCompleted; // Indica si se ha completado la partida, llegando al final de la ultima pantalla - int gameCompletedCounter; // Contador para el tramo final, cuando se ha completado la partida y ya no aparecen más enemigos - Uint8 difficulty; // Dificultad del juego - float difficultyScoreMultiplier; // Multiplicador de puntos en función de la dificultad - Color difficultyColor; // Color asociado a la dificultad - Uint8 onePlayerControl; // Variable para almacenar el valor de las opciones - EnemyFormation enemyFormation[NUMBER_OF_ENEMY_FORMATIONS]; // Vector con todas las formaciones enemigas - EnemyPool enemyPool[10]; // Variable con los diferentes conjuntos de formaciones enemigas - Uint8 lastStageReached; // Contiene el numero de la última pantalla que se ha alcanzado - Demo demo; // Variable con todas las variables relacionadas con el modo demo - int totalPowerToCompleteGame; // La suma del poder necesario para completar todas las fases - int cloudsSpeed{0}; // Velocidad a la que se desplazan las nubes - int pauseCounter; // Contador para salir del menu de pausa y volver al juego - bool leavingPauseMenu; // Indica si esta saliendo del menu de pausa para volver al juego - bool pauseInitialized; // Indica si la pausa ha sido inicializada - bool gameOverInitialized; // Indica si el game over ha sido inicializado - int gameOverPostFade; // Opción a realizar cuando termina el fundido del game over + int num_players_; // Numero de jugadores + 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 + 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 + 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 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 + 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 + 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 + 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 + Color difficulty_color_; // Color asociado a la dificultad + 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 + 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 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 #ifdef PAUSE bool pause; #endif @@ -375,7 +377,7 @@ class Game { void renderBullets(); // Crea un objeto bala - void createBullet(int x, int y, Bullet::Kind kind, bool poweredUp, int owner); + void createBullet(int x, int y, Bullet::Kind kind, bool powered_up, int owner); // Vacia el vector de balas void freeBullets(); @@ -520,7 +522,7 @@ class Game { public: // Constructor - Game(int numPlayers, int currentStage, SDL_Renderer *renderer, bool demo, Section *section); + Game(int num_players, int current_stage, SDL_Renderer *renderer, bool demo, Section *section); // Destructor ~Game(); diff --git a/source/game/scenes/title.cpp b/source/game/scenes/title.cpp index 40ce9f0..47f8532 100644 --- a/source/game/scenes/title.cpp +++ b/source/game/scenes/title.cpp @@ -27,46 +27,46 @@ // Constructor Title::Title(SDL_Renderer *renderer, Section *section) { // Copia las direcciones de los punteros - this->renderer = renderer; - this->section = section; + this->renderer_ = renderer; + this->section_ = section; // Reserva memoria para los punteros - eventHandler = new SDL_Event(); - fade = new Fade(renderer); + event_handler_ = new SDL_Event(); + fade_ = new Fade(renderer); - Resource *R = Resource::get(); - dustTexture = R->getTexture("title_dust.png"); - coffeeTexture = R->getTexture("title_coffee.png"); - crisisTexture = R->getTexture("title_crisis.png"); - gradientTexture = R->getTexture("title_gradient.png"); + Resource *resource = Resource::get(); + dust_texture_ = resource->getTexture("title_dust.png"); + coffee_texture_ = resource->getTexture("title_coffee.png"); + crisis_texture_ = resource->getTexture("title_crisis.png"); + gradient_texture_ = resource->getTexture("title_gradient.png"); - coffeeBitmap = new SmartSprite(coffeeTexture, renderer); - crisisBitmap = new SmartSprite(crisisTexture, renderer); - dustBitmapL = new AnimatedSprite(dustTexture, renderer, "", &R->getAnimationLines("title_dust.ani")); - dustBitmapR = new AnimatedSprite(dustTexture, renderer, "", &R->getAnimationLines("title_dust.ani")); - gradient = new Sprite({0, 0, 256, 192}, gradientTexture, renderer); + coffee_bitmap_ = new SmartSprite(coffee_texture_, renderer); + crisis_bitmap_ = new SmartSprite(crisis_texture_, renderer); + dust_bitmap_left_ = new AnimatedSprite(dust_texture_, renderer, "", &resource->getAnimationLines("title_dust.ani")); + dust_bitmap_right_ = new AnimatedSprite(dust_texture_, renderer, "", &resource->getAnimationLines("title_dust.ani")); + gradient_ = new Sprite({0, 0, 256, 192}, gradient_texture_, renderer); - text1 = R->getText("smb2"); - text2 = R->getText("8bithud"); + text1_ = resource->getText("smb2"); + text2_ = resource->getText("8bithud"); #ifdef GAME_CONSOLE - menu.title = R->getMenu("title_gc"); - menu.options = R->getMenu("options_gc"); + menu_.title = R->getMenu("title_gc"); + menu_.options = R->getMenu("options_gc"); #else - menu.title = R->getMenu("title"); - menu.options = R->getMenu("options"); + menu_.title = resource->getMenu("title"); + menu_.options = resource->getMenu("options"); #endif - menu.playerSelect = R->getMenu("player_select"); + menu_.player_select = resource->getMenu("player_select"); #ifdef __EMSCRIPTEN__ // En la versión web no se puede cerrar el programa: ocultamos la opción QUIT del menú de título - menu.title->setVisible(3, false); - menu.title->setSelectable(3, false); + menu_.title->setVisible(3, false); + menu_.title->setSelectable(3, false); #endif // Sonidos y música (handles compartidos) - crashSound = R->getSound("title.wav"); - titleMusic = R->getMusic("title.ogg"); + crash_sound_ = resource->getSound("title.wav"); + title_music_ = resource->getMusic("title.ogg"); // Inicializa los valores init(); @@ -74,40 +74,40 @@ Title::Title(SDL_Renderer *renderer, Section *section) { // Destructor Title::~Title() { - delete eventHandler; - delete fade; + delete event_handler_; + delete fade_; // Las texturas, Text, Menu, sonido y música son propiedad de Resource — // no se liberan aquí. Solo los sprites que posee esta escena. - delete coffeeBitmap; - delete crisisBitmap; - delete dustBitmapL; - delete dustBitmapR; - delete gradient; + delete coffee_bitmap_; + delete crisis_bitmap_; + delete dust_bitmap_left_; + delete dust_bitmap_right_; + delete gradient_; - SDL_DestroyTexture(background); + SDL_DestroyTexture(background_); } // Inicializa los valores void Title::init() { // Inicializa variables - section->subsection = SUBSECTION_TITLE_1; - counter = TITLE_COUNTER; - backgroundCounter = 0; - backgroundMode = rand() % 2; - menuVisible = false; - menu.active = menu.title; - nextSection.name = SECTION_PROG_GAME; - postFade = 0; - ticks = 0; - ticksSpeed = 15; - fade->init(0x17, 0x17, 0x26); - demo = true; - vibrationStep = 0; - vibrationInitialized = false; - instructionsActive = false; - demoGameActive = false; - demoThenInstructions = false; + section_->subsection = SUBSECTION_TITLE_1; + counter_ = COUNTER; + background_counter_ = 0; + background_mode_ = rand() % 2; + menu_visible_ = false; + menu_.active = menu_.title; + next_section_.name = SECTION_PROG_GAME; + post_fade_ = 0; + ticks_ = 0; + ticks_speed_ = 15; + fade_->init(0x17, 0x17, 0x26); + demo_ = true; + vibration_step_ = 0; + vibration_initialized_ = false; + instructions_active_ = false; + demo_game_active_ = false; + demo_then_instructions_ = false; // Pone valores por defecto a las opciones de control Options::inputs.clear(); @@ -127,82 +127,82 @@ void Title::init() { checkInputDevices(); // Pone valores por defecto. El primer jugador el teclado. El segundo jugador el primer mando - deviceIndex.clear(); - deviceIndex.push_back(availableInputDevices.size() - 1); // El último dispositivo encontrado es el teclado - deviceIndex.push_back(0); // El primer mando encontrado. Si no ha encontrado ninguno es el teclado + 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 // Si ha encontrado un mando se lo asigna al segundo jugador if (Input::get()->gameControllerFound()) { - Options::inputs[1].id = availableInputDevices[deviceIndex[1]].id; - Options::inputs[1].name = availableInputDevices[deviceIndex[1]].name; - Options::inputs[1].deviceType = availableInputDevices[deviceIndex[1]].deviceType; + Options::inputs[1].id = available_input_devices_[device_index_[1]].id; + Options::inputs[1].name = available_input_devices_[device_index_[1]].name; + Options::inputs[1].deviceType = available_input_devices_[device_index_[1]].deviceType; } else { // Si no ha encontrado un mando, deshabilita la opción de jugar a 2 jugadores - menu.title->setSelectable(1, false); - menu.title->setGreyed(1, true); + menu_.title->setSelectable(1, false); + menu_.title->setGreyed(1, true); } // Inicializa el bitmap de Coffee - coffeeBitmap->init(); - coffeeBitmap->setPosX(45); - coffeeBitmap->setPosY(11 - 200); - coffeeBitmap->setWidth(167); - coffeeBitmap->setHeight(46); - coffeeBitmap->setVelX(0.0F); - coffeeBitmap->setVelY(2.5F); - coffeeBitmap->setAccelX(0.0F); - coffeeBitmap->setAccelY(0.1F); - coffeeBitmap->setSpriteClip(0, 0, 167, 46); - coffeeBitmap->setEnabled(true); - coffeeBitmap->setEnabledCounter(0); - coffeeBitmap->setDestX(45); - coffeeBitmap->setDestY(11); + coffee_bitmap_->init(); + coffee_bitmap_->setPosX(45); + coffee_bitmap_->setPosY(11 - 200); + coffee_bitmap_->setWidth(167); + coffee_bitmap_->setHeight(46); + coffee_bitmap_->setVelX(0.0F); + coffee_bitmap_->setVelY(2.5F); + coffee_bitmap_->setAccelX(0.0F); + coffee_bitmap_->setAccelY(0.1F); + coffee_bitmap_->setSpriteClip(0, 0, 167, 46); + coffee_bitmap_->setEnabled(true); + coffee_bitmap_->setEnabledCounter(0); + coffee_bitmap_->setDestX(45); + coffee_bitmap_->setDestY(11); // Inicializa el bitmap de Crisis - crisisBitmap->init(); - crisisBitmap->setPosX(60); - crisisBitmap->setPosY(57 + 200); - crisisBitmap->setWidth(137); - crisisBitmap->setHeight(46); - crisisBitmap->setVelX(0.0F); - crisisBitmap->setVelY(-2.5F); - crisisBitmap->setAccelX(0.0F); - crisisBitmap->setAccelY(-0.1F); - crisisBitmap->setSpriteClip(0, 0, 137, 46); - crisisBitmap->setEnabled(true); - crisisBitmap->setEnabledCounter(0); - crisisBitmap->setDestX(60); - crisisBitmap->setDestY(57); + crisis_bitmap_->init(); + crisis_bitmap_->setPosX(60); + crisis_bitmap_->setPosY(57 + 200); + crisis_bitmap_->setWidth(137); + crisis_bitmap_->setHeight(46); + crisis_bitmap_->setVelX(0.0F); + crisis_bitmap_->setVelY(-2.5F); + crisis_bitmap_->setAccelX(0.0F); + crisis_bitmap_->setAccelY(-0.1F); + crisis_bitmap_->setSpriteClip(0, 0, 137, 46); + crisis_bitmap_->setEnabled(true); + crisis_bitmap_->setEnabledCounter(0); + crisis_bitmap_->setDestX(60); + crisis_bitmap_->setDestY(57); // Inicializa el bitmap de DustRight - dustBitmapR->resetAnimation(); - dustBitmapR->setPosX(218); - dustBitmapR->setPosY(47); - dustBitmapR->setWidth(16); - dustBitmapR->setHeight(16); - dustBitmapR->setFlip(SDL_FLIP_HORIZONTAL); + dust_bitmap_right_->resetAnimation(); + dust_bitmap_right_->setPosX(218); + dust_bitmap_right_->setPosY(47); + dust_bitmap_right_->setWidth(16); + dust_bitmap_right_->setHeight(16); + dust_bitmap_right_->setFlip(SDL_FLIP_HORIZONTAL); // Inicializa el bitmap de DustLeft - dustBitmapL->resetAnimation(); - dustBitmapL->setPosX(33); - dustBitmapL->setPosY(47); - dustBitmapL->setWidth(16); - dustBitmapL->setHeight(16); + dust_bitmap_left_->resetAnimation(); + dust_bitmap_left_->setPosX(33); + dust_bitmap_left_->setPosY(47); + dust_bitmap_left_->setWidth(16); + dust_bitmap_left_->setHeight(16); // Inicializa el sprite con el degradado - gradient->setSpriteClip(0, 96, 256, 192); + gradient_->setSpriteClip(0, 96, 256, 192); // Crea el mosaico de fondo del titulo createTiledBackground(); // Coloca la ventana que recorre el mosaico de fondo de manera que coincida con el mosaico que hay pintado en el titulo al iniciar - backgroundWindow.x = 128; - backgroundWindow.y = 96; - backgroundWindow.w = GAMECANVAS_WIDTH; - backgroundWindow.h = GAMECANVAS_HEIGHT; + background_window_.x = 128; + background_window_.y = 96; + background_window_.w = GAMECANVAS_WIDTH; + background_window_.h = GAMECANVAS_HEIGHT; // Inicializa los valores del vector con los valores del seno for (int i = 0; i < 360; ++i) { - sin[i] = SDL_sinf((float)i * 3.14F / 180.0F); + sin_[i] = SDL_sinf((float)i * 3.14F / 180.0F); } // Actualiza los textos de los menus @@ -211,305 +211,307 @@ void Title::init() { // Actualiza las variables del objeto void Title::update() { - // Actualiza el audio Audio::update(); - - // Comprueba las entradas checkInput(); - // Calcula la lógica de los objetos - if (SDL_GetTicks() - ticks > ticksSpeed) { - // Actualiza el contador de ticks - ticks = SDL_GetTicks(); + if (SDL_GetTicks() - ticks_ <= ticks_speed_) { + return; + } + ticks_ = SDL_GetTicks(); - switch (section->subsection) { - // Sección 1 - Titulo desplazandose - case SUBSECTION_TITLE_1: { - // Actualiza los objetos - coffeeBitmap->update(); - crisisBitmap->update(); + switch (section_->subsection) { + case SUBSECTION_TITLE_1: updateTitle1(); break; + case SUBSECTION_TITLE_2: updateTitle2(); break; + case SUBSECTION_TITLE_3: updateTitle3(); break; + default: break; + } +} - // Si los objetos han llegado a su destino, cambiamos de Sección - if (coffeeBitmap->hasFinished() && crisisBitmap->hasFinished()) { - section->subsection = SUBSECTION_TITLE_2; +// Sección 1 - Titulo desplazandose +void Title::updateTitle1() { + coffee_bitmap_->update(); + crisis_bitmap_->update(); - // Pantallazo blanco: pintar sobre el gameCanvas y dejar - // que Screen::blit() presente por la ruta activa (GPU o - // SDL_Renderer). Un `SDL_RenderPresent(renderer)` directe - // crasheja quan el SDL3 GPU ha reclamat la ventana. - Screen::get()->start(); - SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF); - SDL_RenderClear(renderer); - Screen::get()->blit(); + // Si los objetos han llegado a su destino, cambiamos de Sección + if (coffee_bitmap_->hasFinished() && crisis_bitmap_->hasFinished()) { + section_->subsection = SUBSECTION_TITLE_2; - // Reproduce el efecto sonoro - Audio::get()->playSound(crashSound); - } - } break; + // Pantallazo blanco: pintar sobre el gameCanvas y dejar + // que Screen::blit() presente por la ruta activa (GPU o + // SDL_Renderer). Un `SDL_RenderPresent(renderer)` directe + // crasheja quan el SDL3 GPU ha reclamat la ventana. + Screen::get()->start(); + SDL_SetRenderDrawColor(renderer_, 0xFF, 0xFF, 0xFF, 0xFF); + SDL_RenderClear(renderer_); + Screen::get()->blit(); - // Sección 2 - Titulo vibrando - case SUBSECTION_TITLE_2: { - // Captura las posiciones base y reproduce el sonido la primera vez - if (!vibrationInitialized) { - vibrationCoffeeBaseX = coffeeBitmap->getPosX(); - vibrationCrisisBaseX = crisisBitmap->getPosX(); - vibrationInitialized = true; - } + Audio::get()->playSound(crash_sound_); + } +} - // Agita la pantalla - const int v[] = {-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 0}; +// Sección 2 - Titulo vibrando +void Title::updateTitle2() { + // Captura las posiciones base la primera vez + if (!vibration_initialized_) { + vibration_coffee_base_x_ = coffee_bitmap_->getPosX(); + vibration_crisis_base_x_ = crisis_bitmap_->getPosX(); + vibration_initialized_ = true; + } - coffeeBitmap->setPosX(vibrationCoffeeBaseX + v[vibrationStep / 3]); - crisisBitmap->setPosX(vibrationCrisisBaseX + v[vibrationStep / 3]); - dustBitmapR->update(); - dustBitmapL->update(); + const int V[] = {-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 0}; + coffee_bitmap_->setPosX(vibration_coffee_base_x_ + V[vibration_step_ / 3]); + crisis_bitmap_->setPosX(vibration_crisis_base_x_ + V[vibration_step_ / 3]); + dust_bitmap_right_->update(); + dust_bitmap_left_->update(); - vibrationStep++; + vibration_step_++; - if (vibrationStep >= 33) { - section->subsection = SUBSECTION_TITLE_3; - vibrationStep = 0; - vibrationInitialized = false; - } - } break; + if (vibration_step_ >= 33) { + section_->subsection = SUBSECTION_TITLE_3; + vibration_step_ = 0; + vibration_initialized_ = false; + } +} - // Sección 3 - La pantalla de titulo con el menú y la música - case SUBSECTION_TITLE_3: { - if (counter > 0) { // Reproduce la música - if (Audio::getRealMusicState() == Audio::MusicState::STOPPED) { - Audio::get()->playMusic(titleMusic); - } +// Sección 3 - La pantalla de titulo con el menú y la música +void Title::updateTitle3() { + if (counter_ > 0) { + if (Audio::getRealMusicState() == Audio::MusicState::STOPPED) { + Audio::get()->playMusic(title_music_); + } - dustBitmapR->update(); - dustBitmapL->update(); + dust_bitmap_right_->update(); + dust_bitmap_left_->update(); + fade_->update(); - // Actualiza la lógica del titulo - fade->update(); + if (fade_->hasEnded()) { + handlePostFadeAction(); + } - if (fade->hasEnded()) { - switch (postFade) { - case 0: // 1 PLAYER - section->name = SECTION_PROG_GAME; - section->subsection = SUBSECTION_GAME_PLAY_1P; - Audio::get()->stopMusic(); - break; + updateBG(); - case 1: // 2 PLAYERS - section->name = SECTION_PROG_GAME; - section->subsection = SUBSECTION_GAME_PLAY_2P; - Audio::get()->stopMusic(); - break; + if (menu_visible_ && !fade_->isEnabled()) { + menu_.active->update(); + } - case 2: // QUIT -#ifndef __EMSCRIPTEN__ - section->name = SECTION_PROG_QUIT; - Audio::get()->stopMusic(); -#endif - break; + if (menu_.active->getName() == "TITLE") { + handleTitleMenuSelection(); + } + if (menu_.active->getName() == "PLAYER_SELECT") { + handlePlayerSelectMenuSelection(); + } + if (menu_.active->getName() == "OPTIONS") { + handleOptionsMenuSelection(); + } - case 3: // TIME OUT - counter = TITLE_COUNTER; - menu.active->reset(); - if (demo) { - demoThenInstructions = true; - runDemoGame(); - } else { - section->name = SECTION_PROG_LOGO; - } - break; + if (menu_.active->getName() == "TITLE") { + counter_--; + } + } else if (counter_ == 0) { + if (demo_) { + demo_then_instructions_ = true; + runDemoGame(); + } else { + section_->name = SECTION_PROG_LOGO; + } + } - default: - break; - } - } - - // Actualiza el tileado de fondo - updateBG(); - - // Comprueba las entradas para el menu - if (menuVisible && !fade->isEnabled()) { - menu.active->update(); - } - - // Comprueba si se ha seleccionado algún item del menú de titulo - if (menu.active->getName() == "TITLE") { - switch (menu.active->getItemSelected()) { - case 0: // 1 PLAYER -> Cambia al manu de selección de jugador - menu.active = menu.playerSelect; - break; - - case 1: // 2 PLAYERS - postFade = 1; - fade->activateFade(); - break; - - case 2: // OPTIONS - menu.active = menu.options; - prevVideo = Options::video; - prevWindow = Options::window; - prevSettings = Options::settings; - prevInputs = Options::inputs; - break; - - case 3: // QUIT - postFade = 2; - fade->activateFade(); - break; - - default: - break; - } - } - - // Comprueba si se ha seleccionado algún item del menú de selección de jugador - if (menu.active->getName() == "PLAYER_SELECT") { - switch (menu.active->getItemSelected()) { - case 0: - // Este item no se puede seleccionar y actua de titulo - break; - - case 1: // BAL1 - postFade = 0; - Options::settings.player_selected = 0; - fade->activateFade(); - break; - - case 2: // AROUNDER - postFade = 0; - Options::settings.player_selected = 1; - fade->activateFade(); - break; - - case 3: // BACK - menu.active = menu.title; - menu.playerSelect->reset(); - break; - - default: - break; - } - } - - // Comprueba si se ha seleccionado algún item de opciones - if (menu.active->getName() == "OPTIONS") { - switch (menu.active->getItemSelected()) { - case 0: // Difficulty - if (Options::settings.difficulty == DIFFICULTY_EASY) { - Options::settings.difficulty = DIFFICULTY_NORMAL; - } else if (Options::settings.difficulty == DIFFICULTY_NORMAL) { - Options::settings.difficulty = DIFFICULTY_HARD; - } else { - Options::settings.difficulty = DIFFICULTY_EASY; - } - updateMenuLabels(); - break; - - case 1: // PLAYER 1 CONTROLS - updatePlayerInputs(0); - updateMenuLabels(); - break; - - case 3: // PLAYER 2 CONTROLS - updatePlayerInputs(1); - updateMenuLabels(); - break; - - case 5: // Language - Options::settings.language++; - if (Options::settings.language == 3) { - Options::settings.language = 0; - } - updateMenuLabels(); - break; - - case 6: // Display mode - switchFullScreenModeVar(); - if (Options::video.fullscreen) { - menu.options->setSelectable(8, false); - menu.options->setGreyed(8, true); - } else { - menu.options->setSelectable(8, true); - menu.options->setGreyed(8, false); - } - updateMenuLabels(); - break; - - case 8: // Windows size - Options::window.zoom++; - if (Options::window.zoom > Options::window.max_zoom) { - Options::window.zoom = 1; - } - updateMenuLabels(); - break; - - case 9: // Scale mode - Options::video.scale_mode = (Options::video.scale_mode == SDL_SCALEMODE_NEAREST) - ? SDL_SCALEMODE_LINEAR - : SDL_SCALEMODE_NEAREST; - Texture::setGlobalScaleMode(Options::video.scale_mode); - reLoadTextures(); - updateMenuLabels(); - break; - - case 10: // VSYNC - Options::video.vsync = !Options::video.vsync; - updateMenuLabels(); - break; - - case 11: // HOW TO PLAY - runInstructions(Instructions::Mode::MANUAL); - break; - - case 12: // ACCEPT - applyOptions(); - menu.active->reset(); - menu.active = menu.title; - break; - - case 13: // CANCEL - Options::video = prevVideo; - Options::window = prevWindow; - Options::settings = prevSettings; - Options::inputs = prevInputs; - updateMenuLabels(); - menu.active->reset(); - menu.active = menu.title; - break; - - default: - break; - } - } - - if (menu.active->getName() == "TITLE") { - counter--; - } - } else if (counter == 0) { - if (demo) { - demoThenInstructions = true; - runDemoGame(); - } else { - section->name = SECTION_PROG_LOGO; - } - } - - // Sección Instrucciones - if (section->subsection == SUBSECTION_TITLE_INSTRUCTIONS) { - runInstructions(Instructions::Mode::AUTO); - } - } + if (section_->subsection == SUBSECTION_TITLE_INSTRUCTIONS) { + runInstructions(Instructions::Mode::AUTO); + } +} +// Acción tras finalizar el fundido del título +void Title::handlePostFadeAction() { + switch (post_fade_) { + case 0: // 1 PLAYER + section_->name = SECTION_PROG_GAME; + section_->subsection = SUBSECTION_GAME_PLAY_1P; + Audio::get()->stopMusic(); break; - default: - break; - } + case 1: // 2 PLAYERS + section_->name = SECTION_PROG_GAME; + section_->subsection = SUBSECTION_GAME_PLAY_2P; + Audio::get()->stopMusic(); + break; + + case 2: // QUIT +#ifndef __EMSCRIPTEN__ + section_->name = SECTION_PROG_QUIT; + Audio::get()->stopMusic(); +#endif + break; + + case 3: // TIME OUT + counter_ = COUNTER; + menu_.active->reset(); + if (demo_) { + demo_then_instructions_ = true; + runDemoGame(); + } else { + section_->name = SECTION_PROG_LOGO; + } + break; + + default: + break; + } +} + +// Procesa selección del menú TITLE +void Title::handleTitleMenuSelection() { + switch (menu_.active->getItemSelected()) { + case 0: // 1 PLAYER -> Cambia al manu de selección de jugador + menu_.active = menu_.player_select; + break; + + case 1: // 2 PLAYERS + post_fade_ = 1; + fade_->activateFade(); + break; + + case 2: // OPTIONS + menu_.active = menu_.options; + prev_video_ = Options::video; + prev_window_ = Options::window; + prev_settings_ = Options::settings; + prev_inputs_ = Options::inputs; + break; + + case 3: // QUIT + post_fade_ = 2; + fade_->activateFade(); + break; + + default: + break; + } +} + +// Procesa selección del menú PLAYER_SELECT +void Title::handlePlayerSelectMenuSelection() { + switch (menu_.active->getItemSelected()) { + case 0: + // Este item no se puede seleccionar y actua de titulo + break; + + case 1: // BAL1 + post_fade_ = 0; + Options::settings.player_selected = 0; + fade_->activateFade(); + break; + + case 2: // AROUNDER + post_fade_ = 0; + Options::settings.player_selected = 1; + fade_->activateFade(); + break; + + case 3: // BACK + menu_.active = menu_.title; + menu_.player_select->reset(); + break; + + default: + break; + } +} + +// Procesa selección del menú OPTIONS +void Title::handleOptionsMenuSelection() { + switch (menu_.active->getItemSelected()) { + case 0: // Difficulty + if (Options::settings.difficulty == DIFFICULTY_EASY) { + Options::settings.difficulty = DIFFICULTY_NORMAL; + } else if (Options::settings.difficulty == DIFFICULTY_NORMAL) { + Options::settings.difficulty = DIFFICULTY_HARD; + } else { + Options::settings.difficulty = DIFFICULTY_EASY; + } + updateMenuLabels(); + break; + + case 1: // PLAYER 1 CONTROLS + updatePlayerInputs(0); + updateMenuLabels(); + break; + + case 3: // PLAYER 2 CONTROLS + updatePlayerInputs(1); + updateMenuLabels(); + break; + + case 5: // Language + Options::settings.language++; + if (Options::settings.language == 3) { + Options::settings.language = 0; + } + updateMenuLabels(); + break; + + case 6: // Display mode + switchFullScreenModeVar(); + if (Options::video.fullscreen) { + menu_.options->setSelectable(8, false); + menu_.options->setGreyed(8, true); + } else { + menu_.options->setSelectable(8, true); + menu_.options->setGreyed(8, false); + } + updateMenuLabels(); + break; + + case 8: // Windows size + Options::window.zoom++; + if (Options::window.zoom > Options::window.max_zoom) { + Options::window.zoom = 1; + } + updateMenuLabels(); + break; + + case 9: // Scale mode + Options::video.scale_mode = (Options::video.scale_mode == SDL_SCALEMODE_NEAREST) + ? SDL_SCALEMODE_LINEAR + : SDL_SCALEMODE_NEAREST; + Texture::setGlobalScaleMode(Options::video.scale_mode); + reLoadTextures(); + updateMenuLabels(); + break; + + case 10: // VSYNC + Options::video.vsync = !Options::video.vsync; + updateMenuLabels(); + break; + + case 11: // HOW TO PLAY + runInstructions(Instructions::Mode::MANUAL); + break; + + case 12: // ACCEPT + applyOptions(); + menu_.active->reset(); + menu_.active = menu_.title; + break; + + case 13: // CANCEL + Options::video = prev_video_; + Options::window = prev_window_; + Options::settings = prev_settings_; + Options::inputs = prev_inputs_; + updateMenuLabels(); + menu_.active->reset(); + menu_.active = menu_.title; + break; + + default: + break; } } // Dibuja el objeto en pantalla void Title::render() { - switch (section->subsection) { + switch (section_->subsection) { // Sección 1 - Titulo desplazandose case SUBSECTION_TITLE_1: { // Prepara para empezar a dibujar en la textura de juego @@ -520,16 +522,16 @@ void Title::render() { // Dibuja el tileado de fondo { - SDL_FRect fSrc = {(float)backgroundWindow.x, (float)backgroundWindow.y, (float)backgroundWindow.w, (float)backgroundWindow.h}; - SDL_RenderTexture(renderer, background, &fSrc, nullptr); + SDL_FRect f_src = {(float)background_window_.x, (float)background_window_.y, (float)background_window_.w, (float)background_window_.h}; + SDL_RenderTexture(renderer_, background_, &f_src, nullptr); }; // Dibuja el degradado - gradient->render(); + gradient_->render(); // Dibuja los objetos - coffeeBitmap->render(); - crisisBitmap->render(); + coffee_bitmap_->render(); + crisis_bitmap_->render(); // Vuelca el contenido del renderizador en pantalla Screen::get()->blit(); @@ -545,19 +547,19 @@ void Title::render() { // Dibuja el tileado de fondo { - SDL_FRect fSrc = {(float)backgroundWindow.x, (float)backgroundWindow.y, (float)backgroundWindow.w, (float)backgroundWindow.h}; - SDL_RenderTexture(renderer, background, &fSrc, nullptr); + SDL_FRect f_src = {(float)background_window_.x, (float)background_window_.y, (float)background_window_.w, (float)background_window_.h}; + SDL_RenderTexture(renderer_, background_, &f_src, nullptr); }; // Dibuja el degradado - gradient->render(); + gradient_->render(); // Dibuja los objetos (posiciones ya actualizadas por update) - coffeeBitmap->render(); - crisisBitmap->render(); + coffee_bitmap_->render(); + crisis_bitmap_->render(); - dustBitmapR->render(); - dustBitmapL->render(); + dust_bitmap_right_->render(); + dust_bitmap_left_->render(); // Vuelca el contenido del renderizador en pantalla Screen::get()->blit(); @@ -572,37 +574,37 @@ void Title::render() { // Dibuja el tileado de fondo { - SDL_FRect fSrc = {(float)backgroundWindow.x, (float)backgroundWindow.y, (float)backgroundWindow.w, (float)backgroundWindow.h}; - SDL_RenderTexture(renderer, background, &fSrc, nullptr); + SDL_FRect f_src = {(float)background_window_.x, (float)background_window_.y, (float)background_window_.w, (float)background_window_.h}; + SDL_RenderTexture(renderer_, background_, &f_src, nullptr); }; // Dibuja el degradado - gradient->render(); + gradient_->render(); // Dibuja los objetos - if (menu.active->getName() != "OPTIONS") { + if (menu_.active->getName() != "OPTIONS") { // Bitmaps con el logo/titulo del juego - coffeeBitmap->render(); - crisisBitmap->render(); + coffee_bitmap_->render(); + crisis_bitmap_->render(); // Texto con el copyright y versión - text2->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, GAMECANVAS_HEIGHT - (BLOCK * 2), TEXT_COPYRIGHT, 1, noColor, 1, shdwTxtColor); + text2_->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, GAMECANVAS_HEIGHT - (BLOCK * 2), COPYRIGHT, 1, noColor, 1, shdwTxtColor); } - if (menuVisible) { - menu.active->render(); + if (menu_visible_) { + menu_.active->render(); } - dustBitmapR->render(); - dustBitmapL->render(); + dust_bitmap_right_->render(); + dust_bitmap_left_->render(); // PRESS ANY KEY! - if ((counter % 50 > 14) && (!menuVisible)) { - text1->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, PLAY_AREA_THIRD_QUARTER_Y + BLOCK, Lang::get()->getText(23), 1, noColor, 1, shdwTxtColor); + if ((counter_ % 50 > 14) && (!menu_visible_)) { + text1_->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, PLAY_AREA_THIRD_QUARTER_Y + BLOCK, Lang::get()->getText(23), 1, noColor, 1, shdwTxtColor); } // Fade - fade->render(); + fade_->render(); // Vuelca el contenido del renderizador en pantalla Screen::get()->blit(); @@ -617,7 +619,7 @@ void Title::render() { void Title::checkInput() { #ifndef __EMSCRIPTEN__ if (Input::get()->checkInput(input_exit, REPEAT_FALSE)) { - section->name = SECTION_PROG_QUIT; + section_->name = SECTION_PROG_QUIT; return; } #endif @@ -626,13 +628,13 @@ void Title::checkInput() { // Actualiza el tileado de fondo void Title::updateBG() { - if (backgroundMode == 0) { // El tileado de fondo se desplaza en diagonal - ++backgroundWindow.x %= 64; - ++backgroundWindow.y %= 64; + if (background_mode_ == 0) { // El tileado de fondo se desplaza en diagonal + ++background_window_.x %= 64; + ++background_window_.y %= 64; } else { // El tileado de fondo se desplaza en circulo - ++backgroundCounter %= 360; - backgroundWindow.x = 128 + (int(sin[(backgroundCounter + 270) % 360] * 128)); - backgroundWindow.y = 96 + (int(sin[(360 - backgroundCounter) % 360] * 96)); + ++background_counter_ %= 360; + background_window_.x = 128 + (int(sin_[(background_counter_ + 270) % 360] * 128)); + background_window_.y = 96 + (int(sin_[(360 - background_counter_) % 360] * 96)); } } @@ -647,73 +649,73 @@ void Title::updateMenuLabels() const { // DIFFICULTY switch (Options::settings.difficulty) { case DIFFICULTY_EASY: - menu.options->setItemCaption(i, Lang::get()->getText(59) + ": " + Lang::get()->getText(66)); // EASY + menu_.options->setItemCaption(i, Lang::get()->getText(59) + ": " + Lang::get()->getText(66)); // EASY break; case DIFFICULTY_NORMAL: - menu.options->setItemCaption(i, Lang::get()->getText(59) + ": " + Lang::get()->getText(67)); // NORMAL + menu_.options->setItemCaption(i, Lang::get()->getText(59) + ": " + Lang::get()->getText(67)); // NORMAL break; case DIFFICULTY_HARD: - menu.options->setItemCaption(i, Lang::get()->getText(59) + ": " + Lang::get()->getText(68)); // HARD + menu_.options->setItemCaption(i, Lang::get()->getText(59) + ": " + Lang::get()->getText(68)); // HARD break; default: - menu.options->setItemCaption(i, Lang::get()->getText(59) + ": " + Lang::get()->getText(67)); // NORMAL + menu_.options->setItemCaption(i, Lang::get()->getText(59) + ": " + Lang::get()->getText(67)); // NORMAL break; } i++; // PLAYER 1 CONTROLS - menu.options->setItemCaption(i, Lang::get()->getText(62)); + menu_.options->setItemCaption(i, Lang::get()->getText(62)); i++; // PLAYER 1 CONTROLS - OPTIONS switch (Options::inputs[0].deviceType) { case INPUT_USE_KEYBOARD: - menu.options->setItemCaption(i, Lang::get()->getText(69)); // KEYBOARD - menu.options->setGreyed(i, false); + menu_.options->setItemCaption(i, Lang::get()->getText(69)); // KEYBOARD + menu_.options->setGreyed(i, false); break; case INPUT_USE_GAMECONTROLLER: - menu.options->setItemCaption(i, Lang::get()->getText(70)); // GAME CONTROLLER + menu_.options->setItemCaption(i, Lang::get()->getText(70)); // GAME CONTROLLER if (!Input::get()->gameControllerFound()) { - menu.options->setGreyed(i, true); + menu_.options->setGreyed(i, true); } else { - menu.options->setGreyed(i, false); - menu.options->setItemCaption(i, Options::inputs[0].name); + menu_.options->setGreyed(i, false); + menu_.options->setItemCaption(i, Options::inputs[0].name); } break; default: - menu.options->setItemCaption(i, Lang::get()->getText(69)); // KEYBOARD + menu_.options->setItemCaption(i, Lang::get()->getText(69)); // KEYBOARD break; } i++; // PLAYER 2 CONTROLS - menu.options->setItemCaption(i, Lang::get()->getText(63)); + menu_.options->setItemCaption(i, Lang::get()->getText(63)); i++; // PLAYER 2 CONTROLS - OPTIONS switch (Options::inputs[1].deviceType) { case INPUT_USE_KEYBOARD: - menu.options->setItemCaption(i, Lang::get()->getText(69)); // KEYBOARD - menu.options->setGreyed(i, false); + menu_.options->setItemCaption(i, Lang::get()->getText(69)); // KEYBOARD + menu_.options->setGreyed(i, false); break; case INPUT_USE_GAMECONTROLLER: - menu.options->setItemCaption(i, Lang::get()->getText(70)); // GAME CONTROLLER + menu_.options->setItemCaption(i, Lang::get()->getText(70)); // GAME CONTROLLER if (!Input::get()->gameControllerFound()) { - menu.options->setGreyed(i, true); + menu_.options->setGreyed(i, true); } else { - menu.options->setGreyed(i, false); - menu.options->setItemCaption(i, Options::inputs[1].name); + menu_.options->setGreyed(i, false); + menu_.options->setItemCaption(i, Options::inputs[1].name); } break; default: - menu.options->setItemCaption(i, Lang::get()->getText(69)); // KEYBOARD + menu_.options->setItemCaption(i, Lang::get()->getText(69)); // KEYBOARD break; } @@ -721,100 +723,100 @@ void Title::updateMenuLabels() const { // LANGUAGE switch (Options::settings.language) { case es_ES: - menu.options->setItemCaption(i, Lang::get()->getText(8) + ": " + Lang::get()->getText(24)); // SPANISH + menu_.options->setItemCaption(i, Lang::get()->getText(8) + ": " + Lang::get()->getText(24)); // SPANISH break; case ba_BA: - menu.options->setItemCaption(i, Lang::get()->getText(8) + ": " + Lang::get()->getText(25)); // VALENCIAN + menu_.options->setItemCaption(i, Lang::get()->getText(8) + ": " + Lang::get()->getText(25)); // VALENCIAN break; case en_UK: default: // ENGLISH (i fallback per a llengües no reconegudes) - menu.options->setItemCaption(i, Lang::get()->getText(8) + ": " + Lang::get()->getText(26)); + menu_.options->setItemCaption(i, Lang::get()->getText(8) + ": " + Lang::get()->getText(26)); break; } i++; // DISPLAY MODE - menu.options->setItemCaption(i, Lang::get()->getText(58)); + menu_.options->setItemCaption(i, Lang::get()->getText(58)); i++; // DISPLAY MODE - OPTIONS - menu.options->setItemCaption(i, Options::video.fullscreen ? Lang::get()->getText(5) : Lang::get()->getText(4)); + menu_.options->setItemCaption(i, Options::video.fullscreen ? Lang::get()->getText(5) : Lang::get()->getText(4)); i++; // WINDOW SIZE - menu.options->setItemCaption(i, Lang::get()->getText(7) + " x" + std::to_string(Options::window.zoom)); // WINDOW SIZE + menu_.options->setItemCaption(i, Lang::get()->getText(7) + " x" + std::to_string(Options::window.zoom)); // WINDOW SIZE i++; // SCALE MODE if (Options::video.scale_mode == SDL_SCALEMODE_LINEAR) { - menu.options->setItemCaption(i, Lang::get()->getText(60) + ": " + Lang::get()->getText(71)); // BILINEAL + menu_.options->setItemCaption(i, Lang::get()->getText(60) + ": " + Lang::get()->getText(71)); // BILINEAL } else { - menu.options->setItemCaption(i, Lang::get()->getText(60) + ": " + Lang::get()->getText(72)); // LINEAL + menu_.options->setItemCaption(i, Lang::get()->getText(60) + ": " + Lang::get()->getText(72)); // LINEAL } i++; // VSYNC if (Options::video.vsync) { - menu.options->setItemCaption(i, Lang::get()->getText(61) + ": " + Lang::get()->getText(73)); // ON + menu_.options->setItemCaption(i, Lang::get()->getText(61) + ": " + Lang::get()->getText(73)); // ON } else { - menu.options->setItemCaption(i, Lang::get()->getText(61) + ": " + Lang::get()->getText(74)); // OFF + menu_.options->setItemCaption(i, Lang::get()->getText(61) + ": " + Lang::get()->getText(74)); // OFF } i++; // HOW TO PLAY - menu.options->setItemCaption(i, Lang::get()->getText(2)); + menu_.options->setItemCaption(i, Lang::get()->getText(2)); i++; // ACCEPT - menu.options->setItemCaption(i, Lang::get()->getText(9)); // ACCEPT + menu_.options->setItemCaption(i, Lang::get()->getText(9)); // ACCEPT i++; // CANCEL - menu.options->setItemCaption(i, Lang::get()->getText(10)); // CANCEL + menu_.options->setItemCaption(i, Lang::get()->getText(10)); // CANCEL // Recoloca el menu de opciones - menu.options->centerMenuOnX(GAMECANVAS_CENTER_X); - menu.options->centerMenuOnY(GAMECANVAS_CENTER_Y); - menu.options->centerMenuElementsOnX(); + menu_.options->centerMenuOnX(GAMECANVAS_CENTER_X); + menu_.options->centerMenuOnY(GAMECANVAS_CENTER_Y); + menu_.options->centerMenuElementsOnX(); // Establece las etiquetas del menu de titulo #ifdef GAME_CONSOLE - menu.title->setItemCaption(0, Lang::get()->getText(0)); // PLAY + menu_.title->setItemCaption(0, Lang::get()->getText(0)); // PLAY #else - menu.title->setItemCaption(0, Lang::get()->getText(51)); // 1 PLAYER + menu_.title->setItemCaption(0, Lang::get()->getText(51)); // 1 PLAYER #endif - menu.title->setItemCaption(1, Lang::get()->getText(52)); // 2 PLAYERS - menu.title->setItemCaption(2, Lang::get()->getText(1)); // OPTIONS - menu.title->setItemCaption(3, Lang::get()->getText(3)); // QUIT + menu_.title->setItemCaption(1, Lang::get()->getText(52)); // 2 PLAYERS + menu_.title->setItemCaption(2, Lang::get()->getText(1)); // OPTIONS + menu_.title->setItemCaption(3, Lang::get()->getText(3)); // QUIT #ifdef __EMSCRIPTEN__ - menu.title->setVisible(3, false); - menu.title->setSelectable(3, false); + menu_.title->setVisible(3, false); + menu_.title->setSelectable(3, false); #endif // Recoloca el menu de titulo - menu.title->centerMenuOnX(GAMECANVAS_CENTER_X); - menu.title->centerMenuElementsOnX(); + menu_.title->centerMenuOnX(GAMECANVAS_CENTER_X); + menu_.title->centerMenuElementsOnX(); // Establece las etiquetas del menu de seleccion de jugador - menu.playerSelect->setItemCaption(0, Lang::get()->getText(39)); // SELECT PLAYER - menu.playerSelect->setItemCaption(3, Lang::get()->getText(40)); // BACK + menu_.player_select->setItemCaption(0, Lang::get()->getText(39)); // SELECT PLAYER + menu_.player_select->setItemCaption(3, Lang::get()->getText(40)); // BACK // Recoloca el menu de selección de jugador - menu.playerSelect->centerMenuOnX(GAMECANVAS_CENTER_X); - menu.playerSelect->centerMenuElementsOnX(); + menu_.player_select->centerMenuOnX(GAMECANVAS_CENTER_X); + menu_.player_select->centerMenuElementsOnX(); #ifdef GAME_CONSOLE - menu.options->setGreyed(1, true); - menu.options->setSelectable(1, false); - menu.options->setGreyed(2, true); - menu.options->setSelectable(2, false); - menu.options->setGreyed(3, true); - menu.options->setSelectable(3, false); - menu.options->setGreyed(4, true); - menu.options->setSelectable(4, false); + menu_.options->setGreyed(1, true); + menu_.options->setSelectable(1, false); + menu_.options->setGreyed(2, true); + menu_.options->setSelectable(2, false); + menu_.options->setGreyed(3, true); + menu_.options->setSelectable(3, false); + menu_.options->setGreyed(4, true); + menu_.options->setSelectable(4, false); #endif } @@ -833,58 +835,58 @@ void Title::applyOptions() { // Ejecuta un frame void Title::iterate() { // Si las instrucciones están activas, delega el frame - if (instructionsActive) { - instructions->update(); - instructions->render(); + if (instructions_active_) { + instructions_->update(); + instructions_->render(); - if (instructions->hasFinished()) { - bool wasQuit = instructions->isQuitRequested(); - delete instructions; - instructions = nullptr; - instructionsActive = false; + if (instructions_->hasFinished()) { + bool was_quit = instructions_->isQuitRequested(); + delete instructions_; + instructions_ = nullptr; + instructions_active_ = false; - if (wasQuit) { - section->name = SECTION_PROG_QUIT; - } else if (instructionsMode == Instructions::Mode::AUTO) { - section->name = SECTION_PROG_TITLE; + if (was_quit) { + section_->name = SECTION_PROG_QUIT; + } else if (instructions_mode_ == Instructions::Mode::AUTO) { + section_->name = SECTION_PROG_TITLE; init(); - demo = true; + demo_ = true; } else { - section->name = SECTION_PROG_TITLE; - section->subsection = SUBSECTION_TITLE_3; + section_->name = SECTION_PROG_TITLE; + section_->subsection = SUBSECTION_TITLE_3; } } return; } // Si el juego demo está activo, delega el frame - if (demoGameActive) { + if (demo_game_active_) { // El demo Game necesita section->name == SECTION_PROG_GAME para funcionar - section->name = SECTION_PROG_GAME; - demoGame->iterate(); + section_->name = SECTION_PROG_GAME; + demo_game_->iterate(); - if (demoGame->hasFinished()) { + if (demo_game_->hasFinished()) { // cppcheck-suppress knownConditionTrueFalse - const bool wasQuit = (section->name == SECTION_PROG_QUIT); - delete demoGame; - demoGame = nullptr; - demoGameActive = false; + const bool WAS_QUIT = (section_->name == SECTION_PROG_QUIT); + delete demo_game_; + demo_game_ = nullptr; + demo_game_active_ = false; // cppcheck-suppress knownConditionTrueFalse - if (wasQuit) { - section->name = SECTION_PROG_QUIT; - } else if (demoThenInstructions) { - section->name = SECTION_PROG_TITLE; - section->subsection = SUBSECTION_TITLE_3; - demoThenInstructions = false; + if (WAS_QUIT) { + section_->name = SECTION_PROG_QUIT; + } else if (demo_then_instructions_) { + section_->name = SECTION_PROG_TITLE; + section_->subsection = SUBSECTION_TITLE_3; + demo_then_instructions_ = false; runInstructions(Instructions::Mode::AUTO); } else { - section->name = SECTION_PROG_TITLE; - section->subsection = SUBSECTION_TITLE_1; + section_->name = SECTION_PROG_TITLE; + section_->subsection = SUBSECTION_TITLE_1; } } else { // Restaura section para que Director no transicione fuera de Title - section->name = SECTION_PROG_TITLE; + section_->name = SECTION_PROG_TITLE; } return; } @@ -897,13 +899,13 @@ void Title::iterate() { // Procesa un evento individual void Title::handleEvent(const SDL_Event *event) { // Si hay un sub-estado activo, delega el evento - if (instructionsActive && (instructions != nullptr)) { + if (instructions_active_ && (instructions_ != nullptr)) { // SDL_EVENT_QUIT ya lo maneja Director return; } - if (demoGameActive && (demoGame != nullptr)) { - demoGame->handleEvent(event); + if (demo_game_active_ && (demo_game_ != nullptr)) { + demo_game_->handleEvent(event); return; } @@ -913,47 +915,47 @@ void Title::handleEvent(const SDL_Event *event) { reLoadTextures(); } - if (section->subsection == SUBSECTION_TITLE_3) { + if (section_->subsection == SUBSECTION_TITLE_3) { if ((event->type == SDL_EVENT_KEY_UP) || (event->type == SDL_EVENT_JOYSTICK_BUTTON_UP)) { - menuVisible = true; - counter = TITLE_COUNTER; + menu_visible_ = true; + counter_ = COUNTER; } } } // Bucle para el titulo del juego (compatibilidad) void Title::run() { - while (section->name == SECTION_PROG_TITLE || instructionsActive || demoGameActive) { + while (section_->name == SECTION_PROG_TITLE || instructions_active_ || demo_game_active_) { iterate(); } } // Inicia la parte donde se muestran las instrucciones void Title::runInstructions(Instructions::Mode mode) { - instructions = new Instructions(renderer, section); - instructions->start(mode); - instructionsActive = true; - instructionsMode = mode; + instructions_ = new Instructions(renderer_, section_); + instructions_->start(mode); + instructions_active_ = true; + instructions_mode_ = mode; } // Inicia el juego en modo demo void Title::runDemoGame() { // Temporalmente ponemos section para que el constructor de Game funcione - section->name = SECTION_PROG_GAME; - section->subsection = SUBSECTION_GAME_PLAY_1P; - demoGame = new Game(1, 0, renderer, true, section); - demoGameActive = true; + section_->name = SECTION_PROG_GAME; + section_->subsection = SUBSECTION_GAME_PLAY_1P; + demo_game_ = new Game(1, 0, renderer_, true, section_); + demo_game_active_ = true; // Restauramos section para que Director no transicione fuera de Title - section->name = SECTION_PROG_TITLE; + section_->name = SECTION_PROG_TITLE; } // Modifica las opciones para los controles de los jugadores -auto Title::updatePlayerInputs(int numPlayer) -> bool { - const int numDevices = availableInputDevices.size(); +auto Title::updatePlayerInputs(int num_player) -> bool { + const int NUM_DEVICES = available_input_devices_.size(); if (!Input::get()->gameControllerFound()) { // Si no hay mandos se deja todo de manera prefijada - deviceIndex[0] = 0; - deviceIndex[1] = 0; + device_index_[0] = 0; + device_index_[1] = 0; Options::inputs[0].id = -1; Options::inputs[0].name = "KEYBOARD"; @@ -966,32 +968,32 @@ auto Title::updatePlayerInputs(int numPlayer) -> bool { return true; } // Si hay mas de un dispositivo, se recorre el vector if (Options::settings.console) { - std::cout << "numplayer:" << numPlayer << '\n'; - std::cout << "deviceindex:" << deviceIndex[numPlayer] << '\n'; + std::cout << "numplayer:" << num_player << '\n'; + std::cout << "deviceindex:" << device_index_[num_player] << '\n'; } // Incrementa el indice - if (deviceIndex[numPlayer] < numDevices - 1) { - deviceIndex[numPlayer]++; + if (device_index_[num_player] < NUM_DEVICES - 1) { + device_index_[num_player]++; } else { - deviceIndex[numPlayer] = 0; + device_index_[num_player] = 0; } if (Options::settings.console) { - std::cout << "deviceindex:" << deviceIndex[numPlayer] << '\n'; + std::cout << "deviceindex:" << device_index_[num_player] << '\n'; } // Si coincide con el del otro jugador, se lo intercambian - if (deviceIndex[0] == deviceIndex[1]) { - const int theOtherPlayer = (numPlayer + 1) % 2; - deviceIndex[theOtherPlayer]--; - if (deviceIndex[theOtherPlayer] < 0) { - deviceIndex[theOtherPlayer] = numDevices - 1; + if (device_index_[0] == device_index_[1]) { + const int THE_OTHER_PLAYER = (num_player + 1) % 2; + device_index_[THE_OTHER_PLAYER]--; + if (device_index_[THE_OTHER_PLAYER] < 0) { + device_index_[THE_OTHER_PLAYER] = NUM_DEVICES - 1; } } // Copia el dispositivo marcado por el indice a la variable de opciones de cada jugador - Options::inputs[0] = availableInputDevices[deviceIndex[0]]; - Options::inputs[1] = availableInputDevices[deviceIndex[1]]; + Options::inputs[0] = available_input_devices_[device_index_[0]]; + Options::inputs[1] = available_input_devices_[device_index_[1]]; return true; } @@ -999,24 +1001,24 @@ auto Title::updatePlayerInputs(int numPlayer) -> bool { // Crea el mosaico de fondo del titulo void Title::createTiledBackground() { // Crea la textura para el mosaico de fondo - background = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH * 2, GAMECANVAS_HEIGHT * 2); - if (background != nullptr) { - SDL_SetTextureScaleMode(background, Texture::currentScaleMode); + background_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH * 2, GAMECANVAS_HEIGHT * 2); + if (background_ != nullptr) { + SDL_SetTextureScaleMode(background_, Texture::currentScaleMode); } - if (background == nullptr) { + if (background_ == nullptr) { if (Options::settings.console) { std::cout << "TitleSurface could not be created!\nSDL Error: " << SDL_GetError() << '\n'; } } // Crea los objetos para pintar en la textura de fondo - auto *bgTileTexture = new Texture(renderer, Asset::get()->get("title_bg_tile.png")); - auto *tile = new Sprite({0, 0, 64, 64}, bgTileTexture, renderer); + auto *bg_tile_texture = new Texture(renderer_, Asset::get()->get("title_bg_tile.png")); + auto *tile = new Sprite({0, 0, 64, 64}, bg_tile_texture, renderer_); // Prepara para dibujar sobre la textura - SDL_SetRenderTarget(renderer, background); - SDL_SetRenderDrawColor(renderer, 0x43, 0x43, 0x4F, 0xFF); - SDL_RenderClear(renderer); + SDL_SetRenderTarget(renderer_, background_); + SDL_SetRenderDrawColor(renderer_, 0x43, 0x43, 0x4F, 0xFF); + SDL_RenderClear(renderer_); // Rellena la textura con el tile tile->setSpriteClip(0, 0, 64, 64); @@ -1029,11 +1031,11 @@ void Title::createTiledBackground() { } // Vuelve a colocar el renderizador apuntando a la pantalla - SDL_SetRenderTarget(renderer, nullptr); + SDL_SetRenderTarget(renderer_, nullptr); // Libera la memoria utilizada por los objetos - bgTileTexture->unload(); - delete bgTileTexture; + bg_tile_texture->unload(); + delete bg_tile_texture; delete tile; } @@ -1042,21 +1044,21 @@ void Title::createTiledBackground() { // así que aquí solo leemos la lista actual sin reescanear. void Title::checkInputDevices() { if (Options::settings.console) { - std::cout << "Filling devices for options menu..." << '\n'; + std::cout << "Filling devices for options menu_..." << '\n'; } - const int numControllers = Input::get()->getNumControllers(); - availableInputDevices.clear(); + const int NUM_CONTROLLERS = Input::get()->getNumControllers(); + available_input_devices_.clear(); InputDevice temp; // Añade todos los mandos - if (numControllers > 0) { - for (int i = 0; i < numControllers; ++i) { + if (NUM_CONTROLLERS > 0) { + for (int i = 0; i < NUM_CONTROLLERS; ++i) { temp.id = i; temp.name = Input::get()->getControllerName(i); temp.deviceType = INPUT_USE_GAMECONTROLLER; - availableInputDevices.push_back(temp); + available_input_devices_.push_back(temp); if (Options::settings.console) { - std::cout << "Device " << (int)availableInputDevices.size() << " - " << temp.name.c_str() << '\n'; + std::cout << "Device " << (int)available_input_devices_.size() << " - " << temp.name.c_str() << '\n'; } } } @@ -1065,18 +1067,18 @@ void Title::checkInputDevices() { temp.id = -1; temp.name = "KEYBOARD"; temp.deviceType = INPUT_USE_KEYBOARD; - availableInputDevices.push_back(temp); + available_input_devices_.push_back(temp); if (Options::settings.console) { - std::cout << "Device " << (int)availableInputDevices.size() << " - " << temp.name.c_str() << '\n'; + std::cout << "Device " << (int)available_input_devices_.size() << " - " << temp.name.c_str() << '\n'; std::cout << '\n'; } } // Recarga las texturas void Title::reLoadTextures() { - dustTexture->reLoad(); - coffeeTexture->reLoad(); - crisisTexture->reLoad(); - gradientTexture->reLoad(); + dust_texture_->reLoad(); + coffee_texture_->reLoad(); + crisis_texture_->reLoad(); + gradient_texture_->reLoad(); createTiledBackground(); } \ No newline at end of file diff --git a/source/game/scenes/title.h b/source/game/scenes/title.h index 27d0a46..dd052d2 100644 --- a/source/game/scenes/title.h +++ b/source/game/scenes/title.h @@ -18,144 +18,113 @@ class Texture; struct JA_Music_t; struct JA_Sound_t; -// Textos -constexpr const char *TEXT_COPYRIGHT = "@2020 JailDesigner (v2.3.4)"; - -// Contadores -constexpr int TITLE_COUNTER = 800; - -// Cantidad de eventos de la pantalla de título -constexpr int TITLE_TOTAL_EVENTS = 2; - class Title { - private: - struct MenuData { - Menu *title; // Menu de la pantalla de título - Menu *options; // Menú de la pantalla de opciones - Menu *playerSelect; // Menu para elegir jugador - Menu *active; // Menu activo (de momento para la pantalla del titulo) - bool keyPressed; // Variable para evitar la repetición de teclas en los menus - }; - - // Objetos y punteros - SDL_Renderer *renderer; // El renderizador de la ventana - Instructions *instructions{nullptr}; // Objeto para la sección de las instrucciones - Game *demoGame{nullptr}; // Objeto para lanzar la demo del juego - SDL_Event *eventHandler; // Manejador de eventos - Section *section; // Indicador para el bucle del titulo - - Texture *dustTexture; // Textura con los graficos del polvo - Texture *coffeeTexture; // Textura con los graficos de la palabra coffee - Texture *crisisTexture; // Textura con los graficos de la plabra crisis - Texture *gradientTexture; // Textura con los graficos para el degradado del fondo del titulo - - SDL_Rect backgroundWindow; // Ventana visible para la textura de fondo del titulo - SDL_Texture *background; // Textura dibujar el fondo del titulo - - AnimatedSprite *dustBitmapL; // Sprite con la el polvo que aparece al colisionar el texto de la pantalla de titulo - AnimatedSprite *dustBitmapR; // Sprite con la el polvo que aparece al colisionar el texto de la pantalla de titulo - - SmartSprite *coffeeBitmap; // Sprite con la palabra COFFEE para la pantalla de titulo - SmartSprite *crisisBitmap; // Sprite con la palabra CRISIS para la pantalla de titulo - - Sprite *gradient; // Sprite para dibujar el degradado del titulo - - Text *text1; // Objeto de texto para poder escribir textos en pantalla - Text *text2; // Objeto de texto para poder escribir textos en pantalla - Fade *fade; // Objeto para realizar fundidos en pantalla - - // Variable - JA_Music_t *titleMusic; // Musica para el titulo - JA_Sound_t *crashSound; // Sonido con el impacto del título - int backgroundCounter; // Temporizador para el fondo de tiles de la pantalla de titulo - int counter; // Temporizador para la pantalla de titulo - Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa - Uint8 backgroundMode; // Variable para almacenar el tipo de efecto que hará el fondo de la pantalla de titulo - float sin[360]; // Vector con los valores del seno precalculados - bool menuVisible; // Indicador para saber si se muestra el menu del titulo o la frase intermitente - bool demo; // Indica si el modo demo estará activo - Section nextSection; // Indica cual es la siguiente sección a cargar cuando termine el contador del titulo - Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa - Uint8 postFade; // Opción a realizar cuando termina el fundido - MenuData menu; // Variable con todos los objetos menus y sus variables - // Snapshot per a permetre CANCEL al menú d'opcions. - Options::Video prevVideo; - Options::Window prevWindow; - Options::Settings prevSettings; - std::vector prevInputs; - std::vector availableInputDevices; // Vector con todos los metodos de control disponibles - std::vector deviceIndex; // Indice para el jugador [i] del vector de dispositivos de entrada disponibles - - // Variables para la vibración del título (SUBSECTION_TITLE_2) - int vibrationStep; // Paso actual de la vibración - int vibrationCoffeeBaseX{0}; // Posición X base del bitmap Coffee - int vibrationCrisisBaseX{0}; // Posición X base del bitmap Crisis - bool vibrationInitialized; // Indica si se han capturado las posiciones base - - // Variables para sub-estados delegados (instrucciones y demo) - bool instructionsActive; // Indica si las instrucciones están activas - bool demoGameActive; // Indica si el juego demo está activo - Instructions::Mode instructionsMode{Instructions::Mode::AUTO}; // Modo de las instrucciones activas - bool demoThenInstructions; // Indica si tras la demo hay que mostrar instrucciones - - // Inicializa los valores - void init(); - - // Actualiza las variables del objeto - void update(); - - // Dibuja el objeto en pantalla - void render(); - - // Comprueba las entradas - void checkInput(); - - // Actualiza el tileado de fondo - void updateBG(); - - // Cambia el valor de la variable de modo de pantalla completa - static void switchFullScreenModeVar(); - - // Actualiza los elementos de los menus - void updateMenuLabels() const; - - // Aplica las opciones de menu seleccionadas - void applyOptions(); - - // Ejecuta la parte donde se muestran las instrucciones - void runInstructions(Instructions::Mode mode); - - // Ejecuta el juego en modo demo - void runDemoGame(); - - // Modifica las opciones para los controles de los jugadores - auto updatePlayerInputs(int numPlayer) -> bool; - - // Crea el mosaico de fondo del titulo - void createTiledBackground(); - - // Comprueba cuantos mandos hay conectados para gestionar el menu de opciones - void checkInputDevices(); - - // Recarga las texturas - void reLoadTextures(); - public: - // Constructor - Title(SDL_Renderer *renderer, Section *section); - - // Destructor - ~Title(); + Title(SDL_Renderer *renderer, Section *section); // Constructor + ~Title(); // Destructor Title(const Title &) = delete; auto operator=(const Title &) -> Title & = delete; - // Bucle para el titulo del juego - void run(); + void run(); // Bucle para el titulo del juego + void iterate(); // Ejecuta un frame + void handleEvent(const SDL_Event *event); // Procesa un evento - // Ejecuta un frame - void iterate(); + private: + static constexpr const char *COPYRIGHT = "@2020 JailDesigner (v2.3.4)"; + static constexpr int COUNTER = 800; - // Procesa un evento - void handleEvent(const SDL_Event *event); + struct MenuData { + Menu *title; // Menu de la pantalla de título + Menu *options; // Menú de la pantalla de opciones + Menu *player_select; // Menu para elegir jugador + Menu *active; // Menu activo (de momento para la pantalla del titulo) + bool key_pressed; // Variable para evitar la repetición de teclas en los menus + }; + + // 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 + + Texture *dust_texture_; // Textura con los graficos del polvo + Texture *coffee_texture_; // Textura con los graficos de la palabra coffee + Texture *crisis_texture_; // Textura con los graficos de la plabra crisis + Texture *gradient_texture_; // Textura con los graficos para el degradado del fondo del titulo + + SDL_Rect background_window_; // Ventana visible para la textura de fondo del titulo + SDL_Texture *background_; // Textura dibujar el fondo del titulo + + AnimatedSprite *dust_bitmap_left_; // Sprite con la el polvo que aparece al colisionar el texto de la pantalla de titulo + AnimatedSprite *dust_bitmap_right_; // Sprite con la el polvo que aparece al colisionar el texto de la pantalla de titulo + + SmartSprite *coffee_bitmap_; // Sprite con la palabra COFFEE para la pantalla de titulo + SmartSprite *crisis_bitmap_; // Sprite con la palabra CRISIS para la pantalla de titulo + + Sprite *gradient_; // Sprite para dibujar el degradado del titulo + + Text *text1_; // Objeto de texto para poder escribir textos en pantalla + Text *text2_; // Objeto de texto para poder escribir textos en pantalla + Fade *fade_; // Objeto para realizar fundidos en pantalla + + // Variables + JA_Music_t *title_music_; // Musica para el titulo + JA_Sound_t *crash_sound_; // Sonido con el impacto del título + int background_counter_; // Temporizador para el fondo de tiles de la pantalla de titulo + int counter_; // Temporizador para la pantalla de titulo + Uint32 ticks_; // Contador de ticks para ajustar la velocidad del programa + Uint8 background_mode_; // Variable para almacenar el tipo de efecto que hará el fondo de la pantalla de titulo + float sin_[360]; // Vector con los valores del seno precalculados + bool menu_visible_; // Indicador para saber si se muestra el menu del titulo o la frase intermitente + bool demo_; // Indica si el modo demo estará activo + 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 + // Snapshot per a permetre CANCEL al menú d'opcions. + Options::Video prev_video_; + Options::Window prev_window_; + Options::Settings prev_settings_; + std::vector prev_inputs_; + std::vector available_input_devices_; // Vector con todos los metodos de control disponibles + std::vector device_index_; // Indice para el jugador [i] del vector de dispositivos de entrada disponibles + + // Variables para la vibración del título (SUBSECTION_TITLE_2) + int vibration_step_; // Paso actual de la vibración + int vibration_coffee_base_x_{0}; // Posición X base del bitmap Coffee + int vibration_crisis_base_x_{0}; // Posición X base del bitmap Crisis + bool vibration_initialized_; // Indica si se han capturado las posiciones base + + // Variables para sub-estados delegados (instrucciones y demo) + bool instructions_active_; // Indica si las instrucciones están activas + bool demo_game_active_; // Indica si el juego demo está activo + 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 + + // Helpers de update, uno por cada subsección y por cada switch dentro del título 3 + void updateTitle1(); + void updateTitle2(); + void updateTitle3(); + void handlePostFadeAction(); + void handleTitleMenuSelection(); + 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 };