[Super-tux-commit] supertux/src/badguy badguy.h,1.1,1.2 dispenser.cpp,1.2,1.3 dispenser.h,1.2,1.3 mr
Brought to you by:
wkendrick
From: Marek M. <wa...@us...> - 2004-11-24 18:20:07
|
Update of /cvsroot/super-tux/supertux/src/badguy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12560/src/badguy Modified Files: badguy.h dispenser.cpp dispenser.h mrbomb.cpp mrbomb.h snowball.cpp snowball.h Log Message: dispenser can now launch snowballs and bouncingsnowballs Index: snowball.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/snowball.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- snowball.h 20 Nov 2004 22:14:40 -0000 1.1 +++ snowball.h 24 Nov 2004 18:19:51 -0000 1.2 @@ -7,6 +7,7 @@ { public: SnowBall(LispReader& reader); + SnowBall(float pos_x, float pos_y); void activate(); void write(LispWriter& writer); Index: dispenser.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/dispenser.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- dispenser.h 24 Nov 2004 17:45:26 -0000 1.2 +++ dispenser.h 24 Nov 2004 18:19:51 -0000 1.3 @@ -16,6 +16,7 @@ protected: bool collision_squished(Player& player); + void launch_badguy(); float cycle; std::string badguy; Timer2 dispense_timer; Index: snowball.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/snowball.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- snowball.cpp 23 Nov 2004 16:47:26 -0000 1.2 +++ snowball.cpp 24 Nov 2004 18:19:51 -0000 1.3 @@ -12,6 +12,14 @@ sprite = sprite_manager->create("snowball"); } +SnowBall::SnowBall(float pos_x, float pos_y) +{ + start_position.x = pos_x; + start_position.y = pos_y; + bbox.set_size(32, 32); + sprite = sprite_manager->create("snowball"); +} + void SnowBall::write(LispWriter& writer) { Index: badguy.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/badguy.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- badguy.h 20 Nov 2004 22:14:39 -0000 1.1 +++ badguy.h 24 Nov 2004 18:19:51 -0000 1.2 @@ -84,11 +84,12 @@ * initial position of the enemy. Also the position where enemy respawns when * after being deactivated. */ + bool is_offscreen(); + Vector start_position; Direction dir; private: - bool is_offscreen(); void try_activate(); State state; Index: dispenser.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/dispenser.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- dispenser.cpp 24 Nov 2004 17:45:26 -0000 1.2 +++ dispenser.cpp 24 Nov 2004 18:19:51 -0000 1.3 @@ -2,6 +2,8 @@ #include "dispenser.h" #include "badguy/bouncing_snowball.h" +#include "badguy/snowball.h" + Dispenser::Dispenser(LispReader& reader) { @@ -10,6 +12,7 @@ reader.read_float("cycle", cycle); reader.read_string("badguy", badguy); bbox.set_size(32, 32); + //FIXME: Create dispenser sprite sprite = sprite_manager->create("snowball"); } @@ -28,8 +31,9 @@ void Dispenser::activate() -{ +{ dispense_timer.start(cycle, true); + launch_badguy(); } bool @@ -44,7 +48,7 @@ Dispenser::active_action(float elapsed_time) { if (dispense_timer.check()) { - Sector::current()->add_object(new BouncingSnowball(get_pos().x, get_pos().y)); + launch_badguy(); } } @@ -61,3 +65,21 @@ return CONTINUE; } + +//TODO: Add launching velocity to badguys +// Add more badguys and randomizer +// Clean up stuff I copied without understanding what it does :) +// Lots-O-Stuff (tm) +void +Dispenser::launch_badguy() +{ + //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)); + else if (badguy == "bouncingsnowball") + Sector::current()->add_object(new BouncingSnowball(get_pos().x-2, get_pos().y)); + else if (badguy == "random") + {} + } +} Index: mrbomb.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/mrbomb.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- mrbomb.h 20 Nov 2004 22:14:39 -0000 1.1 +++ mrbomb.h 24 Nov 2004 18:19:51 -0000 1.2 @@ -7,6 +7,7 @@ { public: MrBomb(LispReader& reader); + MrBomb(float pos_x, float pos_y); void activate(); void write(LispWriter& writer); Index: mrbomb.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/mrbomb.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mrbomb.cpp 24 Nov 2004 17:33:50 -0000 1.3 +++ mrbomb.cpp 24 Nov 2004 18:19:51 -0000 1.4 @@ -13,6 +13,14 @@ sprite = sprite_manager->create("mrbomb"); } +MrBomb::MrBomb(float pos_x, float pos_y) +{ + start_position.x = pos_x; + start_position.y = pos_y; + bbox.set_size(32, 32); + sprite = sprite_manager->create("mrbomb"); +} + void MrBomb::write(LispWriter& writer) { |