kugelblitz update - the behaviour intended for the most basic version is almost done...
authorMarek Moeckel <wansti@gmx.de>
Mon, 18 Jul 2005 22:42:51 +0000 (22:42 +0000)
committerMarek Moeckel <wansti@gmx.de>
Mon, 18 Jul 2005 22:42:51 +0000 (22:42 +0000)
SVN-Revision: 2733

data/images/creatures/kugelblitz/pop-0.png [new file with mode: 0644]
data/images/creatures/kugelblitz/pop-1.png [new file with mode: 0644]
data/images/creatures/kugelblitz/pop-2.png [new file with mode: 0644]
data/images/creatures/kugelblitz/pop-3.png [new file with mode: 0644]
data/images/sprites.strf
data/levels/test/kugelblitz.stl
src/badguy/kugelblitz.cpp
src/badguy/kugelblitz.hpp

diff --git a/data/images/creatures/kugelblitz/pop-0.png b/data/images/creatures/kugelblitz/pop-0.png
new file mode 100644 (file)
index 0000000..bb7629e
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 (file)
index 0000000..f8dc4c5
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 (file)
index 0000000..2ad0ec2
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 (file)
index 0000000..4e64c69
Binary files /dev/null and b/data/images/creatures/kugelblitz/pop-3.png differ
index 50bea26..780db69 100644 (file)
          (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
index 3c58abb..610a35b 100644 (file)
       (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))
    )
  )
index 271bb8f..1f861fe 100644 (file)
 #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")
index 30f0b43..d630922 100644 (file)
@@ -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;
 };