fix: els globos fills estaven alineats cap a dalt en lloc de al centre

fix: les explosions eren de un tamany inferior (i per tant desalineades ademes)
This commit is contained in:
2025-07-15 09:26:31 +02:00
parent 6329283124
commit 04a80392d8
4 changed files with 27 additions and 17 deletions

View File

@@ -46,10 +46,10 @@ void BalloonManager::init()
explosions_animations_.emplace_back(Resource::get()->getAnimation("explosion4.ani"));
// Añade texturas
explosions_->addTexture(1, explosions_textures_[0], explosions_animations_[0]);
explosions_->addTexture(2, explosions_textures_[1], explosions_animations_[1]);
explosions_->addTexture(3, explosions_textures_[2], explosions_animations_[2]);
explosions_->addTexture(4, explosions_textures_[3], explosions_animations_[3]);
explosions_->addTexture(0, explosions_textures_[0], explosions_animations_[0]);
explosions_->addTexture(1, explosions_textures_[1], explosions_animations_[1]);
explosions_->addTexture(2, explosions_textures_[2], explosions_animations_[2]);
explosions_->addTexture(3, explosions_textures_[3], explosions_animations_[3]);
}
// Actualiza
@@ -196,12 +196,22 @@ void BalloonManager::createChildBalloon(const std::shared_ptr<Balloon> &balloon,
{
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);
const int x = direction == "LEFT" ? balloon->getPosX() + (balloon->getWidth() / 3) : balloon->getPosX() + 2 * (balloon->getWidth() / 3);
b->alignTo(x);
// Calcula parametros
const float VX = direction == "LEFT" ? BALLOON_VELX_NEGATIVE : BALLOON_VELX_POSITIVE;
const auto SIZE = static_cast<BalloonSize>(static_cast<int>(balloon->getSize()) - 1);
const int PARENT_HEIGHT = balloon->getHeight();
const int CHILD_HEIGHT = BALLOON_SIZE[static_cast<int>(balloon->getSize()) - 1];
const int Y = balloon->getPosY() + (PARENT_HEIGHT - CHILD_HEIGHT) / 2;
const int X = direction == "LEFT" ? balloon->getPosX() + (balloon->getWidth() / 3) : balloon->getPosX() + 2 * (balloon->getWidth() / 3);
// Crea el globo
auto b = createBalloon(0, Y, balloon->getType(), SIZE, VX, balloon_speed_, 0);
// Establece parametros
b->alignTo(X);
b->setVelY(b->getType() == BalloonType::BALLOON ? -2.50f : BALLOON_VELX_NEGATIVE * 2.0f);
// Herencia de estados
if (balloon->isStopped())
{
b->stop();
@@ -409,7 +419,7 @@ void BalloonManager::setSounds(bool value)
}
}
// Activa o desactiva los sonidos de rebote los globos
// Activa o desactiva los sonidos de rebote los globos
void BalloonManager::setBouncingSounds(bool value)
{
bouncing_sound_enabled_ = value;
@@ -418,12 +428,12 @@ void BalloonManager::setBouncingSounds(bool value)
balloon->setBouncingSound(value);
}
}
// Activa o desactiva los sonidos de los globos al explotar
// Activa o desactiva los sonidos de los globos al explotar
void BalloonManager::setPoppingSounds(bool value)
{
poping_sound_enabled_ = value;
poping_sound_enabled_ = value;
for (auto &balloon : balloons_)
{
balloon->setPoppingSound(value);
balloon->setPoppingSound(value);
}
}