badguy/walking_badguy.[ch]pp: Make it possible to specify the target x velocity.
[supertux.git] / src / badguy / haywire.cpp
index f0aaa39..2252515 100644 (file)
@@ -32,7 +32,9 @@
 Haywire::Haywire(const Reader& reader) :
   WalkingBadguy(reader, "images/creatures/haywire/haywire.sprite", "left", "right"),
   is_exploding(false),
-  is_stunned(false)
+  time_until_explosion(0.0f),
+  is_stunned(false),
+  time_stunned(0.0f)
 {
   walk_speed = 80;
   max_drop_height = 16;
@@ -56,7 +58,9 @@ Haywire::Haywire(const Reader& reader) :
 Haywire::Haywire(const Vector& pos, Direction d) :
   WalkingBadguy(pos, d, "images/creatures/haywire/haywire.sprite", "left", "right"),
   is_exploding(false),
-  is_stunned(false)
+  time_until_explosion(0.0f),
+  is_stunned(false),
+  time_stunned(0.0f)
 {
   walk_speed = 80;
   max_drop_height = 16;
@@ -86,7 +90,8 @@ Haywire::collision_squished(GameObject& object)
   }
 
   if (is_stunned) {
-    player->bounce (*this);
+    if (player)
+      player->bounce (*this);
     return true;
   }
 
@@ -102,7 +107,9 @@ Haywire::collision_squished(GameObject& object)
   time_stunned = TIME_STUNNED;
   is_stunned = true;
 
-  player->bounce (*this);
+  if (player)
+    player->bounce (*this);
+
   return true;
 }
 
@@ -131,7 +138,7 @@ Haywire::active_update(float elapsed_time)
   }
 
   if (is_exploding && !turn_around_timer.started()) {
-    Player *p = Sector::current()->get_nearest_player (this->get_bbox ());
+    Player *p = this->get_nearest_player ();
 
     if (p) {
       Direction player_dir = LEFT;