Added support for setting up end sequence animations on levels.
authorRicardo Cruz <rick2@aeiou.pt>
Thu, 16 Sep 2004 18:56:09 +0000 (18:56 +0000)
committerRicardo Cruz <rick2@aeiou.pt>
Thu, 16 Sep 2004 18:56:09 +0000 (18:56 +0000)
Tag: (end-sequence-animation "fireworks")
fireworks is only supported currently.

SVN-Revision: 1929

src/gameloop.cpp
src/sector.cpp
src/sector.h

index 0ccf68d..aa5e1c7 100644 (file)
@@ -548,14 +548,15 @@ GameSession::check_end_conditions()
   else if(!end_sequence && endtile && endtile->data == 0)
     {
       end_sequence = ENDSEQUENCE_RUNNING;
-      random_timer.start(200);  // start 1st firework
+      endsequence_timer.start(7000); // 5 seconds until we finish the map
       last_x_pos = -1;
       SoundManager::get()->play_music(level_end_song, 0);
-      endsequence_timer.start(7000); // 5 seconds until we finish the map
       tux->invincible_timer.start(7000); //FIXME: Implement a winning timer for the end sequence (with special winning animation etc.)
 
       // add left time to stats
       global_stats.set_points(TIME_NEEDED_STAT, time_left.get_gone() / 1000);
+
+      random_timer.start(200);  // start 1st firework
     }
   else if (!end_sequence && tux->is_dead())
     {
@@ -593,7 +594,8 @@ GameSession::action(double frame_ratio)
   }
 
   // on end sequence make a few fireworks
-  if(end_sequence == ENDSEQUENCE_RUNNING && !random_timer.check())
+  if(end_sequence == ENDSEQUENCE_RUNNING && !random_timer.check() &&
+     currentsector->end_sequence_animation() == FIREWORKS_ENDSEQ_ANIM)
     {
     Vector epicenter = currentsector->camera->get_translation();
     epicenter.x += screen->w * ((float)rand() / RAND_MAX);
index c0c86f3..9290da4 100644 (file)
@@ -46,7 +46,7 @@ Sector* Sector::_current = 0;
 
 Sector::Sector()
   : gravity(10), player(0), solids(0), background(0), camera(0),
-    currentmusic(LEVEL_MUSIC)
+    currentmusic(LEVEL_MUSIC), end_sequence_animation_type(NONE_ENDSEQ_ANIM)
 {
   song_title = "Mortimers_chipdisko.mod";
   player = new Player();
@@ -86,6 +86,10 @@ Sector::parse(LispReader& lispreader)
     } else if(token == "music") {
       song_title = lisp_string(data);
       load_music();
+    } else if(token == "end-sequence-animation") {
+      std::string end_seq_anim = lisp_string(data);
+      if(end_seq_anim == "fireworks")
+        end_sequence_animation_type = FIREWORKS_ENDSEQ_ANIM;
     } else if(token == "camera") {
       if(camera) {
         std::cerr << "Warning: More than 1 camera defined in sector.\n";
@@ -184,6 +188,13 @@ Sector::parse_old_format(LispReader& reader)
     add_object(background);
   }
 
+  std::string end_seq_anim;
+  reader.read_string("end-sequence-animation", end_seq_anim);
+  if(end_seq_anim == "fireworks")
+    end_sequence_animation_type = FIREWORKS_ENDSEQ_ANIM;
+//  else
+//    end_sequence_animation = NONE_ENDSEQ_ANIM;
+
   std::string particlesystem;
   reader.read_string("particle_system", particlesystem);
   if(particlesystem == "clouds")
index ffd409e..d4291c8 100644 (file)
@@ -56,6 +56,11 @@ struct SpawnPoint
   Vector pos;
 };
 
+enum {
+  NONE_ENDSEQ_ANIM,
+  FIREWORKS_ENDSEQ_ANIM
+  };
+
 /** This class holds a sector (a part of a level) and all the game objects
  * (badguys, player, background, tilemap, ...)
  */
@@ -126,6 +131,10 @@ public:
       player to play the same level in a different way :) */
   void do_vertical_flip();
 
+  /** Get end sequence animation */
+  int end_sequence_animation()
+    { return end_sequence_animation_type; }
+
   /** @evil@ */
   static Sector* current()
   { return _current; }
@@ -140,6 +149,8 @@ private:
   MusicRef level_song;
   MusicRef level_song_fast;
 
+  int end_sequence_animation_type;
+
 public:
   std::string song_title;
   float gravity;