From: Christoph Sommer Date: Sun, 6 Jan 2008 02:40:59 +0000 (+0000) Subject: Mr. Ice Block: Enforce 100ms delay between squish and kick (closes issue 238); kill... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=9aaf3e33f5549191b84ec7cc1a50fe3491f5a7e0;p=supertux.git Mr. Ice Block: Enforce 100ms delay between squish and kick (closes issue 238); kill Mr. Ice Block after 10 bounces SVN-Revision: 5254 --- diff --git a/src/badguy/mriceblock.cpp b/src/badguy/mriceblock.cpp index cb801b300..f5d927eac 100644 --- a/src/badguy/mriceblock.cpp +++ b/src/badguy/mriceblock.cpp @@ -25,6 +25,7 @@ namespace { const float KICKSPEED = 500; const int MAXSQUISHES = 10; + const float NOKICK_TIME = 0.1f; } MrIceBlock::MrIceBlock(const lisp::Lisp& reader) @@ -105,10 +106,12 @@ MrIceBlock::collision_solid(const CollisionHit& hit) if(hit.right && dir == RIGHT) { dir = LEFT; sound_manager->play("sounds/iceblock_bump.wav", get_pos()); + if(++squishcount >= MAXSQUISHES) { kill_fall(); break; } physic.set_velocity_x(-KICKSPEED); } else if(hit.left && dir == LEFT) { dir = RIGHT; sound_manager->play("sounds/iceblock_bump.wav", get_pos()); + if(++squishcount >= MAXSQUISHES) { kill_fall(); break; } physic.set_velocity_x(KICKSPEED); } sprite->set_action(dir == LEFT ? "flat-left" : "flat-right"); @@ -190,6 +193,7 @@ MrIceBlock::collision_squished(GameObject& object) } set_state(ICESTATE_FLAT); + nokick_timer.start(NOKICK_TIME); break; case ICESTATE_FLAT: { @@ -200,7 +204,7 @@ MrIceBlock::collision_squished(GameObject& object) dir = LEFT; } } - set_state(ICESTATE_KICKED); + if (nokick_timer.check()) set_state(ICESTATE_KICKED); break; case ICESTATE_GRABBED: assert(false); diff --git a/src/badguy/mriceblock.hpp b/src/badguy/mriceblock.hpp index a00c5e734..9d6eb9774 100644 --- a/src/badguy/mriceblock.hpp +++ b/src/badguy/mriceblock.hpp @@ -60,6 +60,7 @@ private: void set_state(IceState state); IceState ice_state; + Timer nokick_timer; Timer flat_timer; int squishcount; };