Corregit el timing de la música en la animació inicial del joc
This commit is contained in:
@@ -400,7 +400,7 @@ void Game::updateGameStateCompleted()
|
|||||||
// Si los jugadores ya no estan y no quedan mensajes en pantalla
|
// Si los jugadores ya no estan y no quedan mensajes en pantalla
|
||||||
if (allPlayersAreGameOver() && path_sprites_.size() == 0)
|
if (allPlayersAreGameOver() && path_sprites_.size() == 0)
|
||||||
{
|
{
|
||||||
state_ = GameState::GAME_OVER;
|
setState(GameState::GAME_OVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Incrementa el contador al final
|
// Incrementa el contador al final
|
||||||
@@ -412,12 +412,12 @@ void Game::checkState()
|
|||||||
{
|
{
|
||||||
if (state_ != GameState::COMPLETED && Stage::number == 10)
|
if (state_ != GameState::COMPLETED && Stage::number == 10)
|
||||||
{
|
{
|
||||||
state_ = GameState::COMPLETED;
|
setState(GameState::COMPLETED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state_ != GameState::GAME_OVER && allPlayersAreGameOver())
|
if (state_ != GameState::GAME_OVER && allPlayersAreGameOver())
|
||||||
{
|
{
|
||||||
state_ = GameState::GAME_OVER;
|
setState(GameState::GAME_OVER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -949,7 +949,6 @@ void Game::update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkMusicStatus();
|
|
||||||
screen_->update();
|
screen_->update();
|
||||||
globalInputs::update();
|
globalInputs::update();
|
||||||
fillCanvas();
|
fillCanvas();
|
||||||
@@ -1044,16 +1043,6 @@ void Game::disableTimeStopItem()
|
|||||||
balloon_manager_->normalColorsToAllBalloons();
|
balloon_manager_->normalColorsToAllBalloons();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba si la música ha de estar sonando
|
|
||||||
void Game::checkMusicStatus()
|
|
||||||
{
|
|
||||||
// Si se ha completado el juego o los jugadores han terminado, detiene la música
|
|
||||||
if (state_ == GameState::PLAYING || state_ == GameState::SHOWING_GET_READY_MESSAGE)
|
|
||||||
{
|
|
||||||
playMusic();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bucle para el juego
|
// Bucle para el juego
|
||||||
void Game::run()
|
void Game::run()
|
||||||
{
|
{
|
||||||
@@ -1201,7 +1190,6 @@ void Game::checkEvents()
|
|||||||
pause(!demo_.enabled);
|
pause(!demo_.enabled);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||||
{
|
{
|
||||||
pause(false);
|
pause(false);
|
||||||
@@ -1647,7 +1635,7 @@ void Game::initDemo(int player_id)
|
|||||||
if (demo_.enabled)
|
if (demo_.enabled)
|
||||||
{
|
{
|
||||||
// Cambia el estado del juego
|
// Cambia el estado del juego
|
||||||
state_ = GameState::PLAYING;
|
setState(GameState::PLAYING);
|
||||||
|
|
||||||
// Aleatoriza la asignación del fichero con los datos del modo demostracion
|
// Aleatoriza la asignación del fichero con los datos del modo demostracion
|
||||||
{
|
{
|
||||||
@@ -1886,7 +1874,7 @@ void Game::updateGameStateFadeIn()
|
|||||||
updateBackground();
|
updateBackground();
|
||||||
if (fade_in_->hasEnded())
|
if (fade_in_->hasEnded())
|
||||||
{
|
{
|
||||||
state_ = GameState::ENTERING_PLAYER;
|
setState(GameState::ENTERING_PLAYER);
|
||||||
balloon_manager_->createTwoBigBalloons();
|
balloon_manager_->createTwoBigBalloons();
|
||||||
evaluateAndSetMenace();
|
evaluateAndSetMenace();
|
||||||
}
|
}
|
||||||
@@ -1903,7 +1891,7 @@ void Game::updateGameStateEnteringPlayer()
|
|||||||
{
|
{
|
||||||
if (player->isPlaying())
|
if (player->isPlaying())
|
||||||
{
|
{
|
||||||
state_ = GameState::SHOWING_GET_READY_MESSAGE;
|
setState(GameState::SHOWING_GET_READY_MESSAGE);
|
||||||
createMessage({paths_.at(0), paths_.at(1)}, Resource::get()->getTexture("game_text_get_ready"));
|
createMessage({paths_.at(0), paths_.at(1)}, Resource::get()->getTexture("game_text_get_ready"));
|
||||||
JA_PlaySound(Resource::get()->getSound("voice_get_ready.wav"));
|
JA_PlaySound(Resource::get()->getSound("voice_get_ready.wav"));
|
||||||
}
|
}
|
||||||
@@ -1922,8 +1910,13 @@ void Game::updateGameStateShowingGetReadyMessage()
|
|||||||
freePathSprites();
|
freePathSprites();
|
||||||
if (path_sprites_.size() == 0)
|
if (path_sprites_.size() == 0)
|
||||||
{
|
{
|
||||||
state_ = GameState::PLAYING;
|
setState(GameState::PLAYING);
|
||||||
}
|
}
|
||||||
|
if (counter_ == 100)
|
||||||
|
{
|
||||||
|
playMusic();
|
||||||
|
}
|
||||||
|
++counter_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las variables durante el transcurso normal del juego
|
// Actualiza las variables durante el transcurso normal del juego
|
||||||
@@ -1953,6 +1946,7 @@ void Game::updateGameStatePlaying()
|
|||||||
checkAndUpdateBalloonSpeed();
|
checkAndUpdateBalloonSpeed();
|
||||||
checkState();
|
checkState();
|
||||||
cleanVectors();
|
cleanVectors();
|
||||||
|
playMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vacía los vectores de elementos deshabilitados
|
// Vacía los vectores de elementos deshabilitados
|
||||||
@@ -2012,4 +2006,11 @@ void Game::checkAndUpdateBalloonSpeed()
|
|||||||
break; // Salir del bucle una vez actualizada la velocidad y aplicada
|
break; // Salir del bucle una vez actualizada la velocidad y aplicada
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cambia el estado del juego
|
||||||
|
void Game::setState(GameState state)
|
||||||
|
{
|
||||||
|
state_ = state;
|
||||||
|
counter_ = 0;
|
||||||
}
|
}
|
||||||
@@ -310,9 +310,6 @@ private:
|
|||||||
// Pausa el juego
|
// Pausa el juego
|
||||||
void pause(bool value);
|
void pause(bool value);
|
||||||
|
|
||||||
// Comprueba si la música ha de estar sonando
|
|
||||||
void checkMusicStatus();
|
|
||||||
|
|
||||||
// Añade una puntuación a la tabla de records
|
// Añade una puntuación a la tabla de records
|
||||||
void addScoreToScoreBoard(const std::string &name, int score);
|
void addScoreToScoreBoard(const std::string &name, int score);
|
||||||
|
|
||||||
@@ -421,6 +418,9 @@ private:
|
|||||||
// Actualiza la velocidad de los globos en funcion del poder acumulado de la fase
|
// Actualiza la velocidad de los globos en funcion del poder acumulado de la fase
|
||||||
void checkAndUpdateBalloonSpeed();
|
void checkAndUpdateBalloonSpeed();
|
||||||
|
|
||||||
|
// Cambia el estado del juego
|
||||||
|
void setState(GameState state);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Game(int playerID, int current_stage, bool demo);
|
Game(int playerID, int current_stage, bool demo);
|
||||||
|
|||||||
Reference in New Issue
Block a user