diff --git a/src/game/credits.c b/src/game/credits.c index 3ca9684..a30708d 100644 --- a/src/game/credits.c +++ b/src/game/credits.c @@ -30,12 +30,13 @@ static Atlas *background; static Credit head, *tail; static float creditSpeed; static int timeout; +static int isFromEnding; -void initCredits(void) +void initCredits(int fromEnding) { startSectionTransition(); - - stopMusic(); + + isFromEnding = fromEnding; memset(&head, 0, sizeof(Credit)); tail = &head; @@ -50,9 +51,12 @@ void initCredits(void) loadCredits(); - loadMusic("music/Eternal Wishes.ogg"); - - playMusic(0); + if (isFromEnding) + { + loadMusic("music/Eternal Wishes.ogg"); + + playMusic(0); + } endSectionTransition(); } @@ -70,7 +74,16 @@ static void logic(void) if (--timeout <= 0) { - exit(1); + if (isFromEnding) + { + initTitle(); + } + else + { + startSectionTransition(); + returnToTitle(); + endSectionTransition(); + } } } @@ -137,9 +150,16 @@ static void loadCredits(void) } limitTextWidth(0); - + /* the music that plays over the credits is 1m 55s, so scroll credits roughly inline with that (plus 2 seconds) */ - timeout = (60 + 57) * FPS; + if (isFromEnding) + { + timeout = (60 + 57) * FPS; + } + else + { + timeout = 60 * FPS; + } creditSpeed = y; creditSpeed /= timeout; diff --git a/src/game/credits.h b/src/game/credits.h index f3ca074..57b592f 100644 --- a/src/game/credits.h +++ b/src/game/credits.h @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../common.h" -#define CREDIT_LINE_LIMIT 500 +#define CREDIT_LINE_LIMIT 900 extern void blitRectScaled(SDL_Texture *texture, int x, int y, int w, int h, SDL_Rect *srcRect, int center); extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); @@ -34,6 +34,8 @@ extern void playMusic(int loop); extern char *readFile(const char *filename); extern void startSectionTransition(void); extern void stopMusic(void); +extern void returnToTitle(void); +extern void initTitle(void); extern App app; extern Colors colors; diff --git a/src/game/ending.c b/src/game/ending.c index c10e359..c5f0365 100644 --- a/src/game/ending.c +++ b/src/game/ending.c @@ -65,7 +65,7 @@ static void logic(void) } else { - exit(1); + initCredits(1); } } } diff --git a/src/game/ending.h b/src/game/ending.h index a6fff85..bb6ce1b 100644 --- a/src/game/ending.h +++ b/src/game/ending.h @@ -32,6 +32,7 @@ extern int getWrappedTextHeight(const char *text, int size); extern void limitTextWidth(int width); extern char *readFile(const char *filename); extern void startSectionTransition(void); +extern void initCredits(int playMusic); extern App app; extern Colors colors;