From: Marek Moeckel Date: Thu, 7 Apr 2005 11:17:51 +0000 (+0000) Subject: changed yeti behaviour back to Matze's version (sorry, paroneayea) X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=12b299773de327f4e1bb42311f6eafa7709c6440;p=supertux.git changed yeti behaviour back to Matze's version (sorry, paroneayea) properly implemented hitpoints (to see paroneayea's version, check out revision 2355) SVN-Revision: 2359 --- diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index 8b6186305..fbe72194c 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -146,7 +146,7 @@ BadGuy::collision_player(Player& player, const CollisionHit& hit) return FORCE_MOVE; } } - std::cout << "COLLISION - HITPOINTS: " << hitpoints << ", BULLLET HP: " << bullet_hitpoints << std::endl; + std::cout << "COLLISION - HITPOINTS: " << hitpoints << ", BULLET HP: " << bullet_hitpoints << std::endl; player.kill(Player::SHRINK); return FORCE_MOVE; } @@ -187,7 +187,7 @@ BadGuy::kill_fall() physic.enable_gravity(true); set_state(STATE_FALLING); } - std::cout << "KILL_FALL - HITPOINTS: " << hitpoints << ", BULLLET HP: " << bullet_hitpoints << std::endl; + std::cout << "KILL_FALL - HITPOINTS: " << hitpoints << ", BULLET HP: " << bullet_hitpoints << std::endl; } void diff --git a/src/badguy/nolok_01.cpp b/src/badguy/nolok_01.cpp index b0798f419..47e55895d 100644 --- a/src/badguy/nolok_01.cpp +++ b/src/badguy/nolok_01.cpp @@ -129,7 +129,7 @@ Nolok_01::kill_fall() set_state(STATE_FALLING); Sector::current()->add_object(new Door((int)get_pos().x+32, 512, "sector1", "main2")); } - std::cout << "KILL_FALL - HITPOINTS: " << hitpoints << ", BULLLET HP: " << bullet_hitpoints << std::endl; + std::cout << "KILL_FALL - HITPOINTS: " << hitpoints << ", BULLET HP: " << bullet_hitpoints << std::endl; } IMPLEMENT_FACTORY(Nolok_01, "nolok_01") diff --git a/src/badguy/stalactite.cpp b/src/badguy/stalactite.cpp index b562ff2b9..1a0b36739 100644 --- a/src/badguy/stalactite.cpp +++ b/src/badguy/stalactite.cpp @@ -99,13 +99,4 @@ Stalactite::deactivate() remove_me(); } -bool -Stalactite::is_harmful() -{ - if (state == STALACTITE_SQUISHED) - return false; - else - return true; -} - IMPLEMENT_FACTORY(Stalactite, "stalactite") diff --git a/src/badguy/stalactite.h b/src/badguy/stalactite.h index 52b9d5bd2..68cdac57b 100644 --- a/src/badguy/stalactite.h +++ b/src/badguy/stalactite.h @@ -17,9 +17,6 @@ public: void draw(DrawingContext& context); void deactivate(); - // returns whether or not the stalactite is harmful in it's current state - bool is_harmful(); - protected: Timer2 timer; diff --git a/src/badguy/yeti.cpp b/src/badguy/yeti.cpp index 5412c9753..20b849cf8 100644 --- a/src/badguy/yeti.cpp +++ b/src/badguy/yeti.cpp @@ -7,10 +7,9 @@ static const float JUMP_VEL1 = 250; static const float JUMP_VEL2 = 700; -static const float RUN_SPEED = 300; +static const float RUN_SPEED = 350; 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; @@ -28,7 +27,6 @@ Yeti::Yeti(const lisp::Lisp& reader) get_resource_filename("sounds/yeti_gna.wav")); sound_roar = SoundManager::get()->load_sound( get_resource_filename("sounds/yeti_roar.wav")); - jump_time_left = 0.0f; } Yeti::~Yeti() @@ -44,27 +42,21 @@ Yeti::active_action(float elapsed_time) break; case GO_RIGHT: physic.set_velocity_x(RUN_SPEED); - if(jump_timer.check()) + if(timer.check()) physic.set_velocity_y(JUMP_VEL2); break; case GO_LEFT: physic.set_velocity_x(-RUN_SPEED); - if(jump_timer.check()) + if(timer.check()) physic.set_velocity_y(JUMP_VEL2); break; case ANGRY_JUMPING: - if(jump_timer.check()) { + if(timer.check()) { // jump SoundManager::get()->play_sound(sound_gna); physic.set_velocity_y(JUMP_VEL1); } break; - - case STUNNED: - if (stun_timer.check()) { - go_right(); - } - default: break; } @@ -79,7 +71,7 @@ Yeti::go_right() physic.set_velocity_y(JUMP_VEL1); physic.set_velocity_x(RUN_SPEED); state = GO_RIGHT; - jump_timer.start(JUMP_TIME); + timer.start(JUMP_TIME); } void @@ -88,41 +80,29 @@ Yeti::go_left() physic.set_velocity_y(JUMP_VEL1); physic.set_velocity_x(-RUN_SPEED); state = GO_LEFT; - jump_timer.start(JUMP_TIME); + timer.start(JUMP_TIME); } void Yeti::angry_jumping() { jumpcount = 0; - jump_timer.start(ANGRY_JUMP_WAIT); + timer.start(ANGRY_JUMP_WAIT); state = ANGRY_JUMPING; physic.set_velocity_x(0); } -void -Yeti::stun() -{ - physic.set_acceleration(0.0f, 0.0f); - physic.set_velocity(0.0f, 0.0f); - jump_time_left = jump_timer.get_timeleft(); - jump_timer.stop(); - stun_timer.start(STUN_TIME); - state = STUNNED; -} - HitResponse Yeti::collision_player(Player& player, const CollisionHit& hit) -{ +{ if(player.is_invincible()) { kill_fall(); 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) hitpoints--; bullet_hitpoints--; + SoundManager::get()->play_sound(sound_roar); if(collision_squished(player)) return ABORT_MOVE; else if (hitpoints <= 0) { @@ -131,38 +111,23 @@ Yeti::collision_player(Player& player, const CollisionHit& hit) return FORCE_MOVE; } } - - if (state == STUNNED) - return ABORT_MOVE; - + std::cout << "COLLISION - HITPOINTS: " << hitpoints << ", BULLET HP: " << bullet_hitpoints << std::endl; player.kill(Player::SHRINK); return FORCE_MOVE; } -HitResponse -Yeti::collision_badguy(BadGuy& badguy, const CollisionHit&) -{ - YetiStalactite* yeti_stal = dynamic_cast(&badguy); - - if (state == STUNNED && yeti_stal && yeti_stal->is_harmful()) - { - kill_fall(); - } - - return FORCE_MOVE; -} - - bool Yeti::collision_squished(Player& player) { - // we don't use the player object, even though it was given to us - (void)player; - - // stun yeti - stun(); - - return true; + bool result = false; + player.bounce(*this); + if (hitpoints <= 0) { + bullet_hitpoints = 0; + //sprite->set_action("dead"); + kill_squished(player); + result = true; + } + return result; } void @@ -201,14 +166,14 @@ Yeti::collision_solid(GameObject& , const CollisionHit& hit) physic.set_velocity_y(0); if(state == INIT) { go_right(); - } else if(state == GO_LEFT && !jump_timer.started()) { + } else if(state == GO_LEFT && !timer.started()) { side = LEFT; angry_jumping(); - } else if(state == GO_RIGHT && !jump_timer.started()) { + } else if(state == GO_RIGHT && !timer.started()) { side = RIGHT; angry_jumping(); } else if(state == ANGRY_JUMPING) { - if(!jump_timer.started()) { + if(!timer.started()) { // we just landed jumpcount++; // make a stalactite falling down and shake camera a bit @@ -223,7 +188,7 @@ Yeti::collision_solid(GameObject& , const CollisionHit& hit) go_left(); } else { // jump again - jump_timer.start(ANGRY_JUMP_WAIT); + timer.start(ANGRY_JUMP_WAIT); } } } @@ -244,6 +209,7 @@ Yeti::kill_fall() physic.enable_gravity(true); set_state(STATE_FALLING); } + std::cout << "KILL_FALL - HITPOINTS: " << hitpoints << ", BULLET HP: " << bullet_hitpoints << std::endl; } IMPLEMENT_FACTORY(Yeti, "yeti") diff --git a/src/badguy/yeti.h b/src/badguy/yeti.h index cf36b5a84..36d901204 100644 --- a/src/badguy/yeti.h +++ b/src/badguy/yeti.h @@ -13,7 +13,6 @@ public: void active_action(float elapsed_time); HitResponse collision_solid(GameObject& other, const CollisionHit& hit); HitResponse collision_player(Player& player, const CollisionHit& hit); - HitResponse collision_badguy(BadGuy& badguy, const CollisionHit&); bool collision_squished(Player& player); void kill_fall(); @@ -21,7 +20,6 @@ private: void go_right(); void go_left(); void angry_jumping(); - void stun(); void drop_stalactite(); enum YetiState { @@ -29,8 +27,7 @@ private: ANGRY_JUMPING, THROW_SNOWBALL, GO_RIGHT, - GO_LEFT, - STUNNED + GO_LEFT }; enum Side { LEFT, @@ -38,10 +35,8 @@ private: }; Side side; YetiState state; - Timer2 jump_timer; - Timer2 stun_timer; + Timer2 timer; int jumpcount; - float jump_time_left; Mix_Chunk* sound_gna; Mix_Chunk* sound_roar; };