fix: arreglats mil mini bugs d'estes ultimes coses que he estat fent. El cas es que el joc es veu igual pero porte dos matins aci fent el mongol.
This commit is contained in:
@@ -36,22 +36,22 @@ void BalloonFormations::initFormations() {
|
||||
|
||||
// Mapa de variables para reemplazar en el archivo
|
||||
std::map<std::string, float> variables = {
|
||||
{"X1_0", X0_0},
|
||||
{"X1_50", X0_50},
|
||||
{"X1_100", X0_100},
|
||||
{"X2_0", X1_0},
|
||||
{"X2_100", X1_100},
|
||||
{"X3_0", X2_0},
|
||||
{"X3_100", X2_100},
|
||||
{"X4_0", X3_0},
|
||||
{"X4_100", X3_100},
|
||||
{"X0_0", X0_0},
|
||||
{"X0_50", X0_50},
|
||||
{"X0_100", X0_100},
|
||||
{"X1_0", X1_0},
|
||||
{"X1_100", X1_100},
|
||||
{"X2_0", X2_0},
|
||||
{"X2_100", X2_100},
|
||||
{"X3_0", X3_0},
|
||||
{"X3_100", X3_100},
|
||||
{"X3_25", X3_25},
|
||||
{"X3_75", X3_75},
|
||||
{"DEFAULT_POS_Y", DEFAULT_POS_Y},
|
||||
{"RIGHT", Balloon::VELX_POSITIVE},
|
||||
{"LEFT", Balloon::VELX_NEGATIVE}};
|
||||
|
||||
if (!loadFormationsFromFile(Asset::get()->get("balloon_formations.txt"), variables)) {
|
||||
if (!loadFormationsFromFile(Asset::get()->get("formations.txt"), variables)) {
|
||||
// Fallback: cargar formaciones por defecto si falla la carga del archivo
|
||||
loadDefaultFormations();
|
||||
}
|
||||
@@ -262,7 +262,7 @@ void BalloonFormations::loadDefaultFormations() {
|
||||
|
||||
void BalloonFormations::initFormationPools() {
|
||||
// Intentar cargar pools desde archivo
|
||||
if (!loadPoolsFromFile(Asset::get()->get("balloon_pools.txt"))) {
|
||||
if (!loadPoolsFromFile(Asset::get()->get("pools.txt"))) {
|
||||
// Fallback: cargar pools por defecto si falla la carga del archivo
|
||||
loadDefaultPools();
|
||||
}
|
||||
|
||||
@@ -78,42 +78,44 @@ void BalloonManager::render() {
|
||||
explosions_->render();
|
||||
}
|
||||
|
||||
// Crea una formación de enemigos
|
||||
void BalloonManager::deployBalloonFormation(int stage) {
|
||||
// Crea una formación de globos
|
||||
void BalloonManager::deployRandomFormation(int stage) {
|
||||
// Solo despliega una formación enemiga si ha pasado cierto tiempo desde la última
|
||||
if (balloon_deploy_counter_ == 0) {
|
||||
// En este punto se decide entre crear una powerball o una formación enemiga
|
||||
if ((rand() % 100 < 15) && (canPowerBallBeCreated())) {
|
||||
// Crea una powerball
|
||||
createPowerBall();
|
||||
|
||||
// Da un poco de margen para que se creen mas enemigos
|
||||
balloon_deploy_counter_ = 10;
|
||||
createPowerBall(); // Crea una powerball
|
||||
balloon_deploy_counter_ = 10; // Da un poco de margen para que se creen mas globos
|
||||
} else {
|
||||
// Decrementa el contador de despliegues enemigos de la PowerBall
|
||||
power_ball_counter_ = (power_ball_counter_ > 0) ? (power_ball_counter_ - 1) : 0;
|
||||
// Decrementa el contador de despliegues de globos necesarios para la siguiente PowerBall
|
||||
if (power_ball_counter_ > 0) {
|
||||
--power_ball_counter_;
|
||||
}
|
||||
|
||||
// Elige una formación enemiga la azar
|
||||
auto formation_id = rand() % 10;
|
||||
const auto NUM_FORMATIONS = balloon_formations_->getPoolSize(stage);
|
||||
int formation_id = rand() % NUM_FORMATIONS;
|
||||
|
||||
// Evita repetir la ultima formación enemiga desplegada
|
||||
if (formation_id == last_balloon_deploy_) {
|
||||
++formation_id %= 10;
|
||||
++formation_id %= NUM_FORMATIONS;
|
||||
}
|
||||
|
||||
last_balloon_deploy_ = formation_id;
|
||||
|
||||
// Crea los globos de la formación
|
||||
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);
|
||||
}
|
||||
|
||||
// Reinicia el contador para el próximo despliegue
|
||||
balloon_deploy_counter_ = 300;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Crea una formación de enemigos específica
|
||||
// Crea una formación de globos específica
|
||||
void BalloonManager::deployFormation(int formation_id) {
|
||||
const auto BALLOONS = balloon_formations_->getFormation(formation_id).balloons;
|
||||
for (auto balloon : BALLOONS) {
|
||||
@@ -121,7 +123,7 @@ void BalloonManager::deployFormation(int formation_id) {
|
||||
}
|
||||
}
|
||||
|
||||
// Crea una formación de enemigos específica a una altura determinada
|
||||
// Crea una formación de globos 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) {
|
||||
|
||||
@@ -33,9 +33,9 @@ class BalloonManager {
|
||||
void freeBalloons(); // Libera globos que ya no sirven
|
||||
|
||||
// Creación de formaciones enemigas
|
||||
void deployBalloonFormation(int stage); // Crea una formación de enemigos aleatoria
|
||||
void deployFormation(int set); // Crea una formación específica
|
||||
void deployFormation(int set, int y); // Crea una formación específica con coordenadas
|
||||
void deployRandomFormation(int stage); // Crea una formación de globos aleatoria
|
||||
void deployFormation(int formation_id); // Crea una formación específica
|
||||
void deployFormation(int formation_id, int y); // Crea una formación específica con coordenadas
|
||||
|
||||
// Creación de globos
|
||||
auto createBalloon(float x, int y, Balloon::Type type, Balloon::Size size, float velx, float speed, int creation_timer) -> std::shared_ptr<Balloon>; // Crea un nuevo globo
|
||||
|
||||
@@ -259,8 +259,8 @@ void Director::setFileList() {
|
||||
Asset::get()->add(PREFIX + "/data/config/demo1.bin", AssetType::DEMODATA);
|
||||
Asset::get()->add(PREFIX + "/data/config/demo2.bin", AssetType::DEMODATA);
|
||||
Asset::get()->add(PREFIX + "/data/config/gamecontrollerdb.txt", AssetType::DATA);
|
||||
Asset::get()->add(PREFIX + "/data/config/balloon_formations.txt", AssetType::DATA);
|
||||
Asset::get()->add(PREFIX + "/data/config/pool_formations.txt", AssetType::DATA);
|
||||
Asset::get()->add(PREFIX + "/data/config/formations.txt", AssetType::DATA);
|
||||
Asset::get()->add(PREFIX + "/data/config/pools.txt", AssetType::DATA);
|
||||
|
||||
// Musicas
|
||||
Asset::get()->add(PREFIX + "/data/music/intro.ogg", AssetType::MUSIC);
|
||||
|
||||
@@ -28,7 +28,7 @@ Player::Player(int id, float x, int y, bool demo, SDL_FRect &play_area, std::vec
|
||||
// Configura objetos
|
||||
player_sprite_->getTexture()->setPalette(coffees_);
|
||||
power_sprite_->getTexture()->setAlpha(224);
|
||||
power_up_desp_x_ = (power_sprite_->getWidth() - player_sprite_->getWidth()) / 2;
|
||||
power_up_x_offset_ = (power_sprite_->getWidth() - player_sprite_->getWidth()) / 2;
|
||||
power_sprite_->setPosY(y - (power_sprite_->getHeight() - player_sprite_->getHeight()));
|
||||
|
||||
// Inicializa variables
|
||||
@@ -846,7 +846,7 @@ auto Player::getRecordNamePos() const -> int {
|
||||
void Player::shiftSprite() {
|
||||
player_sprite_->setPosX(pos_x_);
|
||||
player_sprite_->setPosY(pos_y_);
|
||||
power_sprite_->setPosX(getPosX() - power_up_desp_x_);
|
||||
power_sprite_->setPosX(getPosX() - power_up_x_offset_);
|
||||
}
|
||||
|
||||
// Hace sonar un sonido
|
||||
|
||||
@@ -198,7 +198,7 @@ class Player {
|
||||
int coffees_ = 0; // Indica cuántos cafés lleva acumulados
|
||||
bool power_up_ = false; // Indica si el jugador tiene activo el modo PowerUp
|
||||
int power_up_counter_ = POWERUP_COUNTER; // Temporizador para el modo PowerUp
|
||||
int power_up_desp_x_ = 0; // Desplazamiento del sprite de PowerUp respecto al sprite del jugador
|
||||
int power_up_x_offset_ = 0; // Desplazamiento del sprite de PowerUp respecto al sprite del jugador
|
||||
Circle collider_ = Circle(0, 0, 9); // Círculo de colisión del jugador
|
||||
int continue_counter_ = 10; // Contador para poder continuar
|
||||
Uint32 continue_ticks_ = 0; // Variable para poder cambiar el contador de continue en función del tiempo
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <cstdlib> // Para rand, size_t
|
||||
#include <functional> // Para function
|
||||
#include <iterator> // Para distance, size
|
||||
#include <iostream> // Para std::cout, std::endl
|
||||
|
||||
#include "asset.h" // Para Asset
|
||||
#include "audio.h" // Para Audio
|
||||
@@ -1744,11 +1745,8 @@ void Game::updateMenace() {
|
||||
|
||||
// Si el nivel de amenza es inferior al umbral
|
||||
if (menace_current_ < menace_threshold_) {
|
||||
// Crea una formación de enemigos
|
||||
balloon_manager_->deployBalloonFormation(Stage::number);
|
||||
|
||||
// Recalcula el nivel de amenaza con el nuevo globo
|
||||
evaluateAndSetMenace();
|
||||
balloon_manager_->deployRandomFormation(Stage::number); // Crea una formación aleatoria de globos
|
||||
evaluateAndSetMenace(); // Recalcula el nivel de amenaza con el nuevo globo
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1772,7 +1770,7 @@ void Game::checkAndUpdateBalloonSpeed() {
|
||||
if (balloon_manager_->getBalloonSpeed() == Balloon::SPEED.at(i) && PERCENT > THRESHOLDS.at(i)) {
|
||||
// Sube la velocidad al siguiente nivel (i + 1)
|
||||
balloon_manager_->setBalloonSpeed(Balloon::SPEED.at(i + 1));
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1835,6 +1833,7 @@ void Game::checkServiceMenu() {
|
||||
#ifdef _DEBUG
|
||||
// Comprueba los eventos en el modo DEBUG
|
||||
void Game::checkDebugEvents(const SDL_Event &event) {
|
||||
static int formation_id = 0;
|
||||
if (event.type == SDL_EVENT_KEY_DOWN && static_cast<int>(event.key.repeat) == 0) {
|
||||
switch (event.key.key) {
|
||||
case SDLK_1: // Crea una powerball
|
||||
@@ -1896,6 +1895,20 @@ void Game::checkDebugEvents(const SDL_Event &event) {
|
||||
tabe_->enable();
|
||||
break;
|
||||
}
|
||||
case SDLK_KP_PLUS:{
|
||||
++formation_id;
|
||||
balloon_manager_->destroyAllBalloons();
|
||||
balloon_manager_->deployFormation(formation_id);
|
||||
std::cout << formation_id << std::endl;
|
||||
break;
|
||||
}
|
||||
case SDLK_KP_MINUS:{
|
||||
--formation_id;
|
||||
balloon_manager_->destroyAllBalloons();
|
||||
balloon_manager_->deployFormation(formation_id);
|
||||
std::cout << formation_id << std::endl;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ class Game {
|
||||
// bool paused_by_service_menu_ = false;
|
||||
float difficulty_score_multiplier_; // Multiplicador de puntos en función de la dificultad
|
||||
int counter_ = 0; // Contador para el juego
|
||||
int game_completed_counter_ = 0; // Contador para el tramo final, cuando se ha completado la partida y ya no aparecen más enemigos
|
||||
int game_completed_counter_ = 0; // Contador para el tramo final, cuando se ha completado la partida y ya no aparecen más globos
|
||||
int game_over_counter_ = GAME_OVER_COUNTER; // Contador para el estado de fin de partida
|
||||
int time_stopped_counter_ = 0; // Temporizador para llevar la cuenta del tiempo detenido
|
||||
int total_power_to_complete_game_; // La suma del poder necesario para completar todas las fases
|
||||
|
||||
@@ -111,7 +111,7 @@ void Instructions::updateSprites() {
|
||||
|
||||
// Rellena la textura de texto
|
||||
void Instructions::fillTexture() {
|
||||
const int DESP_X = param.game.item_size + 8;
|
||||
const int X_OFFSET = param.game.item_size + 8;
|
||||
|
||||
// Modifica el renderizador para pintar en la textura
|
||||
auto *temp = SDL_GetRenderTarget(renderer_);
|
||||
@@ -148,7 +148,7 @@ void Instructions::fillTexture() {
|
||||
const int L = text_->lenght(desc);
|
||||
lenght = L > lenght ? L : lenght;
|
||||
}
|
||||
const int ANCHOR_ITEM = (param.game.width - (lenght + DESP_X)) / 2;
|
||||
const int ANCHOR_ITEM = (param.game.width - (lenght + X_OFFSET)) / 2;
|
||||
|
||||
auto caption_style = TextStyle(ORANGE_TEXT_COLOR, SHADOW_TEXT_COLOR);
|
||||
auto text_style = TextStyle(NO_TEXT_COLOR, SHADOW_TEXT_COLOR);
|
||||
@@ -167,11 +167,11 @@ void Instructions::fillTexture() {
|
||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR | TEXT_SHADOW, param.game.game_area.center_x, ANCHOR2, Lang::getText("[INSTRUCTIONS] 06"), caption_style);
|
||||
|
||||
const int ANCHOR3 = ANCHOR2 + SPACE_POST_HEADER;
|
||||
text_->writeShadowed(ANCHOR_ITEM + DESP_X, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 0, Lang::getText("[INSTRUCTIONS] 07"), SHADOW_TEXT_COLOR);
|
||||
text_->writeShadowed(ANCHOR_ITEM + DESP_X, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 1, Lang::getText("[INSTRUCTIONS] 08"), SHADOW_TEXT_COLOR);
|
||||
text_->writeShadowed(ANCHOR_ITEM + DESP_X, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 2, Lang::getText("[INSTRUCTIONS] 09"), SHADOW_TEXT_COLOR);
|
||||
text_->writeShadowed(ANCHOR_ITEM + DESP_X, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 3, Lang::getText("[INSTRUCTIONS] 10"), SHADOW_TEXT_COLOR);
|
||||
text_->writeShadowed(ANCHOR_ITEM + DESP_X, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 4, Lang::getText("[INSTRUCTIONS] 11"), SHADOW_TEXT_COLOR);
|
||||
text_->writeShadowed(ANCHOR_ITEM + X_OFFSET, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 0, Lang::getText("[INSTRUCTIONS] 07"), SHADOW_TEXT_COLOR);
|
||||
text_->writeShadowed(ANCHOR_ITEM + X_OFFSET, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 1, Lang::getText("[INSTRUCTIONS] 08"), SHADOW_TEXT_COLOR);
|
||||
text_->writeShadowed(ANCHOR_ITEM + X_OFFSET, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 2, Lang::getText("[INSTRUCTIONS] 09"), SHADOW_TEXT_COLOR);
|
||||
text_->writeShadowed(ANCHOR_ITEM + X_OFFSET, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 3, Lang::getText("[INSTRUCTIONS] 10"), SHADOW_TEXT_COLOR);
|
||||
text_->writeShadowed(ANCHOR_ITEM + X_OFFSET, ANCHOR3 + SPACE_BETWEEN_ITEM_LINES * 4, Lang::getText("[INSTRUCTIONS] 11"), SHADOW_TEXT_COLOR);
|
||||
|
||||
// Deja el renderizador como estaba
|
||||
SDL_SetRenderTarget(renderer_, temp);
|
||||
|
||||
Reference in New Issue
Block a user