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
|
// 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);
|
||||||
createMessage({paths_.at(2), paths_.at(3)}, Resource::get()->getTexture("game_text_game_over"));
|
balloon_manager_->setSounds(true);
|
||||||
JA_FadeOutMusic(1000);
|
|
||||||
balloon_manager_->setSounds(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
game_over_counter_--;
|
|
||||||
|
|
||||||
if (game_over_counter_ == 150)
|
|
||||||
{
|
|
||||||
fade_out_->activate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fade_out_->hasEnded())
|
game_over_counter_--;
|
||||||
|
|
||||||
|
if (game_over_counter_ == 150)
|
||||||
{
|
{
|
||||||
if (game_completed_counter_ > 0)
|
fade_out_->activate();
|
||||||
{
|
}
|
||||||
// Los jugadores han completado el juego
|
}
|
||||||
section::name = section::Name::CREDITS;
|
|
||||||
}
|
if (fade_out_->hasEnded())
|
||||||
else
|
{
|
||||||
{
|
if (game_completed_counter_ > 0)
|
||||||
// La partida ha terminado con la derrota de los jugadores
|
{
|
||||||
section::name = section::Name::HI_SCORE_TABLE;
|
// 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
|
// 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
|
||||||
|
if (game_completed_counter_ == 0)
|
||||||
{
|
{
|
||||||
// Para la música y elimina todos los globos e items
|
stopMusic();
|
||||||
if (game_completed_counter_ == 0)
|
Stage::number = 9; // Deja el valor dentro de los limites
|
||||||
{
|
balloon_manager_->destroyAllBalloons(); // Destruye a todos los globos
|
||||||
stopMusic();
|
destroyAllItems(); // Destruye todos los items
|
||||||
Stage::number = 9; // Deja el valor dentro de los limites
|
Stage::power = 0; // Vuelve a dejar el poder a cero, por lo que hubiera podido subir al destruir todos los globos
|
||||||
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_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
// Comprueba el estado del juego
|
||||||
@@ -886,26 +913,32 @@ 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_)
|
|
||||||
{
|
{
|
||||||
case GameState::PLAYING:
|
switch (state_)
|
||||||
case GameState::COMPLETED:
|
{
|
||||||
case GameState::GAME_OVER:
|
case GameState::COMPLETED:
|
||||||
updateGameStatePlaying();
|
updateGameStateCompleted();
|
||||||
break;
|
break;
|
||||||
case GameState::FADE_IN:
|
case GameState::GAME_OVER:
|
||||||
updateGameStateFadeIn();
|
updateGameStateGameOver();
|
||||||
break;
|
break;
|
||||||
case GameState::ENTERING_PLAYER:
|
case GameState::PLAYING:
|
||||||
updateGameStateEnteringPlayer();
|
updateGameStatePlaying();
|
||||||
break;
|
break;
|
||||||
case GameState::SHOWING_GET_READY_MESSAGE:
|
case GameState::FADE_IN:
|
||||||
updateGameStateShowingGetReadyMessage();
|
updateGameStateFadeIn();
|
||||||
break;
|
break;
|
||||||
|
case GameState::ENTERING_PLAYER:
|
||||||
|
updateGameStateEnteringPlayer();
|
||||||
|
break;
|
||||||
|
case GameState::SHOWING_GET_READY_MESSAGE:
|
||||||
|
updateGameStateShowingGetReadyMessage();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkMusicStatus();
|
checkMusicStatus();
|
||||||
@@ -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