When invincibility time's running out, the invinc. music fades out.
authorOndřej Hošek <ondra.hosek@gmail.com>
Wed, 12 Apr 2006 11:45:16 +0000 (11:45 +0000)
committerOndřej Hošek <ondra.hosek@gmail.com>
Wed, 12 Apr 2006 11:45:16 +0000 (11:45 +0000)
SVN-Revision: 3313

src/game_session.cpp
src/sector.cpp
src/sector.hpp

index 6fc8fb3..2d21d67 100644 (file)
@@ -529,11 +529,17 @@ GameSession::update(float elapsed_time)
   sound_manager->set_listener_position(currentsector->player->get_pos());
 
   /* Handle music: */
-  if (currentsector->player->invincible_timer.started() && 
-      currentsector->player->invincible_timer.get_timeleft() 
-      > TUX_INVINCIBLE_TIME_WARNING && !end_sequence) {
-    currentsector->play_music(HERRING_MUSIC);
-  } else if(currentsector->get_music_type() != LEVEL_MUSIC && !end_sequence) {
+  if (end_sequence)
+    return;
+  
+  if(currentsector->player->invincible_timer.started()) {
+    if(currentsector->player->invincible_timer.get_timeleft() <=
+       TUX_INVINCIBLE_TIME_WARNING) {
+      currentsector->play_music(HERRING_WARNING_MUSIC);
+    } else {
+      currentsector->play_music(HERRING_MUSIC);
+    }
+  } else if(currentsector->get_music_type() != LEVEL_MUSIC) {
     currentsector->play_music(LEVEL_MUSIC);
   }
 }
index 69571e1..d0c4a95 100644 (file)
@@ -1106,6 +1106,9 @@ Sector::play_music(MusicType type)
     case HERRING_MUSIC:
       sound_manager->play_music("music/salcon.ogg");
       break;
+    case HERRING_WARNING_MUSIC:
+      sound_manager->stop_music(TUX_INVINCIBLE_TIME_WARNING);
+      break;
     default:
       sound_manager->play_music("");
       break;
index 7fff0f3..d88bd45 100644 (file)
@@ -49,7 +49,8 @@ class CollisionHit;
 
 enum MusicType {
   LEVEL_MUSIC,
-  HERRING_MUSIC
+  HERRING_MUSIC,
+  HERRING_WARNING_MUSIC
 };
 
 /**