From ab908ed70c6ab1faba15e48b70aa50b90a152043 Mon Sep 17 00:00:00 2001 From: Marek Moeckel Date: Mon, 18 Jul 2005 19:38:09 +0000 Subject: [PATCH] another kugelblitz update SVN-Revision: 2732 --- data/levels/test/kugelblitz.stl | 2 +- src/badguy/kugelblitz.cpp | 23 ++++++++++++++++++++--- src/badguy/kugelblitz.hpp | 3 +++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/data/levels/test/kugelblitz.stl b/data/levels/test/kugelblitz.stl index f8861b9f4..3c58abba9 100644 --- a/data/levels/test/kugelblitz.stl +++ b/data/levels/test/kugelblitz.stl @@ -102,7 +102,7 @@ (poisonivy (x 987) (y 440)) (poisonivy (x 873) (y 438)) (kugelblitz (x 519) (y 32)) - (kugelblitz (x 1069) (y 169)) + (kugelblitz (x 1100) (y 169)) ) ) diff --git a/src/badguy/kugelblitz.cpp b/src/badguy/kugelblitz.cpp index d04f4e406..271bb8f78 100644 --- a/src/badguy/kugelblitz.cpp +++ b/src/badguy/kugelblitz.cpp @@ -20,6 +20,9 @@ #include #include "kugelblitz.hpp" +#include "sector.hpp" +#include "object/tilemap.hpp" +#include "tile.hpp" Kugelblitz::Kugelblitz(const lisp::Lisp& reader) : groundhit_pos_set(false) @@ -48,6 +51,7 @@ Kugelblitz::activate() { physic.set_velocity_y(-300); physic.set_velocity_x(-20); //fall a little to the left + direction = 1; } HitResponse @@ -71,12 +75,12 @@ Kugelblitz::hit(const CollisionHit& chit) if(chit.normal.y < -.5) { if (!groundhit_pos_set) { - pos_groundhit = get_pos(); //I'm leaving this in, we might need it here, too + pos_groundhit = get_pos(); groundhit_pos_set = true; } sprite->set_action("flying"); physic.set_velocity_y(0); - physic.set_velocity_x(100); + movement_timer.start(1500); } else if(chit.normal.y < .5) { // bumped on roof physic.set_velocity_y(0); @@ -88,7 +92,20 @@ Kugelblitz::hit(const CollisionHit& chit) void Kugelblitz::active_update(float elapsed_time) { - BadGuy::active_update(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 (Sector::current()->solids->get_tile_at(get_pos())->getAttributes() == 16) { + //HIT WATER + } + BadGuy::active_update(elapsed_time); } IMPLEMENT_FACTORY(Kugelblitz, "kugelblitz") diff --git a/src/badguy/kugelblitz.hpp b/src/badguy/kugelblitz.hpp index 9cffb3174..30f0b43ae 100644 --- a/src/badguy/kugelblitz.hpp +++ b/src/badguy/kugelblitz.hpp @@ -21,6 +21,7 @@ #define __KUGELBLITZ_H__ #include "badguy.hpp" +#include "timer.hpp" class Kugelblitz : public BadGuy { @@ -38,6 +39,8 @@ private: HitResponse hit(const CollisionHit& hit); Vector pos_groundhit; bool groundhit_pos_set; + Timer movement_timer; + int direction; }; #endif -- 2.11.0