X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fgameloop.c;h=7567c04f61dc778d6d54f1fd51b830406ae119a9;hb=cc5f060754c9e0ba2c06ab6a00efa1254833baaa;hp=15df2cdd4d57e2231f7d1d53c0dd07a3e8bd7c1b;hpb=e7e01ac7e6765ff1906bfe1e811bd11f4c0f205e;p=supertux.git diff --git a/src/gameloop.c b/src/gameloop.c index 15df2cdd4..7567c04f6 100644 --- a/src/gameloop.c +++ b/src/gameloop.c @@ -7,7 +7,7 @@ bill@newbreedsoftware.com http://www.newbreedsoftware.com/supertux/ - April 11, 2000 - December 9, 2003 + April 11, 2000 - December 28, 2003 */ #include @@ -31,7 +31,7 @@ #include "setup.h" #include "high_scores.h" #include "menu.h" -#include "enemy.h" +#include "badguy.h" #include "world.h" #include "player.h" @@ -119,10 +119,11 @@ bad_guy_type bad_guys[NUM_BAD_GUYS]; floating_score_type floating_scores[NUM_FLOATING_SCORES]; upgrade_type upgrades[NUM_UPGRADES]; bullet_type bullets[NUM_BULLETS]; -char song_title[20]; -char levelname[20]; -char leveltheme[20]; -char str[10]; +char song_title[60]; +char levelname[60]; +char leveltheme[60]; +char str[60]; + /* Local function prototypes: */ @@ -251,15 +252,15 @@ void game_event(void) game_pause = 1; } } - else if (key == SDLK_TAB) + else if (key == SDLK_TAB && debug_mode == YES) { tux_size = !tux_size; } - else if (key == SDLK_END) + else if (key == SDLK_END && debug_mode == YES) { distros += 50; } - else if (key == SDLK_SPACE) + else if (key == SDLK_SPACE && debug_mode == YES) { next_level = 1; } @@ -1121,8 +1122,15 @@ int game_action(void) current_music = LEVEL_MUSIC; halt_music(); } + if (!playing_music()) - play_music( level_song, 1 ); + { + if (time_left <= TIME_WARNING) + play_music( level_song_fast, 1 ); + else + play_music( level_song, 1 ); + } + if (tux_invincible_time > 0) tux_invincible_time--; } @@ -2150,7 +2158,7 @@ void game_draw() drawtext("HIGH", 0, 20, letters_blue, NO_UPDATE); drawtext(str, 96, 20, letters_gold, NO_UPDATE); - if (time_left >= 50 || (frame % 10) < 5) + if (time_left >= TIME_WARNING || (frame % 10) < 5) { sprintf(str, "%d", time_left); drawtext("TIME", 224, 0, letters_blue, NO_UPDATE); @@ -2252,7 +2260,10 @@ int gameloop(void) switch (current_music) { case LEVEL_MUSIC: - play_music(level_song, 1); + if (time_left <= TIME_WARNING) + play_music(level_song_fast, 1); + else + play_music(level_song, 1); break; case HERRING_MUSIC: play_music(herring_song, 1); @@ -2283,6 +2294,10 @@ int gameloop(void) { time_left--; + /* Stop the music; it will start again, faster! */ + if (time_left == TIME_WARNING) + halt_music(); + if (time_left <= 0) killtux(KILL); } @@ -2382,7 +2397,7 @@ void loadlevel(void) time_left = atoi(str); /* (Song file for this level) */ - fgets(str, 20, fi); + fgets(str, sizeof(song_title), fi); strcpy(song_title, str); song_title[strlen(song_title)-1] = '\0'; @@ -2545,14 +2560,22 @@ void loadlevelsong(void) { char * song_path; + char * song_subtitle; song_path = (char *) malloc(sizeof(char) * (strlen(DATA_PREFIX) + strlen(song_title) + 8)); - sprintf(song_path, "%s/music/%s", DATA_PREFIX, song_title); - level_song = load_song(song_path); + free(song_path); + + song_path = (char *) malloc(sizeof(char) * (strlen(DATA_PREFIX) + + strlen(song_title) + 8 + 5)); + song_subtitle = strdup(song_title); + strcpy(strstr(song_subtitle, "."), "\0"); + sprintf(song_path, "%s/music/%s-fast%s", DATA_PREFIX, song_subtitle, strstr(song_title, ".")); + level_song_fast = load_song(song_path); + free(song_subtitle); free(song_path); }