balloon_formation: posat ORDEN en el CAOS de tipos, structs i noms de variables que aci ningú sabia ja qui feia que. De paso llevades coses que sobraven i fetes les coses com toca. Este codi era del CC encara
balloon_formation: els pools de formacions es carreguen ara desde fitxer i ja no hi ha ni llimit de pools ni llimit de formacions per pool falta: revisar les formacions i els pools que algo no quadra
This commit is contained in:
@@ -94,27 +94,18 @@ void BalloonManager::deployBalloonFormation(int stage) {
|
||||
power_ball_counter_ = (power_ball_counter_ > 0) ? (power_ball_counter_ - 1) : 0;
|
||||
|
||||
// Elige una formación enemiga la azar
|
||||
auto formation = rand() % 10;
|
||||
auto formation_id = rand() % 10;
|
||||
|
||||
// Evita repetir la ultima formación enemiga desplegada
|
||||
if (formation == last_balloon_deploy_) {
|
||||
++formation %= 10;
|
||||
if (formation_id == last_balloon_deploy_) {
|
||||
++formation_id %= 10;
|
||||
}
|
||||
|
||||
last_balloon_deploy_ = formation;
|
||||
last_balloon_deploy_ = formation_id;
|
||||
|
||||
const auto SET = balloon_formations_->getSet(stage, formation);
|
||||
const auto NUM_ENEMIES = SET.number_of_balloons;
|
||||
for (int i = 0; i < NUM_ENEMIES; ++i) {
|
||||
auto p = SET.init[i];
|
||||
createBalloon(
|
||||
p.x,
|
||||
p.y,
|
||||
p.type,
|
||||
p.size,
|
||||
p.vel_x,
|
||||
balloon_speed_,
|
||||
(creation_time_enabled_) ? p.creation_counter : 0);
|
||||
const auto BALLOONS = balloon_formations_->getFormationFromPool(stage, formation_id).balloons;
|
||||
for (auto balloon : BALLOONS) {
|
||||
createBalloon(balloon.x, balloon.y, balloon.type, balloon.size, balloon.vel_x, balloon_speed_, (creation_time_enabled_) ? balloon.creation_counter : 0);
|
||||
}
|
||||
|
||||
balloon_deploy_counter_ = 300;
|
||||
@@ -123,21 +114,17 @@ void BalloonManager::deployBalloonFormation(int stage) {
|
||||
}
|
||||
|
||||
// Crea una formación de enemigos específica
|
||||
void BalloonManager::deploySet(int set_number) {
|
||||
const auto SET = balloon_formations_->getSet(set_number);
|
||||
const auto NUM_ENEMIES = SET.number_of_balloons;
|
||||
for (int i = 0; i < NUM_ENEMIES; ++i) {
|
||||
auto balloon = SET.init[i];
|
||||
void BalloonManager::deployFormation(int formation_id) {
|
||||
const auto BALLOONS = balloon_formations_->getFormation(formation_id).balloons;
|
||||
for (auto balloon : BALLOONS) {
|
||||
createBalloon(balloon.x, balloon.y, balloon.type, balloon.size, balloon.vel_x, balloon_speed_, balloon.creation_counter);
|
||||
}
|
||||
}
|
||||
|
||||
// Crea una formación de enemigos específica
|
||||
void BalloonManager::deploySet(int set_number, int y) {
|
||||
const auto SET = balloon_formations_->getSet(set_number);
|
||||
const auto NUM_ENEMIES = SET.number_of_balloons;
|
||||
for (int i = 0; i < NUM_ENEMIES; ++i) {
|
||||
auto balloon = SET.init[i];
|
||||
// Crea una formación de enemigos específica a una altura determinada
|
||||
void BalloonManager::deployFormation(int formation_id, int y) {
|
||||
const auto BALLOONS = balloon_formations_->getFormation(formation_id).balloons;
|
||||
for (auto balloon : BALLOONS) {
|
||||
createBalloon(balloon.x, y, balloon.type, balloon.size, balloon.vel_x, balloon_speed_, balloon.creation_counter);
|
||||
}
|
||||
}
|
||||
@@ -184,7 +171,7 @@ void BalloonManager::createChildBalloon(const std::shared_ptr<Balloon> &balloon,
|
||||
const float VX = direction == "LEFT" ? Balloon::VELX_NEGATIVE : Balloon::VELX_POSITIVE;
|
||||
const auto SIZE = static_cast<Balloon::Size>(static_cast<int>(balloon->getSize()) - 1);
|
||||
const int PARENT_HEIGHT = balloon->getHeight();
|
||||
const int CHILD_HEIGHT = Balloon::SIZE.at(static_cast<int>(balloon->getSize()) - 1);
|
||||
const int CHILD_HEIGHT = Balloon::WIDTH.at(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);
|
||||
|
||||
@@ -209,12 +196,12 @@ void BalloonManager::createChildBalloon(const std::shared_ptr<Balloon> &balloon,
|
||||
void BalloonManager::createPowerBall() {
|
||||
if (can_deploy_balloons_) {
|
||||
constexpr int VALUES = 6;
|
||||
constexpr float POS_Y = -Balloon::SIZE.at(4);
|
||||
constexpr float POS_Y = -Balloon::WIDTH.at(4);
|
||||
constexpr int CREATION_TIME = 0;
|
||||
|
||||
const float LEFT = param.game.play_area.rect.x;
|
||||
const float CENTER = param.game.play_area.center_x - (Balloon::SIZE.at(4) / 2);
|
||||
const float RIGHT = param.game.play_area.rect.w - Balloon::SIZE.at(4);
|
||||
const float CENTER = param.game.play_area.center_x - (Balloon::WIDTH.at(4) / 2);
|
||||
const float RIGHT = param.game.play_area.rect.w - Balloon::WIDTH.at(4);
|
||||
|
||||
const int LUCK = rand() % VALUES;
|
||||
const std::array<float, VALUES> POS_X = {LEFT, LEFT, CENTER, CENTER, RIGHT, RIGHT};
|
||||
@@ -342,14 +329,14 @@ void BalloonManager::normalColorsToAllBalloons() {
|
||||
|
||||
// Crea dos globos gordos
|
||||
void BalloonManager::createTwoBigBalloons() {
|
||||
deploySet(1);
|
||||
deployFormation(1);
|
||||
}
|
||||
|
||||
// Crea una disposición de globos aleatoria
|
||||
void BalloonManager::createRandomBalloons() {
|
||||
const int NUM_BALLOONS = 2 + rand() % 4;
|
||||
for (int i = 0; i < NUM_BALLOONS; ++i) {
|
||||
const float X = param.game.game_area.rect.x + (rand() % static_cast<int>(param.game.game_area.rect.w)) - Balloon::SIZE.at(3);
|
||||
const float X = param.game.game_area.rect.x + (rand() % static_cast<int>(param.game.game_area.rect.w)) - Balloon::WIDTH.at(3);
|
||||
const int Y = param.game.game_area.rect.y + (rand() % 50);
|
||||
const auto SIZE = static_cast<Balloon::Size>(rand() % 4);
|
||||
const float VEL_X = (rand() % 2 == 0) ? Balloon::VELX_POSITIVE : Balloon::VELX_NEGATIVE;
|
||||
|
||||
Reference in New Issue
Block a user