Separats els estats de joc completat i joc acabat del estat joc jugantse
Al completar el joc, el missatge de game over ja no ix fins que desapareixen els textos anteriors
This commit is contained in:
@@ -286,10 +286,22 @@ void Game::updateStage()
|
||||
}
|
||||
|
||||
// Actualiza el estado de fin de la partida
|
||||
void Game::updateGameOverState()
|
||||
{
|
||||
if (state_ == GameState::GAME_OVER)
|
||||
void Game::updateGameStateGameOver()
|
||||
{
|
||||
fade_out_->update();
|
||||
updatePlayers();
|
||||
updateScoreboard();
|
||||
updateBackground();
|
||||
balloon_manager_->update();
|
||||
tabe_->update();
|
||||
updateBullets();
|
||||
updateItems();
|
||||
updateSmartSprites();
|
||||
updatePathSprites();
|
||||
updateTimeStopped();
|
||||
checkBulletBalloonCollision();
|
||||
cleanVectors();
|
||||
|
||||
if (game_over_counter_ > 0)
|
||||
{
|
||||
if (game_over_counter_ == GAME_OVER_COUNTER_)
|
||||
@@ -321,13 +333,21 @@ void Game::updateGameOverState()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Gestiona eventos para el estado del final del juego
|
||||
void Game::updateGameStateCompleted()
|
||||
{
|
||||
if (state_ == GameState::COMPLETED)
|
||||
{
|
||||
updatePlayers();
|
||||
updateScoreboard();
|
||||
updateBackground();
|
||||
balloon_manager_->update();
|
||||
tabe_->update();
|
||||
updateBullets();
|
||||
updateItems();
|
||||
updateSmartSprites();
|
||||
updatePathSprites();
|
||||
cleanVectors();
|
||||
|
||||
// Para la música y elimina todos los globos e items
|
||||
if (game_completed_counter_ == 0)
|
||||
{
|
||||
@@ -363,16 +383,23 @@ void Game::updateGameStateCompleted()
|
||||
if (game_completed_counter_ == 500)
|
||||
{
|
||||
for (auto &player : players_)
|
||||
{
|
||||
if (player->isCelebrating())
|
||||
{
|
||||
player->setPlayingState(player->IsEligibleForHighScore() ? PlayerState::ENTERING_NAME_GAME_COMPLETED : PlayerState::LEAVING_SCREEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Si los jugadores ya no estan y no quedan mensajes en pantalla
|
||||
if (allPlayersAreGameOver() && path_sprites_.size() == 0)
|
||||
{
|
||||
state_ = GameState::GAME_OVER;
|
||||
}
|
||||
|
||||
// Incrementa el contador al final
|
||||
++game_completed_counter_;
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba el estado del juego
|
||||
void Game::checkState()
|
||||
@@ -886,12 +913,17 @@ void Game::update()
|
||||
#ifdef RECORDING
|
||||
updateRecording();
|
||||
#endif
|
||||
// AQUI HAY QUE PONER UN SWITCH Y HACER EL UPDATE EN FUNCIÓN DEL ESTADO
|
||||
if (!paused_)
|
||||
{
|
||||
switch (state_)
|
||||
{
|
||||
case GameState::PLAYING:
|
||||
case GameState::COMPLETED:
|
||||
updateGameStateCompleted();
|
||||
break;
|
||||
case GameState::GAME_OVER:
|
||||
updateGameStateGameOver();
|
||||
break;
|
||||
case GameState::PLAYING:
|
||||
updateGameStatePlaying();
|
||||
break;
|
||||
case GameState::FADE_IN:
|
||||
@@ -907,6 +939,7 @@ void Game::update()
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
checkMusicStatus();
|
||||
screen_->update();
|
||||
@@ -1855,12 +1888,11 @@ void Game::updateGameStateShowingGetReadyMessage()
|
||||
void Game::updateGameStatePlaying()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (auto_pop_balloons_ && state_ == GameState::PLAYING)
|
||||
if (auto_pop_balloons_)
|
||||
{
|
||||
Stage::addPower(5);
|
||||
Stage::addPower(20);
|
||||
}
|
||||
#endif
|
||||
fade_out_->update();
|
||||
updatePlayers();
|
||||
checkPlayersStatusPlaying();
|
||||
updateScoreboard();
|
||||
@@ -1870,8 +1902,6 @@ void Game::updateGameStatePlaying()
|
||||
updateBullets();
|
||||
updateItems();
|
||||
updateStage();
|
||||
updateGameOverState();
|
||||
updateGameStateCompleted();
|
||||
updateSmartSprites();
|
||||
updatePathSprites();
|
||||
updateTimeStopped();
|
||||
|
||||
@@ -200,7 +200,7 @@ private:
|
||||
void updateStage();
|
||||
|
||||
// Actualiza el estado de fin de la partida
|
||||
void updateGameOverState();
|
||||
void updateGameStateGameOver();
|
||||
|
||||
// Destruye todos los items
|
||||
void destroyAllItems();
|
||||
|
||||
Reference in New Issue
Block a user