Añadido contador al quitar el menu de pausa del juego
This commit is contained in:
@@ -273,6 +273,8 @@ void Game::init()
|
||||
powerBallEnabled = false;
|
||||
powerBallCounter = 0;
|
||||
coffeeMachineEnabled = false;
|
||||
pauseCounter = 0;
|
||||
leavingPauseMenu = false;
|
||||
|
||||
if (demo.enabled)
|
||||
{
|
||||
@@ -3073,11 +3075,6 @@ void Game::checkGameInput()
|
||||
if (input->checkInput(INPUT_CANCEL, REPEAT_FALSE, options->input[i].deviceType, options->input[i].id))
|
||||
{
|
||||
section.subsection = GAME_SECTION_PAUSE;
|
||||
|
||||
if (JA_GetMusicState() == JA_MUSIC_PLAYING)
|
||||
{
|
||||
JA_PauseMusic();
|
||||
}
|
||||
}
|
||||
|
||||
if (demo.counter < TOTAL_DEMO_DATA)
|
||||
@@ -3289,7 +3286,32 @@ void Game::updatePausedGame()
|
||||
// Actualiza el contador de ticks
|
||||
ticks = SDL_GetTicks();
|
||||
|
||||
// Actualiza la lógica del menu de pausa
|
||||
if (leavingPauseMenu)
|
||||
{
|
||||
if (pauseCounter > 0)
|
||||
{ // El contador está descendiendo
|
||||
const bool a = pauseCounter == 90;
|
||||
const bool b = pauseCounter == 60;
|
||||
const bool c = pauseCounter == 30;
|
||||
if (a || b || c)
|
||||
{
|
||||
JA_PlaySound(clockSound);
|
||||
}
|
||||
pauseCounter--;
|
||||
}
|
||||
else
|
||||
{ // Ha finalizado el contador
|
||||
section.name = PROG_SECTION_GAME;
|
||||
section.subsection = numPlayers == 1 ? GAME_SECTION_PLAY_1P : GAME_SECTION_PLAY_2P;
|
||||
|
||||
if (JA_GetMusicState() == JA_MUSIC_PAUSED)
|
||||
{
|
||||
JA_ResumeMusic();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // Actualiza la lógica del menu de pausa
|
||||
pauseMenu->update();
|
||||
|
||||
// Comprueba las entradas para el menu
|
||||
@@ -3299,13 +3321,7 @@ void Game::updatePausedGame()
|
||||
switch (pauseMenu->getItemSelected())
|
||||
{
|
||||
case 1:
|
||||
section.name = PROG_SECTION_GAME;
|
||||
section.subsection = numPlayers == 1 ? GAME_SECTION_PLAY_1P : GAME_SECTION_PLAY_2P;
|
||||
|
||||
if (JA_GetMusicState() == JA_MUSIC_PAUSED)
|
||||
{
|
||||
JA_ResumeMusic();
|
||||
}
|
||||
leavingPauseMenu = true;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
@@ -3326,6 +3342,7 @@ void Game::updatePausedGame()
|
||||
JA_StopMusic();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Dibuja el menu de pausa del juego
|
||||
@@ -3361,7 +3378,14 @@ void Game::renderPausedGame()
|
||||
renderFlashEffect();
|
||||
}
|
||||
|
||||
if (leavingPauseMenu)
|
||||
{
|
||||
textNokiaBig2->writeCentered(SCREEN_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, std::to_string((pauseCounter / 30) + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
pauseMenu->render();
|
||||
}
|
||||
fade->render();
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
@@ -3371,8 +3395,18 @@ void Game::renderPausedGame()
|
||||
// Bucle para el menu de pausa del juego
|
||||
void Game::runPausedGame()
|
||||
{
|
||||
// Pone en pausa la música
|
||||
if (JA_GetMusicState() == JA_MUSIC_PLAYING)
|
||||
{
|
||||
JA_PauseMusic();
|
||||
}
|
||||
|
||||
// Reinicia el menu
|
||||
pauseMenu->reset();
|
||||
leavingPauseMenu = false;
|
||||
|
||||
// Inicializa variables
|
||||
pauseCounter = 90;
|
||||
|
||||
while ((section.subsection == GAME_SECTION_PAUSE) && (section.name == PROG_SECTION_GAME))
|
||||
{
|
||||
@@ -3715,6 +3749,15 @@ void Game::checkEventHandler()
|
||||
section.name = PROG_SECTION_QUIT;
|
||||
break;
|
||||
}
|
||||
|
||||
else if (eventHandler->type == SDL_WINDOWEVENT)
|
||||
{
|
||||
if (eventHandler->window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
||||
{
|
||||
section.subsection = GAME_SECTION_PAUSE;
|
||||
}
|
||||
}
|
||||
|
||||
else if (eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0)
|
||||
{
|
||||
switch (eventHandler->key.keysym.scancode)
|
||||
|
||||
@@ -196,7 +196,6 @@ private:
|
||||
int numPlayers; // Numero de jugadores
|
||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||
Uint8 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||
|
||||
Uint32 hiScore; // Puntuación máxima
|
||||
bool hiScoreAchieved; // Indica si se ha superado la puntuación máxima
|
||||
section_t section; // Seccion actual dentro del juego
|
||||
@@ -236,6 +235,8 @@ private:
|
||||
demo_t demo; // Variable con todas las variables relacionadas con el modo demo
|
||||
int totalPowerToCompleteGame; // La suma del poder necesario para completar todas las fases
|
||||
int cloudsSpeed; // Velocidad a la que se desplazan las nubes
|
||||
int pauseCounter; // Contador para salir del menu de pausa y volver al juego
|
||||
bool leavingPauseMenu; // Indica si esta saliendo del menu de pausa para volver al juego
|
||||
|
||||
// Actualiza el juego
|
||||
void update();
|
||||
|
||||
Reference in New Issue
Block a user