Made trampolines less likely to interfere with level design:
[supertux.git] / src / badguy / snowball.cpp
index 889578e..2876357 100644 (file)
 
 #include "snowball.hpp"
 
-static const float WALKSPEED = 80;
-
 SnowBall::SnowBall(const lisp::Lisp& reader)
-       : BadGuy(reader, "images/creatures/snowball/snowball.sprite")
+    : WalkingBadguy(reader, "images/creatures/snowball/snowball.sprite", "left", "right")
 {
+  walk_speed = 80;
 }
 
 SnowBall::SnowBall(const Vector& pos, Direction d)
-       : BadGuy(pos, d, "images/creatures/snowball/snowball.sprite")
+    : WalkingBadguy(pos, d, "images/creatures/snowball/snowball.sprite", "left", "right")
 {
+  walk_speed = 80;
 }
 
 void
 SnowBall::write(lisp::Writer& writer)
 {
   writer.start_list("snowball");
-
-  writer.write_float("x", start_position.x);
-  writer.write_float("y", start_position.y);
-  /*
-  if (fluffy) {  // don't give us away at every snowball
-    writer.write_bool("fluffy", true);
-  }
-  */
+  WalkingBadguy::write(writer);
   writer.end_list("snowball");
 }
 
-void
-SnowBall::activate()
-{
-  physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
-  sprite->set_action(dir == LEFT ? "left" : "right");
-}
-
 bool
 SnowBall::collision_squished(Player& player)
 {
@@ -63,30 +49,4 @@ SnowBall::collision_squished(Player& player)
   return true;
 }
 
-HitResponse
-SnowBall::collision_solid(GameObject& , const CollisionHit& hit)
-{
-  if(fabsf(hit.normal.y) > .5) { // hit floor or roof?
-    physic.set_velocity_y(0);
-  } else { // hit right or left
-    dir = dir == LEFT ? RIGHT : LEFT;
-    sprite->set_action(dir == LEFT ? "left" : "right");
-    physic.set_velocity_x(-physic.get_velocity_x());
-  }
-
-  return CONTINUE;
-}
-
-HitResponse
-SnowBall::collision_badguy(BadGuy& , const CollisionHit& hit)
-{
-  if(fabsf(hit.normal.x) > .8) { // left or right hit
-    dir = dir == LEFT ? RIGHT : LEFT;
-    sprite->set_action(dir == LEFT ? "left" : "right");
-    physic.set_velocity_x(-physic.get_velocity_x());       
-  }
-
-  return CONTINUE;
-}
-
 IMPLEMENT_FACTORY(SnowBall, "snowball")