[Super-tux-commit] supertux/src/badguy badguy.cpp,1.9,1.10 badguy.h,1.5,1.6 nolok_01.cpp,1.9,1.10
Brought to you by:
wkendrick
From: Marek M. <wa...@us...> - 2004-12-30 11:30:01
|
Update of /cvsroot/super-tux/supertux/src/badguy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25557/src/badguy Modified Files: badguy.cpp badguy.h nolok_01.cpp Log Message: badguys can now have multiple hitpoints (default is 1) gave Nolok 3 hitpoints Index: badguy.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/badguy.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- badguy.h 20 Dec 2004 21:24:25 -0000 1.5 +++ badguy.h 30 Dec 2004 11:29:52 -0000 1.6 @@ -91,6 +91,8 @@ Vector start_position; Direction dir; + + int hitpoints; private: void try_activate(); Index: nolok_01.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/nolok_01.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- nolok_01.cpp 20 Dec 2004 21:24:27 -0000 1.9 +++ nolok_01.cpp 30 Dec 2004 11:29:52 -0000 1.10 @@ -7,10 +7,11 @@ #define WALK_TIME 2.5 #define SHOOT_TIME 0.4 #define JUMP_TIME 0.5 +#define INITIAL_HITPOINTS 3 static const float WALKSPEED = 90; -//TODO: Create sprite, give multiple hitpoints, limit max number of snowballs +//TODO: Create sprite, limit max number of snowballs // Stop actions when pause button is hit (probably a general problem of timers) Nolok_01::Nolok_01(const lisp::Lisp& reader) { @@ -42,6 +43,7 @@ void Nolok_01::activate() { + hitpoints = INITIAL_HITPOINTS; physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED); sprite->set_action(dir == LEFT ? "left" : "right"); action = WALKING; @@ -86,10 +88,15 @@ bool Nolok_01::collision_squished(Player& player) { - sprite->set_action("dead"); - kill_squished(player); - Sector::current()->add_object(new Door((int)get_pos().x+32, 512, "sector1", "main2")); - return true; + bool result = false; + player.bounce(*this); + if (hitpoints <= 0) { + sprite->set_action("dead"); + kill_squished(player); + Sector::current()->add_object(new Door((int)get_pos().x+32, 512, "sector1", "main2")); + result = true; + } + return result; } HitResponse @@ -106,4 +113,4 @@ return CONTINUE; } -IMPLEMENT_FACTORY(Nolok_01, "nolok01") +IMPLEMENT_FACTORY(Nolok_01, "nolok_01") Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/badguy.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- badguy.cpp 5 Dec 2004 16:57:14 -0000 1.9 +++ badguy.cpp 30 Dec 2004 11:29:52 -0000 1.10 @@ -10,6 +10,7 @@ BadGuy::BadGuy() : sprite(0), dir(LEFT), state(STATE_INIT) { + hitpoints = 1; } BadGuy::~BadGuy() @@ -131,8 +132,17 @@ return ABORT_MOVE; } 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; if(collision_squished(player)) return ABORT_MOVE; + else if (hitpoints <= 0) { + player.kill(Player::SHRINK); + return FORCE_MOVE; + } } player.kill(Player::SHRINK); return FORCE_MOVE; |