Modificat el color dels nuvols de la última pantalla

debug: opció de no crear mes globos
This commit is contained in:
2025-01-05 09:22:30 +01:00
parent 198aa45d59
commit cd806363e8
8 changed files with 57 additions and 44 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -114,7 +114,7 @@ Background::~Background()
void Background::update() void Background::update()
{ {
// Actualiza el valor de alpha_ // Actualiza el valor de alpha_
updateAlphaColorText(); updateAlphaColorTexture();
// Actualiza las nubes // Actualiza las nubes
updateClouds(); updateClouds();
@@ -293,7 +293,7 @@ void Background::setAlpha(int alpha)
} }
// Actualiza el valor de alpha_ // Actualiza el valor de alpha_
void Background::updateAlphaColorText() void Background::updateAlphaColorTexture()
{ {
if (alpha_color_text_ == alpha_color_text_temp_) if (alpha_color_text_ == alpha_color_text_temp_)
{ {
@@ -346,22 +346,20 @@ void Background::updateClouds()
// Precalcula el vector con el recorrido del sol // Precalcula el vector con el recorrido del sol
void Background::createSunPath() void Background::createSunPath()
{ {
constexpr int OFFSET_X = 94; // Desplazamiento en la textura del sol hasta el sol constexpr int CENTER_X = 170;
constexpr int OFFSET_Y = 48; // Desplazamiento en la textura del sol hasta el sol const int center_y = base_ - 80;
constexpr int CENTER_X = 270; constexpr int RADIUS = 120;
const int center_y = base_ - 30;
constexpr int RADIUS = 130;
const int EXTRA_PIXELS = 30; // Píxeles adicionales para la línea recta
// Generar puntos de la curva desde 90 a 180 grados // Generar puntos de la curva desde 90 a 180 grados
for (double theta = M_PI / 2; theta <= M_PI; theta += 0.01) for (double theta = M_PI / 2; theta <= M_PI; theta += 0.01)
{ {
int x = CENTER_X + static_cast<int>(RADIUS * cos(theta)); int x = CENTER_X + static_cast<int>(RADIUS * cos(theta));
int y = center_y - static_cast<int>(RADIUS * sin(theta)); // Nota: y está invertido en la pantalla int y = center_y - static_cast<int>(RADIUS * sin(theta));
sun_path_.push_back({x - OFFSET_X, y - OFFSET_Y}); sun_path_.push_back({x, y});
} }
// Agregar puntos en línea recta después de la curva // Agregar puntos en línea recta después de la curva
constexpr int EXTRA_PIXELS = 40;
SDL_Point last_point = sun_path_.back(); SDL_Point last_point = sun_path_.back();
for (int i = 1; i <= EXTRA_PIXELS; ++i) 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) for (double theta = 0; theta <= M_PI / 2; theta += 0.01)
{ {
int x = CENTER_X + static_cast<int>(RADIUS * cos(theta)); int x = CENTER_X + static_cast<int>(RADIUS * cos(theta));
int y = center_y - static_cast<int>(RADIUS * sin(theta)); // Nota: y está invertido en la pantalla int y = center_y - static_cast<int>(RADIUS * sin(theta));
moon_path_.push_back({x, y}); moon_path_.push_back({x, y});
} }
} }

View File

@@ -86,8 +86,8 @@ private:
int alpha_color_text_temp_; // Valor temporal para hacer la transición de alpha int alpha_color_text_temp_; // Valor temporal para hacer la transición de alpha
std::vector<SDL_Point> sun_path_; // Vector con el recorrido del sol std::vector<SDL_Point> sun_path_; // Vector con el recorrido del sol
std::vector<SDL_Point> moon_path_; // Vector con el recorrido de la luna std::vector<SDL_Point> moon_path_; // Vector con el recorrido de la luna
size_t sun_index_; // Posición del vector del recorrido del sol size_t sun_index_ = 0; // Posición del vector del recorrido del sol
size_t moon_index_; // Posición del vector del recorrido de la luna size_t moon_index_ = 0; // Posición del vector del recorrido de la luna
// Dibuja el gradiente de fondo // Dibuja el gradiente de fondo
void renderGradient(); void renderGradient();
@@ -102,7 +102,7 @@ private:
void fillCanvas(); void fillCanvas();
// Actualiza el valor de alpha // Actualiza el valor de alpha
void updateAlphaColorText(); void updateAlphaColorTexture();
// Actualiza las nubes // Actualiza las nubes
void updateClouds(); void updateClouds();

View File

@@ -180,50 +180,61 @@ int BalloonManager::calculateScreenPower()
// Crea un globo nuevo en el vector de globos // Crea un globo nuevo en el vector de globos
std::shared_ptr<Balloon> BalloonManager::createBalloon(float x, int y, BalloonType type, BalloonSize size, float velx, float speed, int creation_timer) std::shared_ptr<Balloon> BalloonManager::createBalloon(float x, int y, BalloonType type, BalloonSize size, float velx, float speed, int creation_timer)
{ {
const int index = static_cast<int>(size); if (can_deploy_balloons_)
balloons_.emplace_back(std::make_shared<Balloon>(x, y, type, size, velx, speed, creation_timer, play_area_, balloon_textures_.at(index), balloon_animations_.at(index))); {
return balloons_.back(); const int index = static_cast<int>(size);
balloons_.emplace_back(std::make_shared<Balloon>(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 // Crea un globo a partir de otro globo
void BalloonManager::createChildBalloon(const std::shared_ptr<Balloon> &balloon, const std::string &direction) void BalloonManager::createChildBalloon(const std::shared_ptr<Balloon> &balloon, const std::string &direction)
{ {
const float vx = direction == "LEFT" ? BALLOON_VELX_NEGATIVE : BALLOON_VELX_POSITIVE; if (can_deploy_balloons_)
const auto lower_size = static_cast<BalloonSize>(static_cast<int>(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(); const float vx = direction == "LEFT" ? BALLOON_VELX_NEGATIVE : BALLOON_VELX_POSITIVE;
} const auto lower_size = static_cast<BalloonSize>(static_cast<int>(balloon->getSize()) - 1);
if (balloon->isUsingReversedColor()) 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->useReverseColor(); 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 // Crea una PowerBall
void BalloonManager::createPowerBall() void BalloonManager::createPowerBall()
{ {
constexpr int values = 6; if (can_deploy_balloons_)
constexpr int pos_y = -BALLOON_SIZE[4]; {
constexpr int creation_time = 0; 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 left = param.game.play_area.rect.x;
const auto center = param.game.play_area.center_x - (BALLOON_SIZE[4] / 2); 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 right = param.game.play_area.rect.w - BALLOON_SIZE[4];
const auto luck = rand() % values; const auto luck = rand() % values;
const int x[values] = {left, left, center, center, right, right}; 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 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<Balloon>(x[luck], pos_y, BalloonType::POWERBALL, BalloonSize::SIZE4, vx[luck], balloon_speed_, creation_time, play_area_, balloon_textures_[4], balloon_animations_[4])); balloons_.emplace_back(std::make_unique<Balloon>(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_.back()->setInvulnerable(true);
power_ball_enabled_ = true; power_ball_enabled_ = true;
power_ball_counter_ = POWERBALL_COUNTER; power_ball_counter_ = POWERBALL_COUNTER;
}
} }
// Establece la velocidad de los globos // Establece la velocidad de los globos

View File

@@ -34,6 +34,7 @@ private:
int last_balloon_deploy_ = 0; // Guarda cual ha sido la última formación desplegada para no repetir; 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 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 creation_time_enabled_ = true; // Indica si los globos se crean con tiempo
bool can_deploy_balloons_ = true; // Indica si creará globos
// Inicializa // Inicializa
void init(); void init();
@@ -128,4 +129,5 @@ public:
void resetBalloonSpeed() { setBalloonSpeed(default_balloon_speed_); } void resetBalloonSpeed() { setBalloonSpeed(default_balloon_speed_); }
void setPlayArea(SDL_Rect play_area) { play_area_ = play_area; } void setPlayArea(SDL_Rect play_area) { play_area_ = play_area; }
void setCreationTimeEnabled(bool value) { creation_time_enabled_ = value; } void setCreationTimeEnabled(bool value) { creation_time_enabled_ = value; }
void setDeployBalloons(bool value) { can_deploy_balloons_ = value; }
}; };

View File

@@ -54,7 +54,7 @@ Director::Director(int argc, const char *argv[])
section::name = section::Name::GAME; section::name = section::Name::GAME;
section::options = section::Options::GAME_PLAY_1P; section::options = section::Options::GAME_PLAY_1P;
#elif DEBUG #elif DEBUG
section::name = section::Name::LOGO; section::name = section::Name::GAME;
#else // NORMAL GAME #else // NORMAL GAME
section::name = section::Name::LOGO; section::name = section::Name::LOGO;
section::attract_mode = section::AttractMode::TITLE_TO_DEMO; section::attract_mode = section::AttractMode::TITLE_TO_DEMO;

View File

@@ -1239,7 +1239,9 @@ void Game::checkEvents()
case SDLK_3: // Activa el modo para pasar el juego automaticamente case SDLK_3: // Activa el modo para pasar el juego automaticamente
{ {
auto_pop_balloons_ = !auto_pop_balloons_; 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; break;
} }
case SDLK_4: // Suelta un item case SDLK_4: // Suelta un item