[ Patch #1793 ] Turn physic into POD
[supertux.git] / src / badguy / kugelblitz.cpp
index 558c562..0d14a5a 100644 (file)
@@ -34,14 +34,11 @@ static const float X_OFFSCREEN_DISTANCE = 1600;
 static const float Y_OFFSCREEN_DISTANCE = 1200;
 
 Kugelblitz::Kugelblitz(const lisp::Lisp& reader)
-    : groundhit_pos_set(false)
+    : BadGuy(Vector(0,0), "images/creatures/kugelblitz/kugelblitz.sprite"), groundhit_pos_set(false)
 {
   reader.get("x", start_position.x);
-  start_position.y = 0; //place above visible area
-  bbox.set_size(63.8, 63.8);
-  sprite = sprite_manager->create("images/creatures/kugelblitz/kugelblitz.sprite");
   sprite->set_action("falling");
-  physic.enable_gravity(false);
+  physic.gravity_enabled = false;
 }
 
 void
@@ -57,16 +54,16 @@ Kugelblitz::write(lisp::Writer& writer)
 void
 Kugelblitz::activate()
 {
-  physic.set_velocity_y(-300);
-  physic.set_velocity_x(-20); //fall a little to the left
+  physic.vy = 300;
+  physic.vx = -20; //fall a little to the left
   direction = 1;
   dying = false;
 }
 
-HitResponse
-Kugelblitz::collision_solid(GameObject& , const CollisionHit& chit)
+void
+Kugelblitz::collision_solid(const CollisionHit& chit)
 {
-  return hit(chit);
+  hit(chit);
 }
 
 HitResponse
@@ -100,26 +97,26 @@ Kugelblitz::collision_badguy(BadGuy& other , const CollisionHit& chit)
 }
 
 HitResponse
-Kugelblitz::hit(const CollisionHit& chit)
+Kugelblitz::hit(const CollisionHit& hit)
 {
   // hit floor?
-  if(chit.normal.y < -.5) {
+  if(hit.bottom) {
     if (!groundhit_pos_set)
     {
       pos_groundhit = get_pos();
       groundhit_pos_set = true;
     }
     sprite->set_action("flying");
-    physic.set_velocity_y(0);
+    physic.vy = 0;
     //Set random initial speed and direction
     direction = systemRandom.rand(2)? 1: -1;
     int speed = (BASE_SPEED + (systemRandom.rand(RAND_SPEED))) * direction;
-    physic.set_velocity_x(speed);
+    physic.vx = speed;
     movement_timer.start(MOVETIME);
     lifetime.start(LIFETIME);
 
-  } else if(chit.normal.y < .5) { // bumped on roof
-    physic.set_velocity_y(0);
+  } else if(hit.top) { // bumped on roof
+    physic.vy = 0;
   }
 
   return CONTINUE;
@@ -136,10 +133,11 @@ Kugelblitz::active_update(float elapsed_time)
       if (movement_timer.check()) {
         if (direction == 1) direction = -1; else direction = 1;
         int speed = (BASE_SPEED + (systemRandom.rand(RAND_SPEED))) * direction;
-        physic.set_velocity_x(speed);
+        physic.vx = speed;
         movement_timer.start(MOVETIME);
       }
     }
+    /*
     if (Sector::current()->solids->get_tile_at(get_pos())->getAttributes() == 16) {
       //HIT WATER
       Sector::current()->add_object(new Electrifier(75,1421,1.5));
@@ -150,8 +148,9 @@ Kugelblitz::active_update(float elapsed_time)
       //HIT ELECTRIFIED WATER
       explode();
     }
+    */
   }
-  BadGuy::active_update(elapsed_time);  
+  BadGuy::active_update(elapsed_time);
 }
 
 void