[Super-tux-commit] supertux/src/badguy badguy.cpp,1.7,1.8 bomb.cpp,1.4,1.5 bomb.h,1.2,1.3 bouncing_s
Brought to you by:
wkendrick
From: Matze B. <mat...@us...> - 2004-11-29 00:12:38
|
Update of /cvsroot/super-tux/supertux/src/badguy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6159/src/badguy Modified Files: badguy.cpp bomb.cpp bomb.h bouncing_snowball.cpp bouncing_snowball.h jumpy.cpp jumpy.h mrbomb.cpp mrbomb.h mriceblock.cpp mriceblock.h snowball.cpp snowball.h spiky.cpp spiky.h Log Message: make badguys bounce of each other again, make bombs and kicked mriceblocks kill other enemies, make kicked mriceblock open bonusblocks and destroy bricks Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/badguy.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- badguy.cpp 26 Nov 2004 14:45:41 -0000 1.7 +++ badguy.cpp 29 Nov 2004 00:12:24 -0000 1.8 @@ -97,7 +97,7 @@ return collision_solid(other, hit); BadGuy* badguy = dynamic_cast<BadGuy*> (&other); - if(badguy) + if(badguy && badguy->state == STATE_ACTIVE) return collision_badguy(*badguy, hit); Player* player = dynamic_cast<Player*> (&other); Index: snowball.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/snowball.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- snowball.h 28 Nov 2004 14:56:51 -0000 1.4 +++ snowball.h 29 Nov 2004 00:12:24 -0000 1.5 @@ -12,6 +12,7 @@ void activate(); void write(lisp::Writer& writer); HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit); protected: bool collision_squished(Player& player); Index: spiky.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/spiky.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- spiky.h 28 Nov 2004 14:56:51 -0000 1.2 +++ spiky.h 29 Nov 2004 00:12:24 -0000 1.3 @@ -11,6 +11,7 @@ void activate(); void write(lisp::Writer& writer); HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); }; #endif Index: bomb.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/bomb.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- bomb.h 28 Nov 2004 14:56:50 -0000 1.2 +++ bomb.h 29 Nov 2004 00:12:24 -0000 1.3 @@ -11,6 +11,7 @@ void write(lisp::Writer& writer); HitResponse collision_solid(GameObject& other, const CollisionHit& hit); HitResponse collision_player(Player& player, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); void active_action(float elapsed_time); void kill_fall(); Index: mriceblock.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/mriceblock.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- mriceblock.cpp 28 Nov 2004 14:56:51 -0000 1.5 +++ mriceblock.cpp 29 Nov 2004 00:12:24 -0000 1.6 @@ -1,6 +1,7 @@ #include <config.h> #include "mriceblock.h" +#include "object/block.h" static const float WALKSPEED = 80; static const float KICKSPEED = 500; @@ -59,7 +60,7 @@ } HitResponse -MrIceBlock::collision_solid(GameObject& , const CollisionHit& hit) +MrIceBlock::collision_solid(GameObject& object, const CollisionHit& hit) { if(fabsf(hit.normal.y) > .5) { // floor or roof physic.set_velocity_y(0); @@ -72,13 +73,23 @@ sprite->set_action(dir == LEFT ? "left" : "right"); physic.set_velocity_x(-physic.get_velocity_x()); break; - case ICESTATE_KICKED: + case ICESTATE_KICKED: { + BonusBlock* bonusblock = dynamic_cast<BonusBlock*> (&object); + if(bonusblock) { + bonusblock->try_open(); + } + Brick* brick = dynamic_cast<Brick*> (&object); + if(brick) { + brick->try_break(); + } + dir = dir == LEFT ? RIGHT : LEFT; sprite->set_action(dir == LEFT ? "flat-left" : "flat-right"); physic.set_velocity_x(-physic.get_velocity_x()); SoundManager::get()->play_sound(IDToSound(SND_RICOCHET), get_pos(), Sector::current()->player->get_pos()); break; + } case ICESTATE_FLAT: physic.set_velocity_x(0); break; @@ -87,6 +98,29 @@ return CONTINUE; } +HitResponse +MrIceBlock::collision_badguy(BadGuy& badguy, const CollisionHit& hit) +{ + switch(ice_state) { + case ICESTATE_NORMAL: + if(fabsf(hit.normal.x) > .8) { + dir = dir == LEFT ? RIGHT : LEFT; + sprite->set_action(dir == LEFT ? "left" : "right"); + physic.set_velocity_x(-physic.get_velocity_x()); + } + return CONTINUE; + case ICESTATE_FLAT: + return FORCE_MOVE; + case ICESTATE_KICKED: + badguy.kill_fall(); + return FORCE_MOVE; + default: + assert(false); + } + + return ABORT_MOVE; +} + bool MrIceBlock::collision_squished(Player& player) { Index: bouncing_snowball.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/bouncing_snowball.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- bouncing_snowball.h 28 Nov 2004 14:56:50 -0000 1.4 +++ bouncing_snowball.h 29 Nov 2004 00:12:24 -0000 1.5 @@ -12,6 +12,7 @@ void activate(); void write(lisp::Writer& writer); HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); protected: bool collision_squished(Player& player); Index: jumpy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/jumpy.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- jumpy.cpp 28 Nov 2004 14:56:51 -0000 1.4 +++ jumpy.cpp 29 Nov 2004 00:12:24 -0000 1.5 @@ -24,15 +24,26 @@ } HitResponse -Jumpy::collision_solid(GameObject& , const CollisionHit& hit) +Jumpy::collision_solid(GameObject& , const CollisionHit& chit) +{ + return hit(chit); +} + +HitResponse +Jumpy::collision_badguy(BadGuy& , const CollisionHit& chit) +{ + return hit(chit); +} + +HitResponse +Jumpy::hit(const CollisionHit& chit) { // hit floor? - if(hit.normal.y < -.5) { + if(chit.normal.y < -.5) { physic.set_velocity_y(JUMPSPEED); - } else if(hit.normal.y < .5) { // bumped on roof + } else if(chit.normal.y < .5) { // bumped on roof physic.set_velocity_y(0); } return CONTINUE; } - Index: jumpy.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/jumpy.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- jumpy.h 28 Nov 2004 14:56:51 -0000 1.2 +++ jumpy.h 29 Nov 2004 00:12:24 -0000 1.3 @@ -8,10 +8,13 @@ public: Jumpy(const lisp::Lisp& reader); - virtual HitResponse collision_solid(GameObject& other, - const CollisionHit& hit); + HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit); - virtual void write(lisp::Writer& writer); + void write(lisp::Writer& writer); + +private: + HitResponse hit(const CollisionHit& hit); }; #endif Index: bouncing_snowball.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/bouncing_snowball.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- bouncing_snowball.cpp 28 Nov 2004 14:56:50 -0000 1.6 +++ bouncing_snowball.cpp 29 Nov 2004 00:12:24 -0000 1.7 @@ -67,3 +67,17 @@ return CONTINUE; } +HitResponse +BouncingSnowball::collision_badguy(BadGuy& , const CollisionHit& hit) +{ + if(fabsf(hit.normal.x) > .8) { // left/right? + dir = dir == LEFT ? RIGHT : LEFT; + sprite->set_action(dir == LEFT ? "left" : "right"); + physic.set_velocity_x(-physic.get_velocity_x()); + } else if(hit.normal.y < -.8) { // grounf + physic.set_velocity_y(JUMPSPEED); + } + + return CONTINUE; +} + Index: spiky.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/spiky.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- spiky.cpp 28 Nov 2004 14:56:51 -0000 1.4 +++ spiky.cpp 29 Nov 2004 00:12:24 -0000 1.5 @@ -44,3 +44,15 @@ return CONTINUE; } +HitResponse +Spiky::collision_badguy(BadGuy& , const CollisionHit& hit) +{ + if(fabsf(hit.normal.x) > .8) { // left or right + dir = dir == LEFT ? RIGHT : LEFT; + sprite->set_action(dir == LEFT ? "left" : "right"); + physic.set_velocity_x(-physic.get_velocity_x()); + } + + return CONTINUE; +} + Index: mriceblock.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/mriceblock.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mriceblock.h 28 Nov 2004 14:56:51 -0000 1.3 +++ mriceblock.h 29 Nov 2004 00:12:24 -0000 1.4 @@ -11,7 +11,8 @@ void activate(); void write(lisp::Writer& writer); - HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_solid(GameObject& object, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); void active_action(float elapsed_time); Index: mrbomb.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/mrbomb.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- mrbomb.cpp 28 Nov 2004 14:56:51 -0000 1.7 +++ mrbomb.cpp 29 Nov 2004 00:12:24 -0000 1.8 @@ -66,3 +66,14 @@ return CONTINUE; } +HitResponse +MrBomb::collision_badguy(BadGuy& , const CollisionHit& hit) +{ + if(fabsf(hit.normal.x) > .8) { // left or right + dir = dir == LEFT ? RIGHT : LEFT; + sprite->set_action(dir == LEFT ? "left" : "right"); + physic.set_velocity_x(-physic.get_velocity_x()); + } + + return CONTINUE; +} Index: snowball.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/snowball.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- snowball.cpp 28 Nov 2004 14:56:51 -0000 1.6 +++ snowball.cpp 29 Nov 2004 00:12:24 -0000 1.7 @@ -64,3 +64,15 @@ return CONTINUE; } +HitResponse +SnowBall::collision_badguy(BadGuy& , const CollisionHit& hit) +{ + if(fabsf(hit.normal.x) > .8) { // left or right hit + dir = dir == LEFT ? RIGHT : LEFT; + sprite->set_action(dir == LEFT ? "left" : "right"); + physic.set_velocity_x(-physic.get_velocity_x()); + } + + return CONTINUE; +} + Index: bomb.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/bomb.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- bomb.cpp 28 Nov 2004 14:56:50 -0000 1.4 +++ bomb.cpp 29 Nov 2004 00:12:24 -0000 1.5 @@ -41,6 +41,13 @@ return ABORT_MOVE; } +HitResponse +Bomb::collision_badguy(BadGuy& badguy, const CollisionHit& ) +{ + badguy.kill_fall(); + return ABORT_MOVE; +} + void Bomb::active_action(float ) { Index: mrbomb.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/mrbomb.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- mrbomb.h 28 Nov 2004 14:56:51 -0000 1.4 +++ mrbomb.h 29 Nov 2004 00:12:24 -0000 1.5 @@ -12,6 +12,7 @@ void activate(); void write(lisp::Writer& writer); HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); protected: bool collision_squished(Player& player); |