diff --git a/data/gfx/balloon/explosion4.ani b/data/gfx/balloon/explosion4.ani index dc06f55..872dfc4 100644 --- a/data/gfx/balloon/explosion4.ani +++ b/data/gfx/balloon/explosion4.ani @@ -1,5 +1,5 @@ -frame_width=46 -frame_height=46 +frame_width=48 +frame_height=48 [animation] name=default diff --git a/data/gfx/balloon/explosion4.png b/data/gfx/balloon/explosion4.png index 7fa64fe..06d1653 100644 Binary files a/data/gfx/balloon/explosion4.png and b/data/gfx/balloon/explosion4.png differ diff --git a/source/balloon_manager.cpp b/source/balloon_manager.cpp index 2cd13a1..92e825a 100644 --- a/source/balloon_manager.cpp +++ b/source/balloon_manager.cpp @@ -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, { if (can_deploy_balloons_) { - 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); + // Calcula parametros + const float VX = direction == "LEFT" ? BALLOON_VELX_NEGATIVE : BALLOON_VELX_POSITIVE; + const auto SIZE = static_cast(static_cast(balloon->getSize()) - 1); + const int PARENT_HEIGHT = balloon->getHeight(); + const int CHILD_HEIGHT = BALLOON_SIZE[static_cast(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); } } \ No newline at end of file diff --git a/source/explosions.cpp b/source/explosions.cpp index 2c0a74d..5d54a4a 100644 --- a/source/explosions.cpp +++ b/source/explosions.cpp @@ -32,8 +32,8 @@ void Explosions::addTexture(int size, std::shared_ptr texture, const st // Añade una explosión void Explosions::add(int x, int y, int size) { - const auto index = getIndexBySize(size); - explosions_.emplace_back(std::make_unique(textures_[index].texture, textures_[index].animation)); + const auto INDEX = getIndexBySize(size); + explosions_.emplace_back(std::make_unique(textures_[INDEX].texture, textures_[INDEX].animation)); explosions_.back()->setPos(x, y); }