badguys now have normal hitpoints and bullet hitpoints, so you can make them need...
authorMarek Moeckel <wansti@gmx.de>
Thu, 7 Apr 2005 10:32:23 +0000 (10:32 +0000)
committerMarek Moeckel <wansti@gmx.de>
Thu, 7 Apr 2005 10:32:23 +0000 (10:32 +0000)
SVN-Revision: 2357

src/badguy/badguy.cpp
src/badguy/badguy.h
src/badguy/nolok_01.cpp
src/badguy/yeti.cpp

index d96ca3b..1c1f581 100644 (file)
@@ -10,8 +10,9 @@ static const float Y_OFFSCREEN_DISTANCE = 1200;
 BadGuy::BadGuy()
   : sprite(0), dir(LEFT), state(STATE_INIT)
 {
-  //TODO: Count fireball hits separately so you can make badguys need more fireballs than jumps
+  //Set hitpoints and bullet hitpoints
   hitpoints = 1;
+  bullet_hitpoints = 1;
 }
 
 BadGuy::~BadGuy()
@@ -136,9 +137,11 @@ BadGuy::collision_player(Player& player, const CollisionHit& hit)
     //TODO: fix inaccuracy (tux sometimes dies even if badguy was hit)
     //      give badguys some invincible time (prevent them from being hit multiple times)
     hitpoints--;
+    bullet_hitpoints--;
     if(collision_squished(player))
       return ABORT_MOVE;
     else if (hitpoints <= 0) {
+      bullet_hitpoints = 0;
       player.kill(Player::SHRINK);
       return FORCE_MOVE;
     }
@@ -174,8 +177,8 @@ BadGuy::kill_squished(Player& player)
 void
 BadGuy::kill_fall()
 {
-  hitpoints--;
-  if (hitpoints <= 0) {
+  bullet_hitpoints--;
+  if (bullet_hitpoints <= 0) {
     SoundManager::get()->play_sound(IDToSound(SND_FALL), this,
        Sector::current()->player->get_pos());
     physic.set_velocity_y(0);
index bb31e71..e770feb 100644 (file)
@@ -90,7 +90,7 @@ protected:
    * variable might have been changed so that it faces towards the player.
    */
   virtual void activate();
-  /** caleed when the badguy has been deactivated */
+  /** called when the badguy has been deactivated */
   virtual void deactivate();
 
   void kill_squished(Player& player);
@@ -122,6 +122,7 @@ protected:
   Direction dir;
 
   int hitpoints;
+  int bullet_hitpoints;
 private:
   void try_activate();
   
index d9404c5..933a5d1 100644 (file)
@@ -8,6 +8,7 @@
 #define SHOOT_TIME 0.4
 #define JUMP_TIME 0.5
 #define INITIAL_HITPOINTS 3
+#define INITIAL_BULLET_HP 10
 
 static const float WALKSPEED = 90;
 
@@ -43,6 +44,7 @@ void
 Nolok_01::activate()
 {
   hitpoints = INITIAL_HITPOINTS;
+  bullet_hitpoints = INITIAL_BULLET_HP;
   physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
   sprite->set_action(dir == LEFT ? "left" : "right");
   action = WALKING;
@@ -90,6 +92,7 @@ Nolok_01::collision_squished(Player& player)
   bool result = false;
   player.bounce(*this);
   if (hitpoints <= 0) {
+    bullet_hitpoints = 0;
     sprite->set_action("dead"); 
     kill_squished(player);
     Sector::current()->add_object(new Door((int)get_pos().x+32, 512, "sector1", "main2"));
@@ -116,8 +119,8 @@ Nolok_01::collision_solid(GameObject& , const CollisionHit& hit)
 void
 Nolok_01::kill_fall()
 {
-  hitpoints--;
-  if (hitpoints <= 0) {
+  bullet_hitpoints--;
+  if (bullet_hitpoints <= 0) {
    SoundManager::get()->play_sound(IDToSound(SND_FALL), this,
          Sector::current()->player->get_pos());
    physic.set_velocity_y(0);
index 8ab9f9d..5412c97 100644 (file)
@@ -12,6 +12,7 @@ static const float JUMP_TIME = 1.6;
 static const float ANGRY_JUMP_WAIT = .5;
 static const float STUN_TIME = 2;
 static const int INITIAL_HITPOINTS = 3;
+static const int INITIAL_BULLET_HP = 10;
 
 Yeti::Yeti(const lisp::Lisp& reader)
 {
@@ -22,6 +23,7 @@ Yeti::Yeti(const lisp::Lisp& reader)
   state = INIT;
   side = LEFT;
   hitpoints = INITIAL_HITPOINTS;
+  bullet_hitpoints = INITIAL_BULLET_HP;
   sound_gna = SoundManager::get()->load_sound(
       get_resource_filename("sounds/yeti_gna.wav"));
   sound_roar = SoundManager::get()->load_sound(
@@ -120,9 +122,11 @@ Yeti::collision_player(Player& player, const CollisionHit& hit)
     //TODO: fix inaccuracy (tux sometimes dies even if badguy was hit)
     //      give badguys some invincible time (prevent them from being hit multiple times)
     hitpoints--;
+    bullet_hitpoints--;
     if(collision_squished(player))
       return ABORT_MOVE;
     else if (hitpoints <= 0) {
+      bullet_hitpoints = 0;
       player.kill(Player::SHRINK);
       return FORCE_MOVE;
     }
@@ -232,8 +236,8 @@ void
 Yeti::kill_fall()
 {
   SoundManager::get()->play_sound(sound_roar);
-  hitpoints--;
-  if (hitpoints <= 0) {
+  bullet_hitpoints--;
+  if (bullet_hitpoints <= 0) {
     SoundManager::get()->play_sound(IDToSound(SND_FALL), this,
        Sector::current()->player->get_pos());
     physic.set_velocity_y(0);