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()
{
// 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<int>(RADIUS * cos(theta));
int y = center_y - static_cast<int>(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<int>(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<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});
}
}

View File

@@ -86,8 +86,8 @@ private:
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> 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();

View File

@@ -180,14 +180,21 @@ int BalloonManager::calculateScreenPower()
// 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)
{
if (can_deploy_balloons_)
{
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
void BalloonManager::createChildBalloon(const std::shared_ptr<Balloon> &balloon, const std::string &direction)
{
if (can_deploy_balloons_)
{
const float vx = direction == "LEFT" ? BALLOON_VELX_NEGATIVE : BALLOON_VELX_POSITIVE;
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);
@@ -202,11 +209,14 @@ void BalloonManager::createChildBalloon(const std::shared_ptr<Balloon> &balloon,
{
b->useReverseColor();
}
}
}
// Crea una PowerBall
void BalloonManager::createPowerBall()
{
if (can_deploy_balloons_)
{
constexpr int values = 6;
constexpr int pos_y = -BALLOON_SIZE[4];
constexpr int creation_time = 0;
@@ -224,6 +234,7 @@ void BalloonManager::createPowerBall()
power_ball_enabled_ = true;
power_ball_counter_ = POWERBALL_COUNTER;
}
}
// 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;
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; }
};

View File

@@ -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;

View File

@@ -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