Ending tweaks.

This commit is contained in:
Steve 2018-03-30 13:34:36 +01:00
parent 39362061bf
commit f1b2e8df6d
4 changed files with 30 additions and 13 deletions

View File

@ -33,6 +33,8 @@ static int endingTimer;
void initEnding(void)
{
startSectionTransition();
background[0] = getImageFromAtlas("gfx/ending/ending01.jpg");
background[1] = getImageFromAtlas("gfx/ending/ending02.jpg");
@ -46,22 +48,33 @@ void initEnding(void)
app.delegate.logic = &logic;
app.delegate.draw = &draw;
endSectionTransition();
}
static void logic(void)
{
if (--endingTimer <= -FPS / 2)
{
if (++endingTextIndex == 3)
{
endingImageIndex++;
startSectionTransition();
endSectionTransition();
}
if (endingTextIndex < NUM_ENDING_LINES)
{
endingTimer = strlen(endingText[endingTextIndex]) * 4;
if (++endingTextIndex == 3)
{
endingImageIndex++;
startSectionTransition();
endSectionTransition();
}
if (endingTextIndex < NUM_ENDING_LINES)
{
endingTimer = strlen(endingText[endingTextIndex]) * 4;
}
else
{
fadeMusic(3000);
endingTimer = FPS * 4;
}
}
else
{
@ -79,7 +92,7 @@ static void draw(void)
blitRectScaled(atlasTexture->texture, 0, SCREEN_HEIGHT - h, SCREEN_WIDTH, h, &background[endingImageIndex]->rect, 0);
if (endingTimer > 0)
if (endingTimer > 0 && endingTextIndex < NUM_ENDING_LINES)
{
limitTextWidth(SCREEN_WIDTH / 2);
th = getWrappedTextHeight(endingText[endingTextIndex], 24) + 15;

View File

@ -33,6 +33,7 @@ extern void initCredits(int playMusic);
extern void limitTextWidth(int width);
extern char *readFile(const char *filename);
extern void startSectionTransition(void);
extern void fadeMusic(int ms);
extern App app;
extern Colors colors;

View File

@ -77,16 +77,14 @@ void initPostMission(void)
if (world.isReturnVisit)
{
saveGame();
saveWorld();
}
else
{
restoreGameState();
saveGame();
}
saveGame();
destroyWorld();
initHub();

View File

@ -56,6 +56,11 @@ void stopMusic(void)
Mix_HaltMusic();
}
void fadeMusic(int ms)
{
Mix_FadeOutMusic(ms);
}
void musicSetPlaying(int playing)
{
if (music != NULL)