Afegits sons de caminar i de comptador de continuar

Afegits estats al joc i al jugador per a escenificar el inici de la partida
This commit is contained in:
2025-01-03 19:19:22 +01:00
parent 40dfc32e84
commit cc4acecc03
8 changed files with 223 additions and 77 deletions

View File

@@ -285,27 +285,6 @@ void Game::updateStage()
}
}
// Actualiza el estado de fade in
void Game::updateFadeInState()
{
if (state_ == GameState::FADE_IN)
{
if (fade_in_->hasEnded())
{
state_ = GameState::PLAYING;
// Crea los primeros globos y el mensaje de inicio
if (!demo_.enabled)
{
balloon_manager_->createTwoBigBalloons();
evaluateAndSetMenace();
createMessage({paths_.at(0), paths_.at(1)}, Resource::get()->getTexture("game_text_get_ready"));
JA_PlaySound(Resource::get()->getSound("voice_get_ready.wav"));
}
}
}
}
// Actualiza el estado de fin de la partida
void Game::updateGameOverState()
{
@@ -345,7 +324,7 @@ void Game::updateGameOverState()
}
// Gestiona eventos para el estado del final del juego
void Game::updateCompletedState()
void Game::updateGameStateCompleted()
{
if (state_ == GameState::COMPLETED)
{
@@ -583,11 +562,15 @@ void Game::checkBulletBalloonCollision()
}
// Mueve las balas activas
void Game::moveBullets()
void Game::updateBullets()
{
for (auto &bullet : bullets_)
{
if (bullet->move() == BulletMoveStatus::OUT)
{
getPlayer(bullet->getOwner())->decScoreMultiplier();
}
}
}
// Pinta las balas activas
@@ -802,28 +785,36 @@ void Game::throwCoffee(int x, int y)
void Game::updateSmartSprites()
{
for (auto &sprite : smart_sprites_)
{
sprite->update();
}
}
// Pinta los SmartSprites activos
void Game::renderSmartSprites()
{
for (auto &sprite : smart_sprites_)
{
sprite->render();
}
}
// Actualiza los PathSprites
void Game::updatePathSprites()
{
for (auto &sprite : path_sprites_)
{
sprite->update();
}
}
// Pinta los PathSprites activos
void Game::renderPathSprites()
{
for (auto &sprite : path_sprites_)
{
sprite->render();
}
}
// Acciones a realizar cuando el jugador muere
@@ -895,7 +886,27 @@ void Game::update()
#ifdef RECORDING
updateRecording();
#endif
updateGame();
// AQUI HAY QUE PONER UN SWITCH Y HACER EL UPDATE EN FUNCIÓN DEL ESTADO
switch (state_)
{
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;
default:
break;
}
checkMusicStatus();
screen_->update();
@@ -991,7 +1002,8 @@ void Game::disableTimeStopItem()
void Game::checkMusicStatus()
{
// Si se ha completado el juego o los jugadores han terminado, detiene la música
if (state_ != GameState::COMPLETED && !allPlayersAreGameOver())
// if (state_ != GameState::COMPLETED && !allPlayersAreGameOver())
if (state_ == GameState::PLAYING)
{
playMusic();
}
@@ -1194,7 +1206,7 @@ void Game::checkEvents()
}
case SDLK_6: // Crea un mensaje
{
createMessage({paths_.at(2), paths_.at(3)}, Resource::get()->getTexture("game_text_congratulations"));
createMessage({paths_.at(0), paths_.at(1)}, Resource::get()->getTexture("game_text_get_ready"));
break;
}
case SDLK_7: // Flash
@@ -1705,7 +1717,7 @@ void Game::initPlayers(int player_id)
// Activa el jugador que coincide con el "player_id"
auto player = getPlayer(player_id);
player->setPlayingState(PlayerState::PLAYING);
player->setPlayingState(PlayerState::ENTERING_SCREEN);
player->setInvulnerable(false);
}
@@ -1791,43 +1803,86 @@ void Game::updateRecording()
}
#endif
// Actualiza las variables durante el transcurso normal del juego
void Game::updateGame()
// Actualiza variables durande dicho estado
void Game::updateGameStateFadeIn()
{
if (!paused_)
fade_in_->update();
updateScoreboard();
updateBackground();
if (fade_in_->hasEnded())
{
#ifdef DEBUG
if (auto_pop_balloons_ && state_ == GameState::PLAYING)
{
Stage::addPower(5);
}
#endif
fade_in_->update();
fade_out_->update();
updatePlayers();
checkPlayersStatusPlaying();
updateScoreboard();
updateBackground();
balloon_manager_->update();
tabe_->update();
moveBullets();
updateItems();
updateStage();
updateFadeInState();
updateGameOverState();
updateCompletedState();
updateSmartSprites();
updatePathSprites();
updateTimeStopped();
updateHelper();
checkBulletBalloonCollision();
updateMenace();
checkAndUpdateBalloonSpeed();
checkState();
cleanVectors();
state_ = GameState::ENTERING_PLAYER;
balloon_manager_->createTwoBigBalloons();
evaluateAndSetMenace();
}
}
// Actualiza variables durande dicho estado
void Game::updateGameStateEnteringPlayer()
{
balloon_manager_->update();
updatePlayers();
updateScoreboard();
updateBackground();
for (auto player : players_)
{
if (player->isPlaying())
{
state_ = GameState::SHOWING_GET_READY_MESSAGE;
createMessage({paths_.at(0), paths_.at(1)}, Resource::get()->getTexture("game_text_get_ready"));
JA_PlaySound(Resource::get()->getSound("voice_get_ready.wav"));
}
}
}
// Actualiza variables durande dicho estado
void Game::updateGameStateShowingGetReadyMessage()
{
balloon_manager_->update();
updatePathSprites();
updatePlayers();
updateBullets();
updateScoreboard();
updateBackground();
freePathSprites();
if (path_sprites_.size() == 0)
{
state_ = GameState::PLAYING;
}
}
// Actualiza las variables durante el transcurso normal del juego
void Game::updateGameStatePlaying()
{
#ifdef DEBUG
if (auto_pop_balloons_ && state_ == GameState::PLAYING)
{
Stage::addPower(5);
}
#endif
fade_out_->update();
updatePlayers();
checkPlayersStatusPlaying();
updateScoreboard();
updateBackground();
balloon_manager_->update();
tabe_->update();
updateBullets();
updateItems();
updateStage();
updateGameOverState();
updateGameStateCompleted();
updateSmartSprites();
updatePathSprites();
updateTimeStopped();
updateHelper();
checkBulletBalloonCollision();
updateMenace();
checkAndUpdateBalloonSpeed();
checkState();
cleanVectors();
}
// Vacía los vectores de elementos deshabilitados
void Game::cleanVectors()
{