From: Marek Moeckel Date: Thu, 7 Apr 2005 10:32:23 +0000 (+0000) Subject: badguys now have normal hitpoints and bullet hitpoints, so you can make them need... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=908a780ca974cc9d8bf6c2815d9eec6e8ec25fbb;p=supertux.git badguys now have normal hitpoints and bullet hitpoints, so you can make them need more bullets than jumps on the head. A jump on the head will also decrease bullet hitpoints; both default to 1. SVN-Revision: 2357 --- diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index d96ca3bb1..1c1f581ca 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -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); diff --git a/src/badguy/badguy.h b/src/badguy/badguy.h index bb31e718d..e770feb61 100644 --- a/src/badguy/badguy.h +++ b/src/badguy/badguy.h @@ -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(); diff --git a/src/badguy/nolok_01.cpp b/src/badguy/nolok_01.cpp index d9404c557..933a5d1dc 100644 --- a/src/badguy/nolok_01.cpp +++ b/src/badguy/nolok_01.cpp @@ -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); diff --git a/src/badguy/yeti.cpp b/src/badguy/yeti.cpp index 8ab9f9d62..5412c9753 100644 --- a/src/badguy/yeti.cpp +++ b/src/badguy/yeti.cpp @@ -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);