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

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);
}
}