* Implemented a way to modify extro parameters as a complement to Wansti's new music
authorOndřej Hošek <ondra.hosek@gmail.com>
Sun, 15 Jan 2006 21:08:05 +0000 (21:08 +0000)
committerOndřej Hošek <ondra.hosek@gmail.com>
Sun, 15 Jan 2006 21:08:05 +0000 (21:08 +0000)
* Forgot to check in implementations of stay-on-platform for Mr Bomb and Mr Iceblock; doing so now
* Little fix to statistics
* Fixes to a few converted bonus2 levels
* Anubis's level now has a custom extro

SVN-Revision: 2997

12 files changed:
data/levels/bonus2/level11.stl
data/levels/bonus2/level28.stl
data/levels/world2/level4.stl
src/badguy/dispenser.cpp
src/badguy/mrbomb.cpp
src/badguy/mrbomb.hpp
src/badguy/mriceblock.cpp
src/badguy/mriceblock.hpp
src/game_session.cpp
src/level.cpp
src/level.hpp
src/statistics.cpp

index 36142a6..c2b9556 100644 (file)
@@ -83,6 +83,9 @@
     (leveltime
       (time 400)
     )
+    (camera
+      (mode "normal")
+    )
     (spawnpoint
       (name "main")
       (x 100)
index f4bb13e..c270885 100644 (file)
@@ -80,9 +80,8 @@
       )
     )
     (background
-      (color_top 0 0 0)
-      (color_bottom 255 255 255)
-      (speed 0.5)
+      (top_color 0.0 0.0 0.0)
+      (bottom_color 1.0 1.0 1.0)
     )
     (leveltime
       (time 200)
index d0aa910..d6e4dec 100644 (file)
@@ -3,6 +3,10 @@
   (version 2)
   (name   (_ "Going Underground"))
   (author "Anubis")
+  (extro
+    (music "gameover_forest.ogg")
+    (length 12.7)
+  )
   (sector
     (name  "main")
     (music  "forest2.ogg")
index 4aea90c..010e9c7 100644 (file)
@@ -95,9 +95,9 @@ Dispenser::launch_badguy()
     else if (badguy == "bouncingsnowball")
       Sector::current()->add_object(new BouncingSnowball(get_pos().x, get_pos().y+32, dir));
     else if (badguy == "mrbomb")
-      Sector::current()->add_object(new MrBomb(get_pos().x, get_pos().y+32, dir));
+      Sector::current()->add_object(new MrBomb(get_pos().x, get_pos().y+32, dir, false));
     else if (badguy == "mriceblock")
-      Sector::current()->add_object(new MrIceBlock(get_pos().x, get_pos().y+32, dir));
+      Sector::current()->add_object(new MrIceBlock(get_pos().x, get_pos().y+32, dir, false));
     else if (badguy == "snowsnail")
       Sector::current()->add_object(new SnowSnail(get_pos().x, get_pos().y+32, dir));
     else if (badguy == "mrrocket") {
@@ -110,8 +110,8 @@ Dispenser::launch_badguy()
       {
         case 0: Sector::current()->add_object(new SnowBall(get_pos().x, get_pos().y+32, dir)); break;
         case 1: Sector::current()->add_object(new BouncingSnowball(get_pos().x, get_pos().y+32, dir)); break;
-        case 2: Sector::current()->add_object(new MrBomb(get_pos().x, get_pos().y+32, dir)); break;
-        case 3: Sector::current()->add_object(new MrIceBlock(get_pos().x, get_pos().y+32, dir)); break;
+        case 2: Sector::current()->add_object(new MrBomb(get_pos().x, get_pos().y+32, dir, false)); break;
+        case 3: Sector::current()->add_object(new MrIceBlock(get_pos().x, get_pos().y+32, dir, false)); break;
         case 4: Sector::current()->add_object(new PoisonIvy(get_pos().x, get_pos().y+32, dir)); break;
         case 5: Sector::current()->add_object(new SnowSnail(get_pos().x, get_pos().y+32, dir)); break;
       }
index 2829616..d38ef8d 100644 (file)
@@ -28,15 +28,18 @@ MrBomb::MrBomb(const lisp::Lisp& reader)
 {
   reader.get("x", start_position.x);
   reader.get("y", start_position.y);
+  stay_on_platform = false;
+  reader.get("stay-on-platform", stay_on_platform);
   bbox.set_size(31.8, 31.8);
   sprite = sprite_manager->create("images/creatures/mr_bomb/mr_bomb.sprite");
   set_direction = false;
 }
 
-MrBomb::MrBomb(float pos_x, float pos_y, Direction d)
+MrBomb::MrBomb(float pos_x, float pos_y, Direction d, bool stay_on_plat = false)
 {
   start_position.x = pos_x;
   start_position.y = pos_y;
+  stay_on_platform = stay_on_plat;
   bbox.set_size(31.8, 31.8);
   sprite = sprite_manager->create("images/creatures/mr_bomb/mr_bomb.sprite");
   set_direction = true;
@@ -50,6 +53,7 @@ MrBomb::write(lisp::Writer& writer)
 
   writer.write_float("x", start_position.x);
   writer.write_float("y", start_position.y);
+  writer.write_bool("stay-on-platform", stay_on_platform);
 
   writer.end_list("mrbomb");
 }
@@ -62,6 +66,19 @@ MrBomb::activate()
   sprite->set_action(dir == LEFT ? "left" : "right");
 }
 
+void
+MrBomb::active_update(float elapsed_time)
+{
+  if (stay_on_platform && may_fall_off_platform())
+  {
+    dir = (dir == LEFT ? RIGHT : LEFT);
+    sprite->set_action(dir == LEFT ? "left" : "right");
+    physic.set_velocity_x(-physic.get_velocity_x());
+  }
+
+  BadGuy::active_update(elapsed_time);
+}
+
 bool
 MrBomb::collision_squished(Player& player)
 {
index 8fa7f5a..8495f00 100644 (file)
@@ -27,9 +27,10 @@ class MrBomb : public BadGuy
 {
 public:
   MrBomb(const lisp::Lisp& reader);
-  MrBomb(float pos_x, float pos_y, Direction d);
+  MrBomb(float pos_x, float pos_y, Direction d, bool stay_on_plat);
 
   void activate();
+  void active_update(float elapsed_time);
   void write(lisp::Writer& writer);
   HitResponse collision_solid(GameObject& other, const CollisionHit& hit);
   HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
@@ -38,6 +39,7 @@ public:
 protected:
   bool collision_squished(Player& player);
   bool set_direction;
+  bool stay_on_platform;
   Direction initial_direction;  
 };
 
index 863fd9e..782062b 100644 (file)
@@ -32,17 +32,19 @@ MrIceBlock::MrIceBlock(const lisp::Lisp& reader)
 {
   reader.get("x", start_position.x);
   reader.get("y", start_position.y);
+  stay_on_platform = false;
   reader.get("stay-on-platform", stay_on_platform);
   bbox.set_size(31.8, 31.8);
   sprite = sprite_manager->create("mriceblock");
   set_direction = false;
 }
 
-MrIceBlock::MrIceBlock(float pos_x, float pos_y, Direction d)
+MrIceBlock::MrIceBlock(float pos_x, float pos_y, Direction d, bool stay_on_plat = false )
   : ice_state(ICESTATE_NORMAL), squishcount(0)
 {
   start_position.x = pos_x;
   start_position.y = pos_y;
+  stay_on_platform = stay_on_plat;
   bbox.set_size(31.8, 31.8);
   sprite = sprite_manager->create("mriceblock");
   set_direction = true;
@@ -56,6 +58,7 @@ MrIceBlock::write(lisp::Writer& writer)
 
   writer.write_float("x", start_position.x);
   writer.write_float("y", start_position.y);
+  writer.write_bool("stay-on-platform", stay_on_platform);
 
   writer.end_list("mriceblock");
 }
index a884aa8..4f5d957 100644 (file)
@@ -28,7 +28,7 @@ class MrIceBlock : public BadGuy, public Portable
 {
 public:
   MrIceBlock(const lisp::Lisp& reader);
-  MrIceBlock(float pos_x, float pos_y, Direction d);
+  MrIceBlock(float pos_x, float pos_y, Direction d, bool stay_on_plat);
 
   void activate();
   void write(lisp::Writer& writer);
index 7ccf19b..a63f108 100644 (file)
@@ -718,10 +718,10 @@ GameSession::start_sequence(const std::string& sequencename)
       return;
     
     end_sequence = ENDSEQUENCE_RUNNING;
-    endsequence_timer.start(7.0); // 7 seconds until we finish the map
+    endsequence_timer.start(level->extro_length); // 7 seconds until we finish the map
     last_x_pos = -1;
-    sound_manager->play_music("music/leveldone.ogg", false);
-    currentsector->player->invincible_timer.start(7.0);
+    sound_manager->play_music("music/" + level->extro_music, false);
+    currentsector->player->invincible_timer.start(level->extro_length);
 
     if(sequencename == "fireworks") {
       currentsector->add_object(new Fireworks());
index 8f1885b..6c87b81 100644 (file)
@@ -51,7 +51,7 @@
 using namespace std;
 
 Level::Level()
-  : name("noname"), author("Mr. X")
+  : name("noname"), author("Mr. X"), extro_music("leveldone.ogg"), extro_length(7.0)
 {
 }
 
@@ -85,6 +85,17 @@ Level::load(const std::string& filepath)
         iter.value()->get(name);
       } else if(token == "author") {
         iter.value()->get(author);
+      } else if(token == "extro") {
+        const lisp::Lisp* ext = iter.lisp();
+        lisp::ListIterator ext_iter(ext);
+        while(ext_iter.next()) {
+          const std::string& ext_token = ext_iter.item();
+          if(ext_token == "music") {
+            ext_iter.value()->get(extro_music);
+          } else if(ext_token == "length") {
+            ext_iter.value()->get(extro_length);
+          }
+        }
       } else if(token == "sector") {
         Sector* sector = new Sector;
         sector->parse(*(iter.lisp()));
index 18d1803..2175b3c 100644 (file)
@@ -35,6 +35,8 @@ class Level
 public:
   std::string name;
   std::string author;
+  std::string extro_music;
+  float extro_length;
   typedef std::vector<Sector*> Sectors;
   Sectors sectors;
 
index 6d11616..11c03b5 100644 (file)
@@ -180,7 +180,7 @@ Statistics::draw_message_info(DrawingContext& context, std::string title)
   //sprintf(str, _(    "Max score:             %d"), stats[SCORE_STAT][SPLAYER]);
   //context.draw_text(white_text, str, Vector(SCREEN_WIDTH/2, 450), CENTER_ALLIGN, LAYER_GUI);
 
-  for(int i = 1; i < NUM_STATS; i++)
+  for(int i = 0; i < NUM_STATS; i++)
     {
     if(i == COINS_COLLECTED_STAT)
       sprintf(str, _("Max coins collected:   %d / %d"),
@@ -190,14 +190,16 @@ Statistics::draw_message_info(DrawingContext& context, std::string title)
       sprintf(str, _("Max fragging:          %d / %d"),
               stats[BADGUYS_KILLED_STAT][SPLAYER],
               stats[BADGUYS_KILLED_STAT][STOTAL]);
-    else// if(i == TIME_NEEDED_STAT)
+    else if((i == TIME_NEEDED_STAT) && (stats[TIME_NEEDED_STAT][STOTAL] != -1))
       sprintf(str, _("Min time needed:       %d / %d"),
               stats[TIME_NEEDED_STAT][SPLAYER],
               stats[TIME_NEEDED_STAT][STOTAL]);
+    else
+      continue;
 
 
     // y == (462 + i*18) before score removal
-    context.draw_text(white_small_text, str, Vector(SCREEN_WIDTH/2, 450 + i*18), CENTER_ALLIGN, LAYER_GUI);
+    context.draw_text(white_small_text, str, Vector(SCREEN_WIDTH/2, 450 + (i+1)*18), CENTER_ALLIGN, LAYER_GUI);
     }
 }