From: Marek Moeckel Date: Thu, 7 Apr 2005 14:38:14 +0000 (+0000) Subject: yeti summons snowballs now X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e8a1d89d3d0f4824d3d906ca67149afec0a75e4b;p=supertux.git yeti summons snowballs now SVN-Revision: 2360 --- diff --git a/src/badguy/dispenser.cpp b/src/badguy/dispenser.cpp index 33bd1c9b7..58e7c3ef4 100644 --- a/src/badguy/dispenser.cpp +++ b/src/badguy/dispenser.cpp @@ -78,8 +78,7 @@ Dispenser::launch_badguy() else if (badguy == "mriceblock") Sector::current()->add_object(new MrIceBlock(get_pos().x, get_pos().y+32, dir)); else if (badguy == "mrrocket") { - int offset = (dir == LEFT ? -32 : 32); - Sector::current()->add_object(new MrRocket(get_pos().x+offset, get_pos().y, dir));} + Sector::current()->add_object(new MrRocket(get_pos().x+(dir == LEFT ? -32 : 32), get_pos().y, dir));} else if (badguy == "poisonivy") Sector::current()->add_object(new PoisonIvy(get_pos().x, get_pos().y+32, dir)); else if (badguy == "random") diff --git a/src/badguy/yeti.cpp b/src/badguy/yeti.cpp index 20b849cf8..d16af0bb9 100644 --- a/src/badguy/yeti.cpp +++ b/src/badguy/yeti.cpp @@ -4,6 +4,7 @@ #include "yeti.h" #include "object/camera.h" #include "yeti_stalactite.h" +#include "bouncing_snowball.h" static const float JUMP_VEL1 = 250; static const float JUMP_VEL2 = 700; @@ -92,6 +93,12 @@ Yeti::angry_jumping() physic.set_velocity_x(0); } +void +Yeti::summon_snowball() +{ + Sector::current()->add_object(new BouncingSnowball(get_pos().x+(side == LEFT ? 64 : -64), get_pos().y, (side == LEFT ? RIGHT : LEFT))); +} + HitResponse Yeti::collision_player(Player& player, const CollisionHit& hit) { @@ -168,9 +175,11 @@ Yeti::collision_solid(GameObject& , const CollisionHit& hit) go_right(); } else if(state == GO_LEFT && !timer.started()) { side = LEFT; + summon_snowball(); angry_jumping(); } else if(state == GO_RIGHT && !timer.started()) { side = RIGHT; + summon_snowball(); angry_jumping(); } else if(state == ANGRY_JUMPING) { if(!timer.started()) { diff --git a/src/badguy/yeti.h b/src/badguy/yeti.h index 36d901204..5e42965c4 100644 --- a/src/badguy/yeti.h +++ b/src/badguy/yeti.h @@ -21,6 +21,7 @@ private: void go_left(); void angry_jumping(); void drop_stalactite(); + void summon_snowball(); enum YetiState { INIT, @@ -29,11 +30,7 @@ private: GO_RIGHT, GO_LEFT }; - enum Side { - LEFT, - RIGHT - }; - Side side; + Direction side; YetiState state; Timer2 timer; int jumpcount;