From 448d27f4a4cd4dd45d6be05c23fecaee0a93b222 Mon Sep 17 00:00:00 2001 From: Allanis Date: Tue, 22 Jul 2014 14:24:06 +0100 Subject: [PATCH] [Change] You can now determine different text/music using the intro code. --- src/intro.c | 19 ++++++++++++------- src/intro.h | 2 +- src/player.c | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/intro.c b/src/intro.c index 510ce8a..b2af701 100644 --- a/src/intro.c +++ b/src/intro.c @@ -25,16 +25,16 @@ static int intro_nlines = 0; /**< Number of introduction text lines. */ static int intro_length = 0; /**< Length of the text. */ static glFont intro_font; /** Introduction font. */ -static int intro_load(void); +static int intro_load(const char* text); static void intro_cleanup(void); -static int intro_load(void) { +static int intro_load(const char* text) { uint32_t intro_size; char* intro_buf; int i, p, n; int mem; - intro_buf = ldata_read("../dat/intro", &intro_size); + intro_buf = ldata_read(text, &intro_size); intro_length = intro_size; /* Length aproximation! */ /* Create intro font. */ @@ -86,8 +86,11 @@ static void intro_cleanup(void) { /** * @brief Display the introduction sequence. + * @param text Path of text file to use. + * @param mus Name of music to use. + * @return 0 on success. */ -int intro_display(void) { +int intro_display(const char* text, const char* mus) { int i, max; unsigned int tcur, tlast; double dt; @@ -97,7 +100,7 @@ int intro_display(void) { SDL_Event event; /* Load the introduction. */ - if(intro_load() < 0) + if(intro_load(text) < 0) return -1; /* Calculate velocity. */ @@ -106,8 +109,10 @@ int intro_display(void) { vel = INTRO_SPEED / density; /* (char / s) * (pixel / char) = pixel / s */ /* Change music to intro music. */ - music_load("intro"); - music_play(); + if(mus != NULL) { + music_load(mus); + music_play(); + } /* Prepare for intro loop. */ x = 100.; diff --git a/src/intro.h b/src/intro.h index e698c7b..e46f2e1 100644 --- a/src/intro.h +++ b/src/intro.h @@ -1,4 +1,4 @@ #pragma once -int intro_display(void); +int intro_display(const char* text, const char* mus); diff --git a/src/player.c b/src/player.c index b80707b..5ae2eb8 100644 --- a/src/player.c +++ b/src/player.c @@ -183,7 +183,7 @@ void player_new(void) { if(player_newMake()) return; - intro_display(); + intro_display("../dat/intro", "intro"); /* Add the mission if found. */ if(player_mission != NULL) {