diff --git a/source/game.cpp b/source/game.cpp index 5499047..0b4ec40 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -35,8 +35,7 @@ Game::Game(int playerID, int currentStage, Screen *screen, Asset *asset, Lang *l // Inicializa los vectores con los datos para la demo if (demo) - { - // Aleatoriza la asignación del fichero + { // Aleatoriza la asignación del fichero const int index1 = rand() % 2; const int index2 = (index1 + 1) % 2; loadDemoFile(asset->get("demo1.bin"), &this->demo.dataFile[index1]); @@ -186,25 +185,25 @@ void Game::init(int playerID) powerBallEnabled = false; powerBallCounter = 0; coffeeMachineEnabled = false; + balloonsPopped = 0; // Inicializa las variables para el modo DEMO if (demo.enabled) { // Selecciona una pantalla al azar - const int num = rand() % 2; - if (num == 0) + const int demos = 3; + const int demo = rand() % demos; + const int stages[demos] = {0, 3, 5}; + currentStage = stages[demo]; + + // Actualiza el numero de globos explotados según la fase de la demo + for (int i = 0; i < currentStage; ++i) { - balloonsPopped = 1000; - currentStage = 3; - } - else - { - balloonsPopped = 1800; - currentStage = 6; + balloonsPopped += enemyFormations->getStage(i).powerToComplete; } // Activa o no al otro jugador - if (rand() % 3 == 0) + if (rand() % 2 == 0) { const int otherPlayer = playerID == 1 ? 2 : 1; players[otherPlayer - 1]->enable(true); @@ -232,13 +231,6 @@ void Game::init(int playerID) initPaths(); - // En caso de continuar o empezar en una fase que no sea la primera, actualiza las variables siguientes - /*balloonsPopped = 0; - for (int i = 0; i < currentStage; ++i) - { - balloonsPopped += enemyFormations->getStage(i).powerToComplete; - }*/ - totalPowerToCompleteGame = 0; for (int i = 0; i < 10; ++i) {