Skip to content

Commit

Permalink
Add fadeDuration calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
rickgaiser authored and KrahJohlito committed Jul 5, 2020
1 parent 2f5030d commit a6c6b05
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -1383,6 +1383,8 @@ void guiIntroLoop(void)
{
int endIntro = 0;
int greetingAlpha = 0x80;
const int fadeFrameCount = 0x80 / 2;
const int fadeDuration = (fadeFrameCount * 1000) / 55; // Average between 50 and 60 fps
clock_t tFadeDelayEnd = 0;

while (!endIntro) {
Expand All @@ -1400,7 +1402,7 @@ void guiIntroLoop(void)
// Start playing sound
sfxPlay(SFX_BOOT);
// Calculate transition delay
tFadeDelayEnd = clock() + sfxGetSoundDuration(SFX_BOOT) * CLOCKS_PER_SEC / 1000;
tFadeDelayEnd = clock() + (sfxGetSoundDuration(SFX_BOOT) - fadeDuration) * CLOCKS_PER_SEC / 1000;
}

if (gInitComplete && clock() >= tFadeDelayEnd)
Expand Down

0 comments on commit a6c6b05

Please sign in to comment.