Retocado el final del ending con fade de audio

This commit is contained in:
2022-11-04 18:36:08 +01:00
parent 332b3f5286
commit d37b21fc3b
6 changed files with 46 additions and 8 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -19,6 +19,7 @@ Input::Input(std::string file)
gameControllerBindings.resize(17, gcb);
verbose = true;
enabled = true;
}
// Actualiza el estado del objeto

View File

@@ -100,6 +100,9 @@ void Ending::update()
// Comprueba si se ha de cambiar de escena
checkChangeScene();
// Actualiza el volumen de la musica
updateMusicVolume();
}
}
@@ -484,6 +487,7 @@ section_t Ending::run()
}
JA_StopMusic();
JA_SetVolume(128);
return section;
}
@@ -560,8 +564,12 @@ void Ending::checkChangeScene()
coverCounter = 0;
if (scene == 5)
{
// Termina el bucle
section.name = SECTION_PROG_LOGO;
// Mantiene los valores anteriores
scene = 4;
section.name = SECTION_PROG_QUIT;
coverCounter = 100;
}
}
}
@@ -600,14 +608,20 @@ void Ending::renderCoverTexture()
{
if (coverCounter > 0)
{ // Dibuja la textura que cubre el texto
// const int offset = std::min(coverCounter, 200 / 2);
// SDL_Rect srcRect = {0, 0, 256, 200 - (offset * 2)};
// SDL_Rect dstRect = {0, offset * 2, 256, 200 - (offset * 2)};
// SDL_RenderCopy(renderer, coverTexture, &srcRect, &dstRect);
const int offset = std::min(coverCounter, 100);
SDL_Rect srcRect = {0, 200 - (coverCounter * 2), 256, offset * 2};
SDL_Rect dstRect = {0, 0, 256, offset * 2};
SDL_RenderCopy(renderer, coverTexture, &srcRect, &dstRect);
}
}
// Actualiza el volumen de la musica
void Ending::updateMusicVolume()
{
if (scene == 4 && coverCounter > 0)
{
const float step = (100.0f - coverCounter) / 100.0f;
const int volume = 128 * step;
JA_SetVolume(volume);
}
}

View File

@@ -105,6 +105,9 @@ private:
// Dibuja la cortinilla de cambio de escena
void renderCoverTexture();
// Actualiza el volumen de la musica
void updateMusicVolume();
public:
// Constructor
Ending(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);

View File

@@ -212,6 +212,7 @@ void Game::update()
checkPlayerAndItems();
checkPlayerAndEnemies();
checkIfPlayerIsAlive();
checkGameOver();
checkEndGame();
scoreboard->update();
input->update();
@@ -372,7 +373,7 @@ void Game::checkIfPlayerIsAlive()
}
// Comprueba si ha terminado la partida
void Game::checkEndGame()
void Game::checkGameOver()
{
if (board.lives < 0)
{
@@ -498,3 +499,19 @@ void Game::setScoreBoardColor()
const color_t cBrightBlack = stringToColor(options->palette, "bright_black");
board.color = colorAreEqual(c, cBrightBlack) ? stringToColor(options->palette, "white") : c;
}
// Comprueba si ha finalizado el juego
bool Game::checkEndGame()
{
const bool a = room->getName() == "THE JAIL";
const bool b = board.items >= 2;
const bool c = player->getRect().x < 152;
if (a && b && c)
{
section.name = SECTION_PROG_ENDING;
return true;
}
return false;
}

View File

@@ -89,7 +89,7 @@ private:
void checkIfPlayerIsAlive();
// Comprueba si ha terminado la partida
void checkEndGame();
void checkGameOver();
// Mata al jugador
void killPlayer();
@@ -112,6 +112,9 @@ private:
// Pone el color del marcador en función del color del borde de la habitación
void setScoreBoardColor();
// Comprueba si ha finalizado el juego
bool checkEndGame();
public:
// Constructor
Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options, Input *input, Debug *debug);