fix collision against spikes too wide, fix paths, try to fix jumping on badguys that...
[supertux.git] / src / badguy / flyingsnowball.cpp
index 3135c6a..1fa4374 100644 (file)
@@ -17,8 +17,8 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 //  02111-1307, USA.
-
 #include <config.h>
+
 #include <stdio.h>
 
 #include "flyingsnowball.hpp"
@@ -31,7 +31,7 @@ FlyingSnowBall::FlyingSnowBall(const lisp::Lisp& reader)
   reader.get("x", start_position.x);
   reader.get("y", start_position.y);
   bbox.set_size(31.8, 31.8);
-  sprite = sprite_manager->create("flyingsnowball");
+  sprite = sprite_manager->create("images/creatures/flying_snowball/flying_snowball.sprite");
   physic.enable_gravity(false);
 }
 
@@ -40,7 +40,7 @@ FlyingSnowBall::FlyingSnowBall(float pos_x, float pos_y)
   start_position.x = pos_x;
   start_position.y = pos_y;
   bbox.set_size(31.8, 31.8);
-  sprite = sprite_manager->create("flyingsnowball");
+  sprite = sprite_manager->create("images/creatures/flying_snowball/flying_snowball.sprite");
   physic.enable_gravity(false);
 }
 
@@ -96,8 +96,12 @@ FlyingSnowBall::active_update(float elapsed_time)
     timer.start(FLYTIME);
   }
   movement=physic.get_movement(elapsed_time);
-  dir= Sector::current()->player->get_pos().x>get_pos().x?RIGHT:LEFT;
-  sprite->set_action(dir == LEFT ? "left" : "right");
+
+  Player* player = this->get_nearest_player();
+  if (player) {
+    dir = (player->get_pos().x > get_pos().x) ? RIGHT : LEFT;
+    sprite->set_action(dir == LEFT ? "left" : "right");
+  }
 }
 
 IMPLEMENT_FACTORY(FlyingSnowBall, "flyingsnowball")