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:
218
source/game.cpp
218
source/game.cpp
@@ -286,39 +286,50 @@ void Game::updateStage()
|
||||
}
|
||||
|
||||
// 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_)
|
||||
{
|
||||
createMessage({paths_.at(2), paths_.at(3)}, Resource::get()->getTexture("game_text_game_over"));
|
||||
JA_FadeOutMusic(1000);
|
||||
balloon_manager_->setSounds(true);
|
||||
}
|
||||
|
||||
game_over_counter_--;
|
||||
|
||||
if (game_over_counter_ == 150)
|
||||
{
|
||||
fade_out_->activate();
|
||||
}
|
||||
createMessage({paths_.at(2), paths_.at(3)}, Resource::get()->getTexture("game_text_game_over"));
|
||||
JA_FadeOutMusic(1000);
|
||||
balloon_manager_->setSounds(true);
|
||||
}
|
||||
|
||||
if (fade_out_->hasEnded())
|
||||
game_over_counter_--;
|
||||
|
||||
if (game_over_counter_ == 150)
|
||||
{
|
||||
if (game_completed_counter_ > 0)
|
||||
{
|
||||
// Los jugadores han completado el juego
|
||||
section::name = section::Name::CREDITS;
|
||||
}
|
||||
else
|
||||
{
|
||||
// La partida ha terminado con la derrota de los jugadores
|
||||
section::name = section::Name::HI_SCORE_TABLE;
|
||||
}
|
||||
fade_out_->activate();
|
||||
}
|
||||
}
|
||||
|
||||
if (fade_out_->hasEnded())
|
||||
{
|
||||
if (game_completed_counter_ > 0)
|
||||
{
|
||||
// Los jugadores han completado el juego
|
||||
section::name = section::Name::CREDITS;
|
||||
}
|
||||
else
|
||||
{
|
||||
// La partida ha terminado con la derrota de los jugadores
|
||||
section::name = section::Name::HI_SCORE_TABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -326,52 +337,68 @@ 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)
|
||||
{
|
||||
// Para la música y elimina todos los globos e items
|
||||
if (game_completed_counter_ == 0)
|
||||
{
|
||||
stopMusic();
|
||||
Stage::number = 9; // Deja el valor dentro de los limites
|
||||
balloon_manager_->destroyAllBalloons(); // Destruye a todos los globos
|
||||
destroyAllItems(); // Destruye todos los items
|
||||
Stage::power = 0; // Vuelve a dejar el poder a cero, por lo que hubiera podido subir al destruir todos los globos
|
||||
}
|
||||
|
||||
// Comienza las celebraciones
|
||||
// Muestra el mensaje de felicitación y da los puntos a los jugadores
|
||||
if (game_completed_counter_ == 200)
|
||||
{
|
||||
createMessage({paths_.at(4), paths_.at(5)}, Resource::get()->getTexture("game_text_congratulations"));
|
||||
createMessage({paths_.at(6), paths_.at(7)}, Resource::get()->getTexture("game_text_1000000_points"));
|
||||
|
||||
for (auto &player : players_)
|
||||
if (player->isPlaying())
|
||||
{
|
||||
player->addScore(1000000);
|
||||
player->setPlayingState(PlayerState::CELEBRATING);
|
||||
}
|
||||
else
|
||||
{
|
||||
player->setPlayingState(PlayerState::GAME_OVER);
|
||||
}
|
||||
|
||||
updateHiScore();
|
||||
}
|
||||
|
||||
// Termina las celebraciones
|
||||
if (game_completed_counter_ == 500)
|
||||
{
|
||||
for (auto &player : players_)
|
||||
if (player->isCelebrating())
|
||||
{
|
||||
player->setPlayingState(player->IsEligibleForHighScore() ? PlayerState::ENTERING_NAME_GAME_COMPLETED : PlayerState::LEAVING_SCREEN);
|
||||
}
|
||||
}
|
||||
|
||||
// Incrementa el contador al final
|
||||
++game_completed_counter_;
|
||||
stopMusic();
|
||||
Stage::number = 9; // Deja el valor dentro de los limites
|
||||
balloon_manager_->destroyAllBalloons(); // Destruye a todos los globos
|
||||
destroyAllItems(); // Destruye todos los items
|
||||
Stage::power = 0; // Vuelve a dejar el poder a cero, por lo que hubiera podido subir al destruir todos los globos
|
||||
}
|
||||
|
||||
// Comienza las celebraciones
|
||||
// Muestra el mensaje de felicitación y da los puntos a los jugadores
|
||||
if (game_completed_counter_ == 200)
|
||||
{
|
||||
createMessage({paths_.at(4), paths_.at(5)}, Resource::get()->getTexture("game_text_congratulations"));
|
||||
createMessage({paths_.at(6), paths_.at(7)}, Resource::get()->getTexture("game_text_1000000_points"));
|
||||
|
||||
for (auto &player : players_)
|
||||
if (player->isPlaying())
|
||||
{
|
||||
player->addScore(1000000);
|
||||
player->setPlayingState(PlayerState::CELEBRATING);
|
||||
}
|
||||
else
|
||||
{
|
||||
player->setPlayingState(PlayerState::GAME_OVER);
|
||||
}
|
||||
|
||||
updateHiScore();
|
||||
}
|
||||
|
||||
// Termina las celebraciones
|
||||
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
|
||||
@@ -886,26 +913,32 @@ void Game::update()
|
||||
#ifdef RECORDING
|
||||
updateRecording();
|
||||
#endif
|
||||
// AQUI HAY QUE PONER UN SWITCH Y HACER EL UPDATE EN FUNCIÓN DEL ESTADO
|
||||
switch (state_)
|
||||
if (!paused_)
|
||||
{
|
||||
case GameState::PLAYING:
|
||||
case GameState::COMPLETED:
|
||||
case GameState::GAME_OVER:
|
||||
updateGameStatePlaying();
|
||||
break;
|
||||
case GameState::FADE_IN:
|
||||
updateGameStateFadeIn();
|
||||
break;
|
||||
case GameState::ENTERING_PLAYER:
|
||||
updateGameStateEnteringPlayer();
|
||||
break;
|
||||
case GameState::SHOWING_GET_READY_MESSAGE:
|
||||
updateGameStateShowingGetReadyMessage();
|
||||
break;
|
||||
switch (state_)
|
||||
{
|
||||
case GameState::COMPLETED:
|
||||
updateGameStateCompleted();
|
||||
break;
|
||||
case GameState::GAME_OVER:
|
||||
updateGameStateGameOver();
|
||||
break;
|
||||
case GameState::PLAYING:
|
||||
updateGameStatePlaying();
|
||||
break;
|
||||
case GameState::FADE_IN:
|
||||
updateGameStateFadeIn();
|
||||
break;
|
||||
case GameState::ENTERING_PLAYER:
|
||||
updateGameStateEnteringPlayer();
|
||||
break;
|
||||
case GameState::SHOWING_GET_READY_MESSAGE:
|
||||
updateGameStateShowingGetReadyMessage();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
checkMusicStatus();
|
||||
@@ -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