nou: modificat el valor de velocitat en la creació dels globos verds. i tornat a deixar com estava

This commit is contained in:
2025-09-30 12:42:38 +02:00
parent a0fb6934b0
commit a4abc02f88
3 changed files with 45 additions and 30 deletions

View File

@@ -4,31 +4,31 @@
# Los pools no necesitan estar ordenados ni ser consecutivos # Los pools no necesitan estar ordenados ni ser consecutivos
# Pool para la fase 1 # Pool para la fase 1
POOL: 0 FORMATIONS: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 POOL: 0 FORMATIONS: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
# Pool para la fase 2 # Pool para la fase 2
POOL: 1 FORMATIONS: 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 POOL: 1 FORMATIONS: 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
# Pool para la fase 3 # Pool para la fase 3
POOL: 2 FORMATIONS: 0, 1, 2, 3, 4, 55, 56, 57, 58, 59 POOL: 2 FORMATIONS: 0, 1, 2, 3, 4, 55, 56, 57, 58, 59
# Pool para la fase 4 # Pool para la fase 4
POOL: 3 FORMATIONS: 50, 51, 52, 53, 54, 5, 6, 7, 8, 9 POOL: 3 FORMATIONS: 50, 51, 52, 53, 54, 5, 6, 7, 8, 9
# Pool para la fase 5 # Pool para la fase 5
POOL: 4 FORMATIONS: 60, 61, 62, 63, 64, 65, 66, 67, 68, 69 POOL: 4 FORMATIONS: 60, 61, 62, 63, 64, 65, 66, 67, 68, 69
# Pool para la fase 6 # Pool para la fase 6
POOL: 5 FORMATIONS: 10, 61, 12, 63, 14, 65, 16, 67, 18, 69 POOL: 5 FORMATIONS: 10, 61, 12, 63, 14, 65, 16, 67, 18, 69
# Pool para la fase 7 # Pool para la fase 7
POOL: 6 FORMATIONS: 60, 11, 62, 13, 64, 15, 66, 17, 68, 19 POOL: 6 FORMATIONS: 60, 11, 62, 13, 64, 15, 66, 17, 68, 19
# Pool para la fase 8 # Pool para la fase 8
POOL: 7 FORMATIONS: 20, 21, 22, 23, 24, 65, 66, 67, 68, 69 POOL: 7 FORMATIONS: 20, 21, 22, 23, 24, 65, 66, 67, 68, 69
# Pool para la fase 9 # Pool para la fase 9
POOL: 8 FORMATIONS: 70, 71, 72, 73, 74, 15, 16, 17, 18, 19 POOL: 8 FORMATIONS: 70, 71, 72, 73, 74, 15, 16, 17, 18, 19
# Pool para la fase 10 # Pool para la fase 10
POOL: 9 FORMATIONS: 20, 21, 22, 23, 24, 70, 71, 72, 73, 74 POOL: 9 FORMATIONS: 20, 21, 22, 23, 24, 70, 71, 72, 73, 74

View File

