fix: la variable ballonsPopped no estava inicialitzada i passaven coses rares
This commit is contained in:
@@ -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
|
// Inicializa los vectores con los datos para la demo
|
||||||
if (demo)
|
if (demo)
|
||||||
{
|
{ // Aleatoriza la asignación del fichero
|
||||||
// Aleatoriza la asignación del fichero
|
|
||||||
const int index1 = rand() % 2;
|
const int index1 = rand() % 2;
|
||||||
const int index2 = (index1 + 1) % 2;
|
const int index2 = (index1 + 1) % 2;
|
||||||
loadDemoFile(asset->get("demo1.bin"), &this->demo.dataFile[index1]);
|
loadDemoFile(asset->get("demo1.bin"), &this->demo.dataFile[index1]);
|
||||||
@@ -186,25 +185,25 @@ void Game::init(int playerID)
|
|||||||
powerBallEnabled = false;
|
powerBallEnabled = false;
|
||||||
powerBallCounter = 0;
|
powerBallCounter = 0;
|
||||||
coffeeMachineEnabled = false;
|
coffeeMachineEnabled = false;
|
||||||
|
balloonsPopped = 0;
|
||||||
|
|
||||||
// Inicializa las variables para el modo DEMO
|
// Inicializa las variables para el modo DEMO
|
||||||
if (demo.enabled)
|
if (demo.enabled)
|
||||||
{
|
{
|
||||||
// Selecciona una pantalla al azar
|
// Selecciona una pantalla al azar
|
||||||
const int num = rand() % 2;
|
const int demos = 3;
|
||||||
if (num == 0)
|
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;
|
balloonsPopped += enemyFormations->getStage(i).powerToComplete;
|
||||||
currentStage = 3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
balloonsPopped = 1800;
|
|
||||||
currentStage = 6;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activa o no al otro jugador
|
// Activa o no al otro jugador
|
||||||
if (rand() % 3 == 0)
|
if (rand() % 2 == 0)
|
||||||
{
|
{
|
||||||
const int otherPlayer = playerID == 1 ? 2 : 1;
|
const int otherPlayer = playerID == 1 ? 2 : 1;
|
||||||
players[otherPlayer - 1]->enable(true);
|
players[otherPlayer - 1]->enable(true);
|
||||||
@@ -232,13 +231,6 @@ void Game::init(int playerID)
|
|||||||
|
|
||||||
initPaths();
|
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;
|
totalPowerToCompleteGame = 0;
|
||||||
for (int i = 0; i < 10; ++i)
|
for (int i = 0; i < 10; ++i)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user