- moved some more stuff into the world class
[supertux.git] / src / badguy.cpp
index 8aefbff..f1c5df6 100644 (file)
@@ -16,6 +16,7 @@
 #include "badguy.h"
 #include "scene.h"
 #include "screen.h"
+#include "world.h"
 #include "tile.h"
 
 texture_type img_bsod_squished_left[1];
@@ -372,13 +373,14 @@ BadGuy::fall()
 void
 BadGuy::remove_me()
 {
-  std::vector<BadGuy>::iterator i;
-  for(i = bad_guys.begin(); i != bad_guys.end(); ++i) {
-    if( & (*i) == this) {
-      bad_guys.erase(i);
-      return;
+  for(std::vector<BadGuy>::iterator i = World::current()->bad_guys.begin(); 
+      i != World::current()->bad_guys.end(); ++i) 
+    {
+      if( & (*i) == this) {
+        World::current()->bad_guys.erase(i);
+        return;
+      }
     }
-  }
 }
 
 void
@@ -783,7 +785,7 @@ BadGuy::squish_me(Player* player)
 {
   make_player_jump(player);
     
-  add_score(base.x - scroll_x, base.y, 50 * score_multiplier);
+  World::current()->add_score(base.x - scroll_x, base.y, 50 * score_multiplier);
   play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
   score_multiplier++;
 
@@ -796,58 +798,58 @@ void
 BadGuy::squish(Player* player)
 {
   if(kind == BAD_MRBOMB) {
-      // mrbomb transforms into a bomb now
-      add_bad_guy(base.x, base.y, BAD_BOMB);
-      
-      make_player_jump(player);
-      add_score(base.x - scroll_x, base.y, 50 * score_multiplier);
-      play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
-      score_multiplier++;
+    // mrbomb transforms into a bomb now
+    World::current()->add_bad_guy(base.x, base.y, BAD_BOMB);
+    
+    make_player_jump(player);
+    World::current()->add_score(base.x - scroll_x, base.y, 50 * score_multiplier);
+    play_sound(sounds[SND_SQUISH], SOUND_CENTER_SPEAKER);
+    score_multiplier++;
       
-      remove_me();
-      return;
+    remove_me();
+    return;
 
   } else if(kind == BAD_BSOD) {
-      squish_me(player);
-      set_texture(img_bsod_squished_left, img_bsod_squished_right, 1);
-      physic.set_velocity(0, physic.get_velocity_y());
-      return;
+    squish_me(player);
+    set_texture(img_bsod_squished_left, img_bsod_squished_right, 1);
+    physic.set_velocity(0, physic.get_velocity_y());
+    return;
       
   } else if (kind == BAD_LAPTOP) {
-      if (mode == NORMAL || mode == KICK)
+    if (mode == NORMAL || mode == KICK)
       {
-          /* Flatten! */
-          play_sound(sounds[SND_STOMP], SOUND_CENTER_SPEAKER);
-          mode = FLAT;
-          set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
-          physic.set_velocity(0, physic.get_velocity_y());
+        /* Flatten! */
+        play_sound(sounds[SND_STOMP], SOUND_CENTER_SPEAKER);
+        mode = FLAT;
+        set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
+        physic.set_velocity(0, physic.get_velocity_y());
 
-          timer_start(&timer, 4000);
+        timer_start(&timer, 4000);
       } else if (mode == FLAT) {
-          /* Kick! */
-          play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER);
-
-          if (player->base.x < base.x + (base.width/2)) {
-              physic.set_velocity(5, physic.get_velocity_y());
-              dir = RIGHT;
-          } else {
-              physic.set_velocity(-5, physic.get_velocity_y());
-              dir = LEFT;
-          }
-
-          mode = KICK;
-          set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
+        /* Kick! */
+        play_sound(sounds[SND_KICK], SOUND_CENTER_SPEAKER);
+
+        if (player->base.x < base.x + (base.width/2)) {
+          physic.set_velocity(5, physic.get_velocity_y());
+          dir = RIGHT;
+        } else {
+          physic.set_velocity(-5, physic.get_velocity_y());
+          dir = LEFT;
+        }
+
+        mode = KICK;
+        set_texture(img_laptop_flat_left, img_laptop_flat_right, 1);
       }
 
-      make_player_jump(player);
+    make_player_jump(player);
              
-      add_score(base.x - scroll_x, base.y, 25 * score_multiplier);
-      score_multiplier++;
-      return;
+    World::current()->add_score(base.x - scroll_x, base.y, 25 * score_multiplier);
+    score_multiplier++;
+    return;
   } else if(kind == BAD_FISH) {
     make_player_jump(player);
              
-    add_score(base.x - scroll_x, base.y, 25 * score_multiplier);
+    World::current()->add_score(base.x - scroll_x, base.y, 25 * score_multiplier);
     score_multiplier++;
      
     // simply remove the fish...
@@ -885,11 +887,11 @@ BadGuy::kill_me()
 
   /* Gain some points: */
   if (kind == BAD_BSOD)
-    add_score(base.x - scroll_x, base.y,
-              50 * score_multiplier);
+    World::current()->add_score(base.x - scroll_x, base.y,
+                    50 * score_multiplier);
   else 
-    add_score(base.x - scroll_x, base.y,                                 
-              25 * score_multiplier);
+    World::current()->add_score(base.x - scroll_x, base.y,                                 
+                    25 * score_multiplier);
 
   /* Play death sound: */
   play_sound(sounds[SND_FALL], SOUND_CENTER_SPEAKER);