[Super-tux-commit] supertux/src/badguy dispenser.cpp,1.6,1.7 mrbomb.cpp,1.5,1.6 mrbomb.h,1.2,1.3 mri
Brought to you by:
wkendrick
Update of /cvsroot/super-tux/supertux/src/badguy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv553/src/badguy Modified Files: dispenser.cpp mrbomb.cpp mrbomb.h mriceblock.cpp mriceblock.h nolok_01.cpp nolok_01.h snowball.cpp snowball.h Log Message: updated dispenser -- can summon mriceblock, snowball, bouncing_snowball and mrbomb now fixed message display of the secret area trigger ended some more of Nolok's minor troubles :) Index: nolok_01.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/nolok_01.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- nolok_01.h 25 Nov 2004 14:59:04 -0000 1.3 +++ nolok_01.h 25 Nov 2004 16:22:05 -0000 1.4 @@ -18,8 +18,8 @@ protected: bool collision_squished(Player& player); Timer2 action_timer; - enum { WALKING, JUMPING, SHOOTING }; - int action; + enum Actions { WALKING, JUMPING, SHOOTING }; + Actions action; }; #endif Index: snowball.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/snowball.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- snowball.h 24 Nov 2004 18:19:51 -0000 1.2 +++ snowball.h 25 Nov 2004 16:22:05 -0000 1.3 @@ -7,7 +7,7 @@ { public: SnowBall(LispReader& reader); - SnowBall(float pos_x, float pos_y); + SnowBall(float pos_x, float pos_y, Direction d); void activate(); void write(LispWriter& writer); @@ -15,6 +15,8 @@ protected: bool collision_squished(Player& player); + bool set_direction; + Direction initial_direction; }; #endif Index: mriceblock.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/mriceblock.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mriceblock.cpp 25 Nov 2004 00:49:34 -0000 1.3 +++ mriceblock.cpp 25 Nov 2004 16:22:05 -0000 1.4 @@ -13,6 +13,18 @@ reader.read_float("y", start_position.y); bbox.set_size(31.8, 31.8); sprite = sprite_manager->create("mriceblock"); + set_direction = false; +} + +MrIceBlock::MrIceBlock(float pos_x, float pos_y, Direction d) + : ice_state(ICESTATE_NORMAL), squishcount(0) +{ + start_position.x = pos_x; + start_position.y = pos_y; + bbox.set_size(31.8, 31.8); + sprite = sprite_manager->create("mriceblock"); + set_direction = true; + initial_direction = d; } void @@ -29,6 +41,7 @@ void MrIceBlock::activate() { + if (set_direction) {dir = initial_direction;} physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED); sprite->set_action(dir == LEFT ? "left" : "right"); } Index: snowball.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/snowball.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- snowball.cpp 25 Nov 2004 00:49:34 -0000 1.4 +++ snowball.cpp 25 Nov 2004 16:22:05 -0000 1.5 @@ -10,14 +10,17 @@ reader.read_float("y", start_position.y); bbox.set_size(31.8, 31.8); sprite = sprite_manager->create("snowball"); + set_direction = false; } -SnowBall::SnowBall(float pos_x, float pos_y) +SnowBall::SnowBall(float pos_x, float pos_y, Direction d) { start_position.x = pos_x; start_position.y = pos_y; bbox.set_size(31.8, 31.8); sprite = sprite_manager->create("snowball"); + set_direction = true; + initial_direction = d; } void @@ -34,6 +37,7 @@ void SnowBall::activate() { + if (set_direction) {dir = initial_direction;} physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED); sprite->set_action(dir == LEFT ? "left" : "right"); } Index: dispenser.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/dispenser.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- dispenser.cpp 25 Nov 2004 13:19:37 -0000 1.6 +++ dispenser.cpp 25 Nov 2004 16:22:05 -0000 1.7 @@ -3,6 +3,8 @@ #include "dispenser.h" #include "badguy/bouncing_snowball.h" #include "badguy/snowball.h" +#include "badguy/mrbomb.h" +#include "badguy/mriceblock.h" Dispenser::Dispenser(LispReader& reader) @@ -69,9 +71,9 @@ } //TODO: Add launching velocity to badguys -// Add more badguys and randomizer +// Add randomizer // Clean up stuff I copied without understanding what it does :) -// Stop dispensing when game is paused +// Stop dispensing when game is paused (timer related problem) // Lots-O-Stuff (tm) void Dispenser::launch_badguy() @@ -79,9 +81,13 @@ //FIXME: Does is_offscreen() work right here? if (!is_offscreen()) { if (badguy == "snowball") - Sector::current()->add_object(new SnowBall(get_pos().x-2, get_pos().y)); + Sector::current()->add_object(new SnowBall(get_pos().x, get_pos().y, dir)); else if (badguy == "bouncingsnowball") - Sector::current()->add_object(new BouncingSnowball(get_pos().x-2, get_pos().y, dir)); + Sector::current()->add_object(new BouncingSnowball(get_pos().x, get_pos().y, dir)); + else if (badguy == "mrbomb") + Sector::current()->add_object(new MrBomb(get_pos().x, get_pos().y, dir)); + else if (badguy == "mriceblock") + Sector::current()->add_object(new MrIceBlock(get_pos().x, get_pos().y, dir)); else if (badguy == "random") {} } Index: mrbomb.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/mrbomb.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- mrbomb.h 24 Nov 2004 18:19:51 -0000 1.2 +++ mrbomb.h 25 Nov 2004 16:22:05 -0000 1.3 @@ -7,7 +7,7 @@ { public: MrBomb(LispReader& reader); - MrBomb(float pos_x, float pos_y); + MrBomb(float pos_x, float pos_y, Direction d); void activate(); void write(LispWriter& writer); @@ -15,6 +15,8 @@ protected: bool collision_squished(Player& player); + bool set_direction; + Direction initial_direction; }; #endif Index: nolok_01.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/nolok_01.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- nolok_01.cpp 25 Nov 2004 14:59:04 -0000 1.4 +++ nolok_01.cpp 25 Nov 2004 16:22:05 -0000 1.5 @@ -11,7 +11,6 @@ static const float WALKSPEED = 90; //TODO: Create sprite, give multiple hitpoints, limit max number of snowballs -// Can only be killed when jumping, no idea why // Stop actions when pause button is hit (probably a general problem of timers) Nolok_01::Nolok_01(LispReader& reader) { @@ -52,27 +51,35 @@ void Nolok_01::active_action(float elapsed_time) { - movement = physic.get_movement(elapsed_time); if (action_timer.check()) { - if (action == WALKING) { - physic.set_velocity_y(700); - action = JUMPING; - action_timer.start(JUMP_TIME); - } - else if (action == JUMPING) { + switch (action) { + case WALKING: + { + physic.set_velocity_y(700); + action = JUMPING; + action_timer.start(JUMP_TIME); + break; + } + case JUMPING: + { sprite->set_action("throw"); action = SHOOTING; action_timer.start(SHOOT_TIME); - } - else if (action == SHOOTING) { + break; + } + case SHOOTING: + { Sector::current()->add_object(new BouncingSnowball(get_pos().x - 64, get_pos().y, LEFT)); Sector::current()->add_object(new BouncingSnowball(get_pos().x + 64, get_pos().y, RIGHT)); physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED); sprite->set_action(dir == LEFT ? "left" : "right"); action = WALKING; action_timer.start(WALK_TIME); + break; + } } } + movement = physic.get_movement(elapsed_time); } bool Index: mrbomb.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/mrbomb.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- mrbomb.cpp 25 Nov 2004 00:49:34 -0000 1.5 +++ mrbomb.cpp 25 Nov 2004 16:22:05 -0000 1.6 @@ -11,14 +11,17 @@ reader.read_float("y", start_position.y); bbox.set_size(31.8, 31.8); sprite = sprite_manager->create("mrbomb"); + set_direction = false; } -MrBomb::MrBomb(float pos_x, float pos_y) +MrBomb::MrBomb(float pos_x, float pos_y, Direction d) { start_position.x = pos_x; start_position.y = pos_y; bbox.set_size(31.8, 31.8); sprite = sprite_manager->create("mrbomb"); + set_direction = true; + initial_direction = d; } void @@ -35,6 +38,7 @@ void MrBomb::activate() { + if (set_direction) {dir = initial_direction;} physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED); sprite->set_action(dir == LEFT ? "left" : "right"); } Index: mriceblock.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/mriceblock.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- mriceblock.h 20 Nov 2004 22:14:39 -0000 1.1 +++ mriceblock.h 25 Nov 2004 16:22:05 -0000 1.2 @@ -7,6 +7,7 @@ { public: MrIceBlock(LispReader& reader); + MrIceBlock(float pos_x, float pos_y, Direction d); void activate(); void write(LispWriter& writer); @@ -26,6 +27,8 @@ IceState ice_state; Timer2 flat_timer; int squishcount; + bool set_direction; + Direction initial_direction; }; #endif |