@@ -122,6 +122,8 @@ class Balloon {
// --- Setters --- // --- Setters ---
void setVelY(float vel_y) { vy_ = vel_y; } void setVelY(float vel_y) { vy_ = vel_y; }
void setVelX(float vel_x) { vx_ = vel_x; }
void alterVelX(float percent) {vx_ *= percent; }
void setGameTempo(float tempo) { game_tempo_ = tempo; } void setGameTempo(float tempo) { game_tempo_ = tempo; }
void setInvulnerable(bool value) { invulnerable_ = value; } void setInvulnerable(bool value) { invulnerable_ = value; }
void setBouncingSound(bool value) { sound_.bouncing_enabled = value; } void setBouncingSound(bool value) { sound_.bouncing_enabled = value; }

View File

@@ -16,7 +16,7 @@
#include "utils.h" #include "utils.h"
// Constructor // Constructor
BalloonManager::BalloonManager(IStageInfo *stage_info) BalloonManager::BalloonManager(IStageInfo* stage_info)
: explosions_(std::make_unique<Explosions>()), : explosions_(std::make_unique<Explosions>()),
balloon_formations_(std::make_unique<BalloonFormations>()), balloon_formations_(std::make_unique<BalloonFormations>()),
stage_info_(stage_info) { init(); } stage_info_(stage_info) { init(); }
@@ -64,7 +64,7 @@ void BalloonManager::init() {
// Actualiza (time-based) // Actualiza (time-based)
void BalloonManager::update(float deltaTime) { void BalloonManager::update(float deltaTime) {
for (const auto &balloon : balloons_) { for (const auto& balloon : balloons_) {
balloon->update(deltaTime); balloon->update(deltaTime);
} }
updateBalloonDeployCounter(deltaTime); updateBalloonDeployCounter(deltaTime);
@@ -73,7 +73,7 @@ void BalloonManager::update(float deltaTime) {
// Renderiza los objetos // Renderiza los objetos
void BalloonManager::render() { void BalloonManager::render() {
for (auto &balloon : balloons_) { for (auto& balloon : balloons_) {
balloon->render(); balloon->render();
} }
explosions_->render(); explosions_->render();
@@ -158,7 +158,7 @@ void BalloonManager::deployFormation(int formation_id, float y) {
// Vacia del vector de globos los globos que ya no sirven // Vacia del vector de globos los globos que ya no sirven
void BalloonManager::freeBalloons() { void BalloonManager::freeBalloons() {
auto result = std::ranges::remove_if(balloons_, [](const auto &balloon) { return !balloon->isEnabled(); }); auto result = std::ranges::remove_if(balloons_, [](const auto& balloon) { return !balloon->isEnabled(); });
balloons_.erase(result.begin(), balloons_.end()); balloons_.erase(result.begin(), balloons_.end());
} }
@@ -173,7 +173,7 @@ auto BalloonManager::canPowerBallBeCreated() -> bool { return (!power_ball_enabl
// Calcula el poder actual de los globos en pantalla // Calcula el poder actual de los globos en pantalla
auto BalloonManager::calculateScreenPower() -> int { auto BalloonManager::calculateScreenPower() -> int {
return std::accumulate(balloons_.begin(), balloons_.end(), 0, [](int sum, const auto &balloon) { return sum + (balloon->isEnabled() ? balloon->getPower() : 0); }); return std::accumulate(balloons_.begin(), balloons_.end(), 0, [](int sum, const auto& balloon) { return sum + (balloon->isEnabled() ? balloon->getPower() : 0); });
} }
// Crea un globo nuevo en el vector de globos // Crea un globo nuevo en el vector de globos
@@ -194,7 +194,7 @@ auto BalloonManager::createBalloon(Balloon::Config config) -> std::shared_ptr<Ba
} }
// 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) {
if (can_deploy_balloons_) { if (can_deploy_balloons_) {
// Calcula parametros // Calcula parametros
const int PARENT_HEIGHT = balloon->getHeight(); const int PARENT_HEIGHT = balloon->getHeight();
@@ -217,9 +217,22 @@ void BalloonManager::createChildBalloon(const std::shared_ptr<Balloon> &balloon,
// Crea el globo // Crea el globo
auto b = createBalloon(config); auto b = createBalloon(config);
// Establece parametros (deltaTime en segundos - velocidades en pixels/segundo) // Establece parametros
constexpr float VEL_Y_BALLOON_PER_S = -150.0F; // -2.50 pixels/frame convertido a pixels/segundo (-2.50 * 60 = -150) constexpr float VEL_Y_BALLOON_PER_S = -150.0F;
b->setVelY(b->getType() == Balloon::Type::BALLOON ? VEL_Y_BALLOON_PER_S : Balloon::VELX_NEGATIVE * 2.0F); switch (b->getType()) {
case Balloon::Type::BALLOON: {
b->setVelY(VEL_Y_BALLOON_PER_S);
break;
}
case Balloon::Type::FLOATER: {
const float MODIFIER = (rand() % 2 == 0) ? 1.0F : 1.0F;
b->setVelY(Balloon::VELX_NEGATIVE * 2.0F * MODIFIER);
(rand() % 2 == 0) ? b->alterVelX(1.0F) : b->alterVelX(1.0F);
break;
}
default:
break;
}
// Herencia de estados // Herencia de estados
if (balloon->isStopped()) { b->stop(); } if (balloon->isStopped()) { b->stop(); }
@@ -267,13 +280,13 @@ void BalloonManager::createPowerBall() {
// Establece la velocidad de los globos // Establece la velocidad de los globos
void BalloonManager::setBalloonSpeed(float speed) { void BalloonManager::setBalloonSpeed(float speed) {
balloon_speed_ = speed; balloon_speed_ = speed;
for (auto &balloon : balloons_) { for (auto& balloon : balloons_) {
balloon->setGameTempo(speed); balloon->setGameTempo(speed);
} }
} }
// Explosiona un globo. Lo destruye y crea otros dos si es el caso // Explosiona un globo. Lo destruye y crea otros dos si es el caso
auto BalloonManager::popBalloon(const std::shared_ptr<Balloon> &balloon) -> int { auto BalloonManager::popBalloon(const std::shared_ptr<Balloon>& balloon) -> int {
stage_info_->addPower(1); stage_info_->addPower(1);
int score = 0; int score = 0;
@@ -298,7 +311,7 @@ auto BalloonManager::popBalloon(const std::shared_ptr<Balloon> &balloon) -> int
} }
// Explosiona un globo. Lo destruye = no crea otros globos // Explosiona un globo. Lo destruye = no crea otros globos
auto BalloonManager::destroyBalloon(std::shared_ptr<Balloon> &balloon) -> int { auto BalloonManager::destroyBalloon(std::shared_ptr<Balloon>& balloon) -> int {
int score = 0; int score = 0;
// Calcula la puntuación y el poder que generaria el globo en caso de romperlo a él y a sus hijos // Calcula la puntuación y el poder que generaria el globo en caso de romperlo a él y a sus hijos
@@ -333,7 +346,7 @@ auto BalloonManager::destroyBalloon(std::shared_ptr<Balloon> &balloon) -> int {
// Destruye todos los globos // Destruye todos los globos
auto BalloonManager::destroyAllBalloons() -> int { auto BalloonManager::destroyAllBalloons() -> int {
int score = 0; int score = 0;
for (auto &balloon : balloons_) { for (auto& balloon : balloons_) {
score += destroyBalloon(balloon); score += destroyBalloon(balloon);
} }
@@ -346,7 +359,7 @@ auto BalloonManager::destroyAllBalloons() -> int {
// Detiene todos los globos // Detiene todos los globos
void BalloonManager::stopAllBalloons() { void BalloonManager::stopAllBalloons() {
for (auto &balloon : balloons_) { for (auto& balloon : balloons_) {
if (!balloon->isBeingCreated()) { if (!balloon->isBeingCreated()) {
balloon->stop(); balloon->stop();
} }
@@ -355,7 +368,7 @@ void BalloonManager::stopAllBalloons() {
// Pone en marcha todos los globos // Pone en marcha todos los globos
void BalloonManager::startAllBalloons() { void BalloonManager::startAllBalloons() {
for (auto &balloon : balloons_) { for (auto& balloon : balloons_) {
if (!balloon->isBeingCreated()) { if (!balloon->isBeingCreated()) {
balloon->start(); balloon->start();
} }
@@ -364,7 +377,7 @@ void BalloonManager::startAllBalloons() {
// Cambia el color de todos los globos // Cambia el color de todos los globos
void BalloonManager::reverseColorsToAllBalloons() { void BalloonManager::reverseColorsToAllBalloons() {
for (auto &balloon : balloons_) { for (auto& balloon : balloons_) {
if (balloon->isStopped()) { if (balloon->isStopped()) {
balloon->useReverseColor(); balloon->useReverseColor();
} }
@@ -373,7 +386,7 @@ void BalloonManager::reverseColorsToAllBalloons() {
// Cambia el color de todos los globos // Cambia el color de todos los globos
void BalloonManager::normalColorsToAllBalloons() { void BalloonManager::normalColorsToAllBalloons() {
for (auto &balloon : balloons_) { for (auto& balloon : balloons_) {
balloon->useNormalColor(); balloon->useNormalColor();
} }
} }
@@ -385,13 +398,13 @@ void BalloonManager::createTwoBigBalloons() {
// Obtiene el nivel de ameza actual generado por los globos // Obtiene el nivel de ameza actual generado por los globos
auto BalloonManager::getMenace() -> int { auto BalloonManager::getMenace() -> int {
return std::accumulate(balloons_.begin(), balloons_.end(), 0, [](int sum, const auto &balloon) { return sum + (balloon->isEnabled() ? balloon->getMenace() : 0); }); return std::accumulate(balloons_.begin(), balloons_.end(), 0, [](int sum, const auto& balloon) { return sum + (balloon->isEnabled() ? balloon->getMenace() : 0); });
} }
// Establece el sonido de los globos // Establece el sonido de los globos
void BalloonManager::setSounds(bool value) { void BalloonManager::setSounds(bool value) {
sound_enabled_ = value; sound_enabled_ = value;
for (auto &balloon : balloons_) { for (auto& balloon : balloons_) {
balloon->setSound(value); balloon->setSound(value);
} }
} }
@@ -399,14 +412,14 @@ 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) { void BalloonManager::setBouncingSounds(bool value) {
bouncing_sound_enabled_ = value; bouncing_sound_enabled_ = value;
for (auto &balloon : balloons_) { for (auto& balloon : balloons_) {
balloon->setBouncingSound(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) { void BalloonManager::setPoppingSounds(bool value) {
poping_sound_enabled_ = value; poping_sound_enabled_ = value;
for (auto &balloon : balloons_) { for (auto& balloon : balloons_) {
balloon->setPoppingSound(value); balloon->setPoppingSound(value);
} }
} }