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

View File

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

View File

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

View File

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