From: Marek Moeckel Date: Mon, 18 Jul 2005 22:42:51 +0000 (+0000) Subject: kugelblitz update - the behaviour intended for the most basic version is almost done... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=5f42927f2739ad4dcf2a4a2fb32c6d4e0127ef11;p=supertux.git kugelblitz update - the behaviour intended for the most basic version is almost done, only the explosion is missing and a few bugs are still there. Try the test level, but be careful - these guys are dangerous :) SVN-Revision: 2733 --- diff --git a/data/images/creatures/kugelblitz/pop-0.png b/data/images/creatures/kugelblitz/pop-0.png new file mode 100644 index 000000000..bb7629e78 Binary files /dev/null and b/data/images/creatures/kugelblitz/pop-0.png differ diff --git a/data/images/creatures/kugelblitz/pop-1.png b/data/images/creatures/kugelblitz/pop-1.png new file mode 100644 index 000000000..f8dc4c572 Binary files /dev/null and b/data/images/creatures/kugelblitz/pop-1.png differ diff --git a/data/images/creatures/kugelblitz/pop-2.png b/data/images/creatures/kugelblitz/pop-2.png new file mode 100644 index 000000000..2ad0ec267 Binary files /dev/null and b/data/images/creatures/kugelblitz/pop-2.png differ diff --git a/data/images/creatures/kugelblitz/pop-3.png b/data/images/creatures/kugelblitz/pop-3.png new file mode 100644 index 000000000..4e64c69f1 Binary files /dev/null and b/data/images/creatures/kugelblitz/pop-3.png differ diff --git a/data/images/sprites.strf b/data/images/sprites.strf index 50bea266c..780db695e 100644 --- a/data/images/sprites.strf +++ b/data/images/sprites.strf @@ -1332,6 +1332,16 @@ (images "creatures/kugelblitz/flying-0.png" "creatures/kugelblitz/flying-1.png" "creatures/kugelblitz/flying-2.png")) + + (action + (name "pop") + (x-offset 0) + (y-offset 0) + (fps 20) + (images "creatures/kugelblitz/pop-0.png" + "creatures/kugelblitz/pop-1.png" + "creatures/kugelblitz/pop-2.png" + "creatures/kugelblitz/pop-3.png")) ) ;; Game elements follow diff --git a/data/levels/test/kugelblitz.stl b/data/levels/test/kugelblitz.stl index 3c58abba9..610a35b8e 100644 --- a/data/levels/test/kugelblitz.stl +++ b/data/levels/test/kugelblitz.stl @@ -95,13 +95,15 @@ (mode "normal") ) + (spawnpoint (name "main") (x 950) (y 400)) (background (image "ghostforest.jpg") (speed 1.000000) ) - (poisonivy (x 987) (y 440)) - (poisonivy (x 873) (y 438)) + (poisonivy (x 800) (y 440)) + (poisonivy (x 100) (y 438)) (kugelblitz (x 519) (y 32)) + (kugelblitz (x 700) (y 32)) (kugelblitz (x 1100) (y 169)) ) ) diff --git a/src/badguy/kugelblitz.cpp b/src/badguy/kugelblitz.cpp index 271bb8f78..1f861fec6 100644 --- a/src/badguy/kugelblitz.cpp +++ b/src/badguy/kugelblitz.cpp @@ -24,6 +24,11 @@ #include "object/tilemap.hpp" #include "tile.hpp" +#define LIFETIME 5 +#define MOVETIME 0.75 +#define BASE_SPEED 200 +#define RAND_SPEED 150 + Kugelblitz::Kugelblitz(const lisp::Lisp& reader) : groundhit_pos_set(false) { @@ -52,11 +57,13 @@ Kugelblitz::activate() physic.set_velocity_y(-300); physic.set_velocity_x(-20); //fall a little to the left direction = 1; + dying = false; } HitResponse Kugelblitz::collision_solid(GameObject& other, const CollisionHit& chit) { + //TODO: Explode when Tux is hit return hit(chit); } @@ -80,7 +87,12 @@ Kugelblitz::hit(const CollisionHit& chit) } sprite->set_action("flying"); physic.set_velocity_y(0); - movement_timer.start(1500); + //Set random initial speed and direction + if ((rand() % 2) == 1) direction = 1; else direction = -1; + int speed = (BASE_SPEED + (rand() % RAND_SPEED)) * direction; + physic.set_velocity_x(speed); + movement_timer.start(MOVETIME); + lifetime.start(LIFETIME); } else if(chit.normal.y < .5) { // bumped on roof physic.set_velocity_y(0); @@ -92,20 +104,33 @@ Kugelblitz::hit(const CollisionHit& chit) void Kugelblitz::active_update(float elapsed_time) { - if (groundhit_pos_set) { - if (movement_timer.check()) { - //std::cout << "IM HERE" << std::endl; - //FIXME: Find out why the program never gets here - if (direction == 1) direction = -1; else direction = 1; - int speed = (300 + (rand() % 300)) * direction; - physic.set_velocity_x(speed); - movement_timer.start(1500); + if (lifetime.check()) { + if (!dying) { + sprite->set_action("pop"); + lifetime.start(0.2); + dying = true; } + else remove_me(); } - if (Sector::current()->solids->get_tile_at(get_pos())->getAttributes() == 16) { - //HIT WATER + else { + if (groundhit_pos_set) { + if (movement_timer.check()) { + if (direction == 1) direction = -1; else direction = 1; + int speed = (BASE_SPEED + (rand() % RAND_SPEED)) * direction; + physic.set_velocity_x(speed); + movement_timer.start(MOVETIME); + } + } + if (Sector::current()->solids->get_tile_at(get_pos())->getAttributes() == 16) { + //HIT WATER + } } BadGuy::active_update(elapsed_time); } +void +Kugelblitz::kill_fall() +{ +} + IMPLEMENT_FACTORY(Kugelblitz, "kugelblitz") diff --git a/src/badguy/kugelblitz.hpp b/src/badguy/kugelblitz.hpp index 30f0b43ae..d63092207 100644 --- a/src/badguy/kugelblitz.hpp +++ b/src/badguy/kugelblitz.hpp @@ -34,12 +34,15 @@ public: void write(lisp::Writer& writer); void active_update(float); + void kill_fall(); private: HitResponse hit(const CollisionHit& hit); Vector pos_groundhit; bool groundhit_pos_set; + bool dying; Timer movement_timer; + Timer lifetime; int direction; };