diff --git a/data/gfx/game/game_clouds1.png b/data/gfx/game/game_clouds1.png index 3b239cd..2727291 100644 Binary files a/data/gfx/game/game_clouds1.png and b/data/gfx/game/game_clouds1.png differ diff --git a/data/gfx/game/game_clouds2.png b/data/gfx/game/game_clouds2.png index efb1401..6d539f4 100644 Binary files a/data/gfx/game/game_clouds2.png and b/data/gfx/game/game_clouds2.png differ diff --git a/source/background.cpp b/source/background.cpp index f3d5426..719d652 100644 --- a/source/background.cpp +++ b/source/background.cpp @@ -114,7 +114,7 @@ Background::~Background() void Background::update() { // Actualiza el valor de alpha_ - updateAlphaColorText(); + updateAlphaColorTexture(); // Actualiza las nubes updateClouds(); @@ -293,7 +293,7 @@ void Background::setAlpha(int alpha) } // Actualiza el valor de alpha_ -void Background::updateAlphaColorText() +void Background::updateAlphaColorTexture() { if (alpha_color_text_ == alpha_color_text_temp_) { @@ -346,22 +346,20 @@ void Background::updateClouds() // Precalcula el vector con el recorrido del sol void Background::createSunPath() { - constexpr int OFFSET_X = 94; // Desplazamiento en la textura del sol hasta el sol - constexpr int OFFSET_Y = 48; // Desplazamiento en la textura del sol hasta el sol - constexpr int CENTER_X = 270; - const int center_y = base_ - 30; - constexpr int RADIUS = 130; - const int EXTRA_PIXELS = 30; // Píxeles adicionales para la línea recta + constexpr int CENTER_X = 170; + const int center_y = base_ - 80; + constexpr int RADIUS = 120; // Generar puntos de la curva desde 90 a 180 grados for (double theta = M_PI / 2; theta <= M_PI; theta += 0.01) { int x = CENTER_X + static_cast(RADIUS * cos(theta)); - int y = center_y - static_cast(RADIUS * sin(theta)); // Nota: y está invertido en la pantalla - sun_path_.push_back({x - OFFSET_X, y - OFFSET_Y}); + int y = center_y - static_cast(RADIUS * sin(theta)); + sun_path_.push_back({x, y}); } // Agregar puntos en línea recta después de la curva + constexpr int EXTRA_PIXELS = 40; SDL_Point last_point = sun_path_.back(); for (int i = 1; i <= EXTRA_PIXELS; ++i) { @@ -380,7 +378,7 @@ void Background::createMoonPath() for (double theta = 0; theta <= M_PI / 2; theta += 0.01) { int x = CENTER_X + static_cast(RADIUS * cos(theta)); - int y = center_y - static_cast(RADIUS * sin(theta)); // Nota: y está invertido en la pantalla + int y = center_y - static_cast(RADIUS * sin(theta)); moon_path_.push_back({x, y}); } } diff --git a/source/background.h b/source/background.h index 7db1c9e..0ea98b8 100644 --- a/source/background.h +++ b/source/background.h @@ -86,8 +86,8 @@ private: int alpha_color_text_temp_; // Valor temporal para hacer la transición de alpha std::vector sun_path_; // Vector con el recorrido del sol std::vector moon_path_; // Vector con el recorrido de la luna - size_t sun_index_; // Posición del vector del recorrido del sol - size_t moon_index_; // Posición del vector del recorrido de la luna + size_t sun_index_ = 0; // Posición del vector del recorrido del sol + size_t moon_index_ = 0; // Posición del vector del recorrido de la luna // Dibuja el gradiente de fondo void renderGradient(); @@ -102,7 +102,7 @@ private: void fillCanvas(); // Actualiza el valor de alpha - void updateAlphaColorText(); + void updateAlphaColorTexture(); // Actualiza las nubes void updateClouds(); diff --git a/source/balloon_manager.cpp b/source/balloon_manager.cpp index 5fd4685..2b2db3c 100644 --- a/source/balloon_manager.cpp +++ b/source/balloon_manager.cpp @@ -180,50 +180,61 @@ int BalloonManager::calculateScreenPower() // Crea un globo nuevo en el vector de globos std::shared_ptr BalloonManager::createBalloon(float x, int y, BalloonType type, BalloonSize size, float velx, float speed, int creation_timer) { - const int index = static_cast(size); - balloons_.emplace_back(std::make_shared(x, y, type, size, velx, speed, creation_timer, play_area_, balloon_textures_.at(index), balloon_animations_.at(index))); - return balloons_.back(); + if (can_deploy_balloons_) + { + const int index = static_cast(size); + balloons_.emplace_back(std::make_shared(x, y, type, size, velx, speed, creation_timer, play_area_, balloon_textures_.at(index), balloon_animations_.at(index))); + return balloons_.back(); + } + + return nullptr; } // Crea un globo a partir de otro globo void BalloonManager::createChildBalloon(const std::shared_ptr &balloon, const std::string &direction) { - const float vx = direction == "LEFT" ? BALLOON_VELX_NEGATIVE : BALLOON_VELX_POSITIVE; - const auto lower_size = static_cast(static_cast(balloon->getSize()) - 1); - auto b = createBalloon(0, balloon->getPosY(), balloon->getType(), lower_size, vx, balloon_speed_, 0); - const int x = direction == "LEFT" ? balloon->getPosX() + (balloon->getWidth() / 3) : balloon->getPosX() + 2 * (balloon->getWidth() / 3); - b->alignTo(x); - b->setVelY(b->getType() == BalloonType::BALLOON ? -2.50f : BALLOON_VELX_NEGATIVE * 2.0f); - if (balloon->isStopped()) + if (can_deploy_balloons_) { - b->stop(); - } - if (balloon->isUsingReversedColor()) - { - b->useReverseColor(); + const float vx = direction == "LEFT" ? BALLOON_VELX_NEGATIVE : BALLOON_VELX_POSITIVE; + const auto lower_size = static_cast(static_cast(balloon->getSize()) - 1); + auto b = createBalloon(0, balloon->getPosY(), balloon->getType(), lower_size, vx, balloon_speed_, 0); + const int x = direction == "LEFT" ? balloon->getPosX() + (balloon->getWidth() / 3) : balloon->getPosX() + 2 * (balloon->getWidth() / 3); + b->alignTo(x); + b->setVelY(b->getType() == BalloonType::BALLOON ? -2.50f : BALLOON_VELX_NEGATIVE * 2.0f); + if (balloon->isStopped()) + { + b->stop(); + } + if (balloon->isUsingReversedColor()) + { + b->useReverseColor(); + } } } // Crea una PowerBall void BalloonManager::createPowerBall() { - constexpr int values = 6; - constexpr int pos_y = -BALLOON_SIZE[4]; - constexpr int creation_time = 0; + if (can_deploy_balloons_) + { + constexpr int values = 6; + constexpr int pos_y = -BALLOON_SIZE[4]; + constexpr int creation_time = 0; - const auto left = param.game.play_area.rect.x; - const auto center = param.game.play_area.center_x - (BALLOON_SIZE[4] / 2); - const auto right = param.game.play_area.rect.w - BALLOON_SIZE[4]; + const auto left = param.game.play_area.rect.x; + const auto center = param.game.play_area.center_x - (BALLOON_SIZE[4] / 2); + const auto right = param.game.play_area.rect.w - BALLOON_SIZE[4]; - const auto luck = rand() % values; - const int x[values] = {left, left, center, center, right, right}; - const float vx[values] = {BALLOON_VELX_POSITIVE, BALLOON_VELX_POSITIVE, BALLOON_VELX_POSITIVE, BALLOON_VELX_NEGATIVE, BALLOON_VELX_NEGATIVE, BALLOON_VELX_NEGATIVE}; + const auto luck = rand() % values; + const int x[values] = {left, left, center, center, right, right}; + const float vx[values] = {BALLOON_VELX_POSITIVE, BALLOON_VELX_POSITIVE, BALLOON_VELX_POSITIVE, BALLOON_VELX_NEGATIVE, BALLOON_VELX_NEGATIVE, BALLOON_VELX_NEGATIVE}; - balloons_.emplace_back(std::make_unique(x[luck], pos_y, BalloonType::POWERBALL, BalloonSize::SIZE4, vx[luck], balloon_speed_, creation_time, play_area_, balloon_textures_[4], balloon_animations_[4])); - balloons_.back()->setInvulnerable(true); + balloons_.emplace_back(std::make_unique(x[luck], pos_y, BalloonType::POWERBALL, BalloonSize::SIZE4, vx[luck], balloon_speed_, creation_time, play_area_, balloon_textures_[4], balloon_animations_[4])); + balloons_.back()->setInvulnerable(true); - power_ball_enabled_ = true; - power_ball_counter_ = POWERBALL_COUNTER; + power_ball_enabled_ = true; + power_ball_counter_ = POWERBALL_COUNTER; + } } // Establece la velocidad de los globos diff --git a/source/balloon_manager.h b/source/balloon_manager.h index b3db7b4..7614364 100644 --- a/source/balloon_manager.h +++ b/source/balloon_manager.h @@ -34,6 +34,7 @@ private: int last_balloon_deploy_ = 0; // Guarda cual ha sido la última formación desplegada para no repetir; SDL_Rect play_area_ = param.game.play_area.rect; // Zona por donde se moveran los globos bool creation_time_enabled_ = true; // Indica si los globos se crean con tiempo + bool can_deploy_balloons_ = true; // Indica si creará globos // Inicializa void init(); @@ -128,4 +129,5 @@ public: void resetBalloonSpeed() { setBalloonSpeed(default_balloon_speed_); } void setPlayArea(SDL_Rect play_area) { play_area_ = play_area; } void setCreationTimeEnabled(bool value) { creation_time_enabled_ = value; } + void setDeployBalloons(bool value) { can_deploy_balloons_ = value; } }; \ No newline at end of file diff --git a/source/director.cpp b/source/director.cpp index 5fa848c..0edbafa 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -54,7 +54,7 @@ Director::Director(int argc, const char *argv[]) section::name = section::Name::GAME; section::options = section::Options::GAME_PLAY_1P; #elif DEBUG - section::name = section::Name::LOGO; + section::name = section::Name::GAME; #else // NORMAL GAME section::name = section::Name::LOGO; section::attract_mode = section::AttractMode::TITLE_TO_DEMO; diff --git a/source/game.cpp b/source/game.cpp index 8cea7ff..9d70c97 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -1239,7 +1239,9 @@ void Game::checkEvents() case SDLK_3: // Activa el modo para pasar el juego automaticamente { auto_pop_balloons_ = !auto_pop_balloons_; - Notifier::get()->showText({"auto_pop_balloons_ " + boolToString(auto_pop_balloons_)}); + Notifier::get()->showText({"auto advance: " + boolToString(auto_pop_balloons_)}); + balloon_manager_->destroyAllBalloons(); + balloon_manager_->setDeployBalloons(!auto_pop_balloons_); break; } case SDLK_4: // Suelta un item