Now loads both normal and fast versions of songs; plays according to time left.
authorBill Kendrick <nbs@sonic.net>
Sun, 28 Dec 2003 09:55:50 +0000 (09:55 +0000)
committerBill Kendrick <nbs@sonic.net>
Sun, 28 Dec 2003 09:55:50 +0000 (09:55 +0000)
SVN-Revision: 62

CHANGES.txt
src/defines.h
src/gameloop.c
src/gameloop.h
src/sound.h

index a725df6..1840c33 100644 (file)
@@ -13,6 +13,10 @@ http://www.newbreedsoftware.com/supertux/
   * Added: --disable-music and music on/off menu option
     Duong-Khang NGUYEN <neoneurone@users.sf.net>
 
+  * Changed out some music.  Created sped-up versions of songs for when
+    time is running out.
+    Bill Kendrick <bill@newbreedsoftware.com>
+
 
 0.0.5 - December 24th, 2003
 ---------------------------
index ffe446a..9299b5b 100644 (file)
@@ -7,7 +7,7 @@
   bill@newbreedsoftware.com
   http://www.newbreedsoftware.com/supertux/
 
-  April 11, 2000 - August 29, 2002
+  April 11, 2000 - December 28, 2003
 */
 
 
index fcb589b..7567c04 100644 (file)
@@ -119,10 +119,10 @@ 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: */
@@ -1125,7 +1125,10 @@ int game_action(void)
 
       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)
@@ -2155,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);
@@ -2257,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);
@@ -2288,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);
         }
@@ -2387,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';
 
@@ -2550,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);
 }
 
index 9b226b7..4104577 100644 (file)
@@ -7,7 +7,7 @@
   bill@newbreedsoftware.com
   http://www.newbreedsoftware.com/supertux/
   
-  April 11, 2000 - November 7, 2001
+  April 11, 2000 - December 28, 2003
 */
 
 
 #define DISTROS_LIFEUP 100
 
 
+/* When to alert player they're low on time! */
+
+#define TIME_WARNING 50
+
+
 /* Dying types: */
 
 /* ---- NO 0 */
index dd14564..e47d488 100644 (file)
@@ -40,8 +40,8 @@ enum Music_Type {
 #include <SDL_mixer.h>
 
 /* variables for stocking the sound and music */
-Mix_Chunk* sounds[NUM_SOUNDS];
-Mix_Music* level_song, *herring_song;
+Mix_Chunk * sounds[NUM_SOUNDS];
+Mix_Music * level_song, * level_song_fast, * herring_song;
 
 /* functions handling the sound and music */
 int open_audio(int frequency, Uint16 format, int channels, int chunksize);