Afegits roidets de colisió per als globos per a certs moments

This commit is contained in:
2024-12-23 12:37:19 +01:00
parent fb31445731
commit fb4d0d12db
7 changed files with 65 additions and 11 deletions

View File

@@ -283,10 +283,15 @@ void Game::updateGameOverState()
if (game_over_counter_ > 0)
{
if (game_over_counter_ == GAME_OVER_COUNTER_)
{
createMessage({paths_.at(2), paths_.at(3)}, Resource::get()->getTexture("game_over"));
stopMusic();
balloon_manager_->setSounds(true);
}
game_over_counter_--;
/*
if ((game_over_counter_ == 250) || (game_over_counter_ == 200) || (game_over_counter_ == 180) || (game_over_counter_ == 120) || (game_over_counter_ == 60))
{
// Hace sonar aleatoriamente uno de los 4 sonidos de burbujas
@@ -294,6 +299,7 @@ void Game::updateGameOverState()
JA_Sound_t *sound[4] = {Resource::get()->getSound("bubble1.wav"), Resource::get()->getSound("bubble2.wav"), Resource::get()->getSound("bubble3.wav"), Resource::get()->getSound("bubble4.wav")};
JA_PlaySound(sound[index], 0);
}
*/
if (game_over_counter_ == 150)
{
@@ -724,7 +730,9 @@ void Game::createMessage(const std::vector<Path> &paths, std::shared_ptr<Texture
// Inicializa
for (const auto &path : paths)
{
path_sprites_.back()->addPath(path, true);
}
path_sprites_.back()->enable();
}
@@ -817,13 +825,13 @@ void Game::killPlayer(std::shared_ptr<Player> &player)
else
{
// Si no tiene cafes, muere
pauseMusic();
// pauseMusic();
balloon_manager_->stopAllBalloons();
JA_PlaySound(Resource::get()->getSound("player_collision.wav"));
screen_->shake();
JA_PlaySound(Resource::get()->getSound("voice_no.wav"));
player->setPlayingState(PlayerState::DYING);
allPlayersAreNotPlaying() ? stopMusic() : resumeMusic();
// allPlayersAreNotPlaying() ? stopMusic() : resumeMusic();
}
}
@@ -871,7 +879,7 @@ void Game::update()
checkMusicStatus();
screen_->update();
globalInputs::update();
globalInputs::update();
fillCanvas();
}
}
@@ -962,10 +970,8 @@ void Game::disableTimeStopItem()
// Comprueba si la música ha de estar sonando
void Game::checkMusicStatus()
{
// Si la música no está sonando
if (JA_GetMusicState() == JA_MUSIC_INVALID || JA_GetMusicState() == JA_MUSIC_STOPPED)
// Si se ha completado el juego o los jugadores han terminado, detiene la música
state_ == GameState::COMPLETED || allPlayersAreGameOver() ? JA_StopMusic() : JA_PlayMusic(Resource::get()->getMusic("playing.ogg"));
// Si se ha completado el juego o los jugadores han terminado, detiene la música
state_ == GameState::COMPLETED || allPlayersAreGameOver() ? stopMusic() : playMusic();
}
// Bucle para el juego
@@ -1000,8 +1006,7 @@ void Game::initPaths()
paths_.emplace_back(Path(createPath(x1, x2, PathType::HORIZONTAL, y, 80, easeInQuint), 0));
}
// Recorrido para el texto de "Last Stage!" o de "X stages left" o "Game Over"
// (2,3)
// Recorrido para el texto de "Last Stage!" o de "X stages left" o "Game Over" (2,3)
{
const auto &texture = Resource::get()->getTexture("last_stage");
const auto h = texture->getHeight();
@@ -1693,6 +1698,16 @@ void Game::resumeMusic()
}
}
// Hace sonar la música
void Game::playMusic()
{
// Si la música no está sonando
if (JA_GetMusicState() == JA_MUSIC_INVALID || JA_GetMusicState() == JA_MUSIC_STOPPED)
{
JA_PlayMusic(Resource::get()->getMusic("playing.ogg"));
}
}
// Detiene la música
void Game::stopMusic()
{