From: Marek Moeckel Date: Thu, 25 Nov 2004 13:19:51 +0000 (+0000) Subject: added (temporary) dispenser sprites X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=55a19b5e43db960fc04773eb7f22edd86eac0e6c;p=supertux.git added (temporary) dispenser sprites improved nolok code SVN-Revision: 2186 --- diff --git a/data/images/shared/dispenser-broken.png b/data/images/shared/dispenser-broken.png new file mode 100644 index 000000000..dbd6dccdb Binary files /dev/null and b/data/images/shared/dispenser-broken.png differ diff --git a/data/images/shared/dispenser-working.png b/data/images/shared/dispenser-working.png new file mode 100644 index 000000000..c36e65567 Binary files /dev/null and b/data/images/shared/dispenser-working.png differ diff --git a/data/images/supertux.strf b/data/images/supertux.strf index f689b0540..85c185e7d 100644 --- a/data/images/supertux.strf +++ b/data/images/supertux.strf @@ -1107,7 +1107,20 @@ (x-offset 0) (y-offset 0) (images "shared/walkingtree-left-small-1.png"))) - + + ; Dispenser + (sprite (name "dispenser") + (action + (name "working") + (x-offset 0) + (y-offset 0) + (images "shared/dispenser-working.png")) + (action + (name "broken") + (x-offset 0) + (y-offset 0) + (images "shared/dispenser-broken.png"))) + ; Dummyguy (sprite (name "dummyguy") (action diff --git a/src/badguy/dispenser.cpp b/src/badguy/dispenser.cpp index 2975c1a89..953a32137 100644 --- a/src/badguy/dispenser.cpp +++ b/src/badguy/dispenser.cpp @@ -12,9 +12,8 @@ Dispenser::Dispenser(LispReader& reader) reader.read_float("cycle", cycle); reader.read_string("badguy", badguy); bbox.set_size(32, 32); - //FIXME: Create dispenser sprite - sprite = sprite_manager->create("dummyguy"); - sprite->set_action("stand"); + sprite = sprite_manager->create("dispenser"); + sprite->set_action("working"); } void @@ -40,7 +39,9 @@ Dispenser::activate() bool Dispenser::collision_squished(Player& player) { - remove_me(); + //FIXME: Should act like a normal tile when killed + sprite->set_action("broken"); + dispense_timer.start(0); player.bounce(*this); return true; } diff --git a/src/badguy/nolok_01.cpp b/src/badguy/nolok_01.cpp index 4bbc14e73..180ee839d 100644 --- a/src/badguy/nolok_01.cpp +++ b/src/badguy/nolok_01.cpp @@ -44,7 +44,8 @@ Nolok_01::activate() { physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED); sprite->set_action(dir == LEFT ? "left" : "right"); - action_timer.start(SHOOT_TIME, true); + action = WALKING; + action_timer.start(SHOOT_TIME); } void @@ -52,18 +53,24 @@ Nolok_01::active_action(float elapsed_time) { movement = physic.get_movement(elapsed_time); if (action_timer.check()) { - physic.set_velocity_y(700); - jump_timer.start(JUMP_TIME); - } - if (jump_timer.check()) { - sprite->set_action("throw"); - idle_timer.start(IDLE_TIME); - } - if (idle_timer.check()) { - Sector::current()->add_object(new BouncingSnowball(get_pos().x-32, get_pos().y, LEFT)); - Sector::current()->add_object(new BouncingSnowball(get_pos().x, get_pos().y, RIGHT)); - physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED); - sprite->set_action(dir == LEFT ? "left" : "right"); + if (action == WALKING) { + physic.set_velocity_y(700); + action = JUMPING; + action_timer.start(JUMP_TIME); + } + else if (action == JUMPING) { + sprite->set_action("throw"); + action = IDLE; + action_timer.start(IDLE_TIME); + } + else if (action == IDLE) { + Sector::current()->add_object(new BouncingSnowball(get_pos().x-32, get_pos().y, LEFT)); + Sector::current()->add_object(new BouncingSnowball(get_pos().x, get_pos().y, RIGHT)); + physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED); + sprite->set_action(dir == LEFT ? "left" : "right"); + action = WALKING; + action_timer.start(SHOOT_TIME); + } } } diff --git a/src/badguy/nolok_01.h b/src/badguy/nolok_01.h index 4049892db..ff32034f4 100644 --- a/src/badguy/nolok_01.h +++ b/src/badguy/nolok_01.h @@ -18,8 +18,8 @@ public: protected: bool collision_squished(Player& player); Timer2 action_timer; - Timer2 idle_timer; - Timer2 jump_timer; + enum { IDLE, WALKING, JUMPING, SHOOTING }; + int action; }; #endif