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
|
// Actualiza el estado de fin de la partida
|
||||||
void Game::updateGameOverState()
|
void Game::updateGameStateGameOver()
|
||||||
{
|
|
||||||
if (state_ == GameState::GAME_OVER)
|
|
||||||
{
|
{
|
||||||
|
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_ > 0)
|
||||||
{
|
{
|
||||||
if (game_over_counter_ == GAME_OVER_COUNTER_)
|
if (game_over_counter_ == GAME_OVER_COUNTER_)
|
||||||
@@ -321,13 +333,21 @@ void Game::updateGameOverState()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Gestiona eventos para el estado del final del juego
|
// Gestiona eventos para el estado del final del juego
|
||||||
void Game::updateGameStateCompleted()
|
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
|
// Para la música y elimina todos los globos e items
|
||||||
if (game_completed_counter_ == 0)
|
if (game_completed_counter_ == 0)
|
||||||
{
|
{
|
||||||
@@ -363,16 +383,23 @@ void Game::updateGameStateCompleted()
|
|||||||
if (game_completed_counter_ == 500)
|
if (game_completed_counter_ == 500)
|
||||||
{
|
{
|
||||||
for (auto &player : players_)
|
for (auto &player : players_)
|
||||||
|
{
|
||||||
if (player->isCelebrating())
|
if (player->isCelebrating())
|
||||||
{
|
{
|
||||||
player->setPlayingState(player->IsEligibleForHighScore() ? PlayerState::ENTERING_NAME_GAME_COMPLETED : PlayerState::LEAVING_SCREEN);
|
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
|
// Incrementa el contador al final
|
||||||
++game_completed_counter_;
|
++game_completed_counter_;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba el estado del juego
|
// Comprueba el estado del juego
|
||||||
void Game::checkState()
|
void Game::checkState()
|
||||||
@@ -886,12 +913,17 @@ void Game::update()
|
|||||||
#ifdef RECORDING
|
#ifdef RECORDING
|
||||||
updateRecording();
|
updateRecording();
|
||||||
#endif
|
#endif
|
||||||
// AQUI HAY QUE PONER UN SWITCH Y HACER EL UPDATE EN FUNCIÓN DEL ESTADO
|
if (!paused_)
|
||||||
|
{
|
||||||
switch (state_)
|
switch (state_)
|
||||||
{
|
{
|
||||||
case GameState::PLAYING:
|
|
||||||
case GameState::COMPLETED:
|
case GameState::COMPLETED:
|
||||||
|
updateGameStateCompleted();
|
||||||
|
break;
|
||||||
case GameState::GAME_OVER:
|
case GameState::GAME_OVER:
|
||||||
|
updateGameStateGameOver();
|
||||||
|
break;
|
||||||
|
case GameState::PLAYING:
|
||||||
updateGameStatePlaying();
|
updateGameStatePlaying();
|
||||||
break;
|
break;
|
||||||
case GameState::FADE_IN:
|
case GameState::FADE_IN:
|
||||||
@@ -907,6 +939,7 @@ void Game::update()
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
checkMusicStatus();
|
checkMusicStatus();
|
||||||
screen_->update();
|
screen_->update();
|
||||||
@@ -1855,12 +1888,11 @@ void Game::updateGameStateShowingGetReadyMessage()
|
|||||||
void Game::updateGameStatePlaying()
|
void Game::updateGameStatePlaying()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (auto_pop_balloons_ && state_ == GameState::PLAYING)
|
if (auto_pop_balloons_)
|
||||||
{
|
{
|
||||||
Stage::addPower(5);
|
Stage::addPower(20);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
fade_out_->update();
|
|
||||||
updatePlayers();
|
updatePlayers();
|
||||||
checkPlayersStatusPlaying();
|
checkPlayersStatusPlaying();
|
||||||
updateScoreboard();
|
updateScoreboard();
|
||||||
@@ -1870,8 +1902,6 @@ void Game::updateGameStatePlaying()
|
|||||||
updateBullets();
|
updateBullets();
|
||||||
updateItems();
|
updateItems();
|
||||||
updateStage();
|
updateStage();
|
||||||
updateGameOverState();
|
|
||||||
updateGameStateCompleted();
|
|
||||||
updateSmartSprites();
|
updateSmartSprites();
|
||||||
updatePathSprites();
|
updatePathSprites();
|
||||||
updateTimeStopped();
|
updateTimeStopped();
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ private:
|
|||||||
void updateStage();
|
void updateStage();
|
||||||
|
|
||||||
// Actualiza el estado de fin de la partida
|
// Actualiza el estado de fin de la partida
|
||||||
void updateGameOverState();
|
void updateGameStateGameOver();
|
||||||
|
|
||||||
// Destruye todos los items
|
// Destruye todos los items
|
||||||
void destroyAllItems();
|
void destroyAllItems();
|
||||||
|
|||||||
Reference in New Issue
Block a user