canvi de pc
This commit is contained in:
@@ -9,23 +9,23 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
void BalloonFormations::initBalloonFormations() {
|
||||
void BalloonFormations::initFormations() {
|
||||
// Calcular posiciones base
|
||||
const int DEFAULT_POS_Y = param.game.play_area.rect.h - BALLOON_SPAWN_HEIGHT;
|
||||
|
||||
const int X4_0 = param.game.play_area.rect.x;
|
||||
const int X4_100 = param.game.play_area.rect.w - BALLOON_SIZE[3];
|
||||
const int X4_100 = param.game.play_area.rect.w - BALLOON_SIZE.at(3);
|
||||
const int X3_0 = param.game.play_area.rect.x;
|
||||
const int X3_100 = param.game.play_area.rect.w - BALLOON_SIZE[2];
|
||||
const int X3_100 = param.game.play_area.rect.w - BALLOON_SIZE.at(2);
|
||||
const int X2_0 = param.game.play_area.rect.x;
|
||||
const int X2_100 = param.game.play_area.rect.w - BALLOON_SIZE[1];
|
||||
const int X2_100 = param.game.play_area.rect.w - BALLOON_SIZE.at(1);
|
||||
const int X1_0 = param.game.play_area.rect.x;
|
||||
const int X1_50 = param.game.play_area.center_x - (BALLOON_SIZE[0] / 2);
|
||||
const int X1_100 = param.game.play_area.rect.w - BALLOON_SIZE[0];
|
||||
const int X1_50 = param.game.play_area.center_x - (BALLOON_SIZE.at(0) / 2);
|
||||
const int X1_100 = param.game.play_area.rect.w - BALLOON_SIZE.at(0);
|
||||
|
||||
// Variables calculadas para posiciones especiales
|
||||
const int QUARTER1_X4 = param.game.play_area.first_quarter_x - (BALLOON_SIZE[3] / 2);
|
||||
const int QUARTER3_X4 = param.game.play_area.third_quarter_x - (BALLOON_SIZE[3] / 2);
|
||||
const int QUARTER1_X4 = param.game.play_area.first_quarter_x - (BALLOON_SIZE.at(3) / 2);
|
||||
const int QUARTER3_X4 = param.game.play_area.third_quarter_x - (BALLOON_SIZE.at(3) / 2);
|
||||
|
||||
// Mapa de variables para reemplazar en el archivo
|
||||
std::map<std::string, float> variables = {
|
||||
@@ -41,10 +41,10 @@ void BalloonFormations::initBalloonFormations() {
|
||||
{"QUARTER1_X4", QUARTER1_X4},
|
||||
{"QUARTER3_X4", QUARTER3_X4},
|
||||
{"DEFAULT_POS_Y", DEFAULT_POS_Y},
|
||||
{"BALLOON_SIZE_0", BALLOON_SIZE[0]},
|
||||
{"BALLOON_SIZE_1", BALLOON_SIZE[1]},
|
||||
{"BALLOON_SIZE_2", BALLOON_SIZE[2]},
|
||||
{"BALLOON_SIZE_3", BALLOON_SIZE[3]},
|
||||
{"BALLOON_SIZE_0", BALLOON_SIZE.at(0)},
|
||||
{"BALLOON_SIZE_1", BALLOON_SIZE.at(1)},
|
||||
{"BALLOON_SIZE_2", BALLOON_SIZE.at(2)},
|
||||
{"BALLOON_SIZE_3", BALLOON_SIZE.at(3)},
|
||||
{"RIGHT", BALLOON_VELX_POSITIVE},
|
||||
{"LEFT", BALLOON_VELX_NEGATIVE}};
|
||||
|
||||
@@ -71,7 +71,7 @@ auto BalloonFormations::loadFormationsFromFile(const std::string& filename, cons
|
||||
line = trim(line);
|
||||
|
||||
// Saltar líneas vacías y comentarios
|
||||
if (line.empty() || line[0] == '#') {
|
||||
if (line.empty() || line.at(0) == '#') {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -127,31 +127,31 @@ auto BalloonFormations::parseBalloonLine(const std::string& line, const std::map
|
||||
}
|
||||
|
||||
try {
|
||||
int x = evaluateExpression(tokens[0], variables);
|
||||
int desp = evaluateExpression(tokens[1], variables);
|
||||
int y = evaluateExpression(tokens[2], variables);
|
||||
float vel_x = evaluateExpression(tokens[3], variables);
|
||||
int x = evaluateExpression(tokens.at(0), variables);
|
||||
int desp = evaluateExpression(tokens.at(1), variables);
|
||||
int y = evaluateExpression(tokens.at(2), variables);
|
||||
float vel_x = evaluateExpression(tokens.at(3), variables);
|
||||
|
||||
BalloonType type = (tokens[4] == "BALLOON") ? BalloonType::BALLOON : BalloonType::FLOATER;
|
||||
BalloonType type = (tokens.at(4) == "BALLOON") ? BalloonType::BALLOON : BalloonType::FLOATER;
|
||||
|
||||
BalloonSize size;
|
||||
if (tokens[5] == "SIZE1") {
|
||||
if (tokens.at(5) == "SIZE1") {
|
||||
size = BalloonSize::SIZE1;
|
||||
desp = desp * (BALLOON_SIZE[0] + 1);
|
||||
} else if (tokens[5] == "SIZE2") {
|
||||
desp = desp * (BALLOON_SIZE.at(0) + 1);
|
||||
} else if (tokens.at(5) == "SIZE2") {
|
||||
size = BalloonSize::SIZE2;
|
||||
desp = desp * (BALLOON_SIZE[1] + 1);
|
||||
} else if (tokens[5] == "SIZE3") {
|
||||
desp = desp * (BALLOON_SIZE.at(1) + 1);
|
||||
} else if (tokens.at(5) == "SIZE3") {
|
||||
size = BalloonSize::SIZE3;
|
||||
desp = desp * (BALLOON_SIZE[2] + 1);
|
||||
} else if (tokens[5] == "SIZE4") {
|
||||
desp = desp * (BALLOON_SIZE.at(2) + 1);
|
||||
} else if (tokens.at(5) == "SIZE4") {
|
||||
size = BalloonSize::SIZE4;
|
||||
desp = desp * (BALLOON_SIZE[3] + 1);
|
||||
desp = desp * (BALLOON_SIZE.at(3) + 1);
|
||||
} else {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
int creation_time = CREATION_TIME + evaluateExpression(tokens[6], variables);
|
||||
int creation_time = CREATION_TIME + evaluateExpression(tokens.at(6), variables);
|
||||
|
||||
return BalloonFormationParams(x + desp, y, vel_x, type, size, creation_time);
|
||||
} catch (const std::exception&) {
|
||||
@@ -163,7 +163,7 @@ auto BalloonFormations::evaluateExpression(const std::string& expr, const std::m
|
||||
std::string trimmed_expr = trim(expr);
|
||||
|
||||
// Si es un número directo
|
||||
if ((std::isdigit(trimmed_expr[0]) != 0) || (trimmed_expr[0] == '-' && trimmed_expr.length() > 1)) {
|
||||
if ((std::isdigit(trimmed_expr.at(0)) != 0) || (trimmed_expr.at(0) == '-' && trimmed_expr.length() > 1)) {
|
||||
return std::stoi(trimmed_expr);
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ auto BalloonFormations::evaluateExpression(const std::string& expr, const std::m
|
||||
auto BalloonFormations::evaluateSimpleExpression(const std::string& expr, const std::map<std::string, float>& variables) -> float {
|
||||
// Buscar operadores (+, -, *, /)
|
||||
for (size_t i = 1; i < expr.length(); ++i) {
|
||||
char op = expr[i];
|
||||
char op = expr.at(i);
|
||||
if (op == '+' || op == '-' || op == '*' || op == '/') {
|
||||
std::string left = trim(expr.substr(0, i));
|
||||
std::string right = trim(expr.substr(i + 1));
|
||||
@@ -219,16 +219,16 @@ void BalloonFormations::createFloaterVariants() {
|
||||
// Crear variantes flotantes de las primeras 50 formaciones
|
||||
for (size_t k = 0; k < 50 && k < balloon_formation_.size(); k++) {
|
||||
std::vector<BalloonFormationParams> floater_params;
|
||||
floater_params.reserve(balloon_formation_[k].number_of_balloons);
|
||||
floater_params.reserve(balloon_formation_.at(k).number_of_balloons);
|
||||
|
||||
for (int i = 0; i < balloon_formation_[k].number_of_balloons; i++) {
|
||||
const auto& original = balloon_formation_[k].init[i];
|
||||
for (int i = 0; i < balloon_formation_.at(k).number_of_balloons; i++) {
|
||||
const auto& original = balloon_formation_.at(k).init.at(i);
|
||||
floater_params.emplace_back(
|
||||
original.x, original.y, original.vel_x, BalloonType::FLOATER, original.size, original.creation_counter);
|
||||
}
|
||||
|
||||
balloon_formation_[k + 50] = BalloonFormationUnit(
|
||||
balloon_formation_[k].number_of_balloons, floater_params);
|
||||
balloon_formation_.at(k + 50) = BalloonFormationUnit(
|
||||
balloon_formation_.at(k).number_of_balloons, floater_params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ void BalloonFormations::addTestFormation() {
|
||||
{90, -BLOCK, 0, BalloonType::FLOATER, BalloonSize::SIZE3, 200},
|
||||
{140, -BLOCK, 0, BalloonType::FLOATER, BalloonSize::SIZE4, 200}};
|
||||
|
||||
balloon_formation_[99] = BalloonFormationUnit(4, test_params);
|
||||
balloon_formation_.at(99) = BalloonFormationUnit(4, test_params);
|
||||
}
|
||||
|
||||
void BalloonFormations::loadDefaultFormations() {
|
||||
@@ -248,7 +248,7 @@ void BalloonFormations::loadDefaultFormations() {
|
||||
|
||||
const int DEFAULT_POS_Y = param.game.play_area.rect.h - BALLOON_SPAWN_HEIGHT;
|
||||
const int X4_0 = param.game.play_area.rect.x;
|
||||
const int X4_100 = param.game.play_area.rect.w - BALLOON_SIZE[3];
|
||||
const int X4_100 = param.game.play_area.rect.w - BALLOON_SIZE.at(3);
|
||||
|
||||
// Formación básica #00
|
||||
std::vector<BalloonFormationParams> basic_formation = {
|
||||
@@ -258,7 +258,7 @@ void BalloonFormations::loadDefaultFormations() {
|
||||
}
|
||||
|
||||
// Inicializa los conjuntos de formaciones
|
||||
void BalloonFormations::initBalloonFormationPools() {
|
||||
void BalloonFormations::initFormationPools() {
|
||||
// Reserva espacio para cada pool de formaciones
|
||||
balloon_formation_pool_.resize(NUMBER_OF_SETS_PER_POOL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user