[Super-tux-commit] supertux/src/badguy dispenser.cpp,1.5,1.6 nolok_01.cpp,1.1,1.2 nolok_01.h,1.1,1.2
Brought to you by:
wkendrick
From: Marek M. <wa...@us...> - 2004-11-25 13:20:06
|
Update of /cvsroot/super-tux/supertux/src/badguy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23444/src/badguy Modified Files: dispenser.cpp nolok_01.cpp nolok_01.h Log Message: added (temporary) dispenser sprites improved nolok code Index: nolok_01.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/nolok_01.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- nolok_01.h 25 Nov 2004 11:16:03 -0000 1.1 +++ nolok_01.h 25 Nov 2004 13:19:51 -0000 1.2 @@ -18,8 +18,8 @@ protected: bool collision_squished(Player& player); Timer2 action_timer; - Timer2 idle_timer; - Timer2 jump_timer; + enum { IDLE, WALKING, JUMPING, SHOOTING }; + int action; }; #endif Index: nolok_01.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/nolok_01.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- nolok_01.cpp 25 Nov 2004 11:16:03 -0000 1.1 +++ nolok_01.cpp 25 Nov 2004 13:19:51 -0000 1.2 @@ -44,7 +44,8 @@ { 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 @@ { 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); + } } } Index: dispenser.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/dispenser.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- dispenser.cpp 25 Nov 2004 11:16:03 -0000 1.5 +++ dispenser.cpp 25 Nov 2004 13:19:37 -0000 1.6 @@ -12,9 +12,8 @@ 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 @@ 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; } |