Applied new FPS reg. patch from Enrico
[supertux.git] / src / badguy / badguy.cpp
index 0b80172..fbe7219 100644 (file)
@@ -10,7 +10,9 @@ static const float Y_OFFSCREEN_DISTANCE = 1200;
 BadGuy::BadGuy()
   : sprite(0), dir(LEFT), state(STATE_INIT)
 {
+  //Set hitpoints and bullet hitpoints
   hitpoints = 1;
+  bullet_hitpoints = 1;
 }
 
 BadGuy::~BadGuy()
@@ -134,16 +136,17 @@ BadGuy::collision_player(Player& player, const CollisionHit& hit)
   if(hit.normal.y > .9) {
     //TODO: fix inaccuracy (tux sometimes dies even if badguy was hit)
     //      give badguys some invincible time (prevent them from being hit multiple times)
-    //      use hitpoints also when hit by fireball or invincible tux
     hitpoints--;
-    std::cout << "Hitpoints: " << hitpoints << std::endl;
+    bullet_hitpoints--;
     if(collision_squished(player))
       return ABORT_MOVE;
     else if (hitpoints <= 0) {
+      bullet_hitpoints = 0;
       player.kill(Player::SHRINK);
       return FORCE_MOVE;
     }
   }
+  std::cout << "COLLISION - HITPOINTS: " << hitpoints << ", BULLET HP: " << bullet_hitpoints << std::endl;
   player.kill(Player::SHRINK);
   return FORCE_MOVE;
 }
@@ -175,11 +178,16 @@ BadGuy::kill_squished(Player& player)
 void
 BadGuy::kill_fall()
 {
-  SoundManager::get()->play_sound(IDToSound(SND_FALL), this,
-      Sector::current()->player->get_pos());
-  physic.set_velocity_y(0);
-  physic.enable_gravity(true);
-  set_state(STATE_FALLING);
+  bullet_hitpoints--;
+  if (bullet_hitpoints <= 0) {
+    hitpoints = 0;
+    SoundManager::get()->play_sound(IDToSound(SND_FALL), this,
+       Sector::current()->player->get_pos());
+    physic.set_velocity_y(0);
+    physic.enable_gravity(true);
+    set_state(STATE_FALLING);
+  }
+  std::cout << "KILL_FALL - HITPOINTS: " << hitpoints << ", BULLET HP: " << bullet_hitpoints << std::endl;
 }
 
 void