[Change] You can now determine different text/music using the intro

code.
This commit is contained in:
Allanis 2014-07-22 14:24:06 +01:00
parent bb81e44374
commit 448d27f4a4
3 changed files with 14 additions and 9 deletions

View File

@ -25,16 +25,16 @@ static int intro_nlines = 0; /**< Number of introduction text lines. */
static int intro_length = 0; /**< Length of the text. */ static int intro_length = 0; /**< Length of the text. */
static glFont intro_font; /** Introduction font. */ static glFont intro_font; /** Introduction font. */
static int intro_load(void); static int intro_load(const char* text);
static void intro_cleanup(void); static void intro_cleanup(void);
static int intro_load(void) { static int intro_load(const char* text) {
uint32_t intro_size; uint32_t intro_size;
char* intro_buf; char* intro_buf;
int i, p, n; int i, p, n;
int mem; int mem;
intro_buf = ldata_read("../dat/intro", &intro_size); intro_buf = ldata_read(text, &intro_size);
intro_length = intro_size; /* Length aproximation! */ intro_length = intro_size; /* Length aproximation! */
/* Create intro font. */ /* Create intro font. */
@ -86,8 +86,11 @@ static void intro_cleanup(void) {
/** /**
* @brief Display the introduction sequence. * @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; int i, max;
unsigned int tcur, tlast; unsigned int tcur, tlast;
double dt; double dt;
@ -97,7 +100,7 @@ int intro_display(void) {
SDL_Event event; SDL_Event event;
/* Load the introduction. */ /* Load the introduction. */
if(intro_load() < 0) if(intro_load(text) < 0)
return -1; return -1;
/* Calculate velocity. */ /* Calculate velocity. */
@ -106,8 +109,10 @@ int intro_display(void) {
vel = INTRO_SPEED / density; /* (char / s) * (pixel / char) = pixel / s */ vel = INTRO_SPEED / density; /* (char / s) * (pixel / char) = pixel / s */
/* Change music to intro music. */ /* Change music to intro music. */
music_load("intro"); if(mus != NULL) {
music_load(mus);
music_play(); music_play();
}
/* Prepare for intro loop. */ /* Prepare for intro loop. */
x = 100.; x = 100.;

View File

@ -1,4 +1,4 @@
#pragma once #pragma once
int intro_display(void); int intro_display(const char* text, const char* mus);

View File

@ -183,7 +183,7 @@ void player_new(void) {
if(player_newMake()) if(player_newMake())
return; return;
intro_display(); intro_display("../dat/intro", "intro");
/* Add the mission if found. */ /* Add the mission if found. */
if(player_mission != NULL) { if(player_mission != NULL) {