kugelblitz electrifies water on contact - electrified water is baaaaaaad
authorMarek Moeckel <wansti@gmx.de>
Sat, 17 Sep 2005 19:07:47 +0000 (19:07 +0000)
committerMarek Moeckel <wansti@gmx.de>
Sat, 17 Sep 2005 19:07:47 +0000 (19:07 +0000)
SVN-Revision: 2766

13 files changed:
data/images/sprites.strf
data/images/tiles.strf
data/images/tiles/water/electrified-0.png [new file with mode: 0644]
data/images/tiles/water/electrified-1.png [new file with mode: 0644]
data/images/tiles/water/electrified_waves-0.png [new file with mode: 0644]
data/images/tiles/water/electrified_waves-1.png [new file with mode: 0644]
data/levels/test/kugelblitz.stl
data/levels/world2/dfk-level3.stl
src/badguy/kugelblitz.cpp
src/badguy/kugelblitz.hpp
src/object/tilemap.cpp
src/object/tilemap.hpp
src/sector.cpp

index 879e7c4..fb396a4 100644 (file)
        (action
          (name "falling")
          (x-offset 0)
-         (y-offset )
+         (y-offset 0)
          (images "creatures/kugelblitz/falling-0.png"
                  "creatures/kugelblitz/falling-1.png"
                  "creatures/kugelblitz/falling-2.png"))
index c5a07af..dc87789 100644 (file)
       "tiles/lava/lava1-4.png"
     )
     (water #t)
+    (spike #t)
     (anim-fps 10)
   )
   (tile
       "tiles/lava/lava2-4.png"
     )
     (water #t)
+    (spike #t)
     (anim-fps 10)
   )
   (tile
     )
     (solid #t)
   )
+  (tile
+    (id 1421)
+    (images
+      "tiles/water/electrified-0.png"
+      "tiles/water/electrified-1.png"
+    )
+    (anim-fps 5)
+    (spike #t)
+    (water #t)
+  )
+  (tile
+    (id 1422)
+    (images
+      "tiles/water/electrified_waves-0.png"
+      "tiles/water/electrified_waves-1.png"
+    )
+    (anim-fps 5)
+    (spike #t)
+    (water #t)
+  )
 )
diff --git a/data/images/tiles/water/electrified-0.png b/data/images/tiles/water/electrified-0.png
new file mode 100644 (file)
index 0000000..a2eec75
Binary files /dev/null and b/data/images/tiles/water/electrified-0.png differ
diff --git a/data/images/tiles/water/electrified-1.png b/data/images/tiles/water/electrified-1.png
new file mode 100644 (file)
index 0000000..228eaa8
Binary files /dev/null and b/data/images/tiles/water/electrified-1.png differ
diff --git a/data/images/tiles/water/electrified_waves-0.png b/data/images/tiles/water/electrified_waves-0.png
new file mode 100644 (file)
index 0000000..62207e3
Binary files /dev/null and b/data/images/tiles/water/electrified_waves-0.png differ
diff --git a/data/images/tiles/water/electrified_waves-1.png b/data/images/tiles/water/electrified_waves-1.png
new file mode 100644 (file)
index 0000000..1744a14
Binary files /dev/null and b/data/images/tiles/water/electrified_waves-1.png differ
index ba74f7d..8b442fd 100644 (file)
        )
        (poisonivy (x 800) (y 440))
        (poisonivy (x 100) (y 438))
-       (kugelblitz (x 519) (y 32))
+       (kugelblitz (x 219) (y 32))
        (kugelblitz (x 700) (y 32))
        (kugelblitz (x 1100) (y 169))
    )
index 2779035..d3c7286 100644 (file)
@@ -4,8 +4,8 @@
   (name   (_ "Dark Forest Keep - The Black Tower"))
   (author "SuperTux Team")
   (sector
-    (name  "main")
-    (music  "darkforestkeep.ogg")
+    (name "main")
+    (music "darkforestkeep.ogg")
     (gravity 10.000000)
     (tilemap
       (layer  "background")
index f8303e0..6c5824c 100644 (file)
@@ -63,11 +63,31 @@ Kugelblitz::activate()
 HitResponse
 Kugelblitz::collision_solid(GameObject& , const CollisionHit& chit)
 {
-  //TODO: Explode when Tux is hit
   return hit(chit);
 }
 
 HitResponse
+Kugelblitz::collision_player(Player& player, const CollisionHit& )
+{
+  if(player.is_invincible()) {
+    explode();
+    return ABORT_MOVE;
+  }
+  // hit from above?
+  if(player.get_movement().y - get_movement().y > 0 && player.get_bbox().p2.y <
+      (get_bbox().p1.y + get_bbox().p2.y) / 2) {
+    // if it's not is it possible to squish us, then this will hurt
+    if(!collision_squished(player))
+      player.kill(Player::SHRINK);
+      explode();
+    return FORCE_MOVE;
+  }
+  player.kill(Player::SHRINK);
+  explode();
+  return FORCE_MOVE;
+}
+
+HitResponse
 Kugelblitz::collision_badguy(BadGuy& other , const CollisionHit& chit)
 {
   //Let the Kugelblitz explode, too?
@@ -104,13 +124,13 @@ Kugelblitz::hit(const CollisionHit& chit)
 void
 Kugelblitz::active_update(float elapsed_time)
 {
-  if (lifetime.check()) {
-    if (!dying) {
-      sprite->set_action("pop");
-      lifetime.start(0.2);
-      dying = true;
-    }
-    else remove_me();
+  if (electrify_timer.check()) {
+    Sector::current()->solids->change_all(1421,75);
+    Sector::current()->solids->change_all(1422,76);
+    explode();
+  }
+  else if (lifetime.check()) {
+    explode();
   }
   else {
     if (groundhit_pos_set) {
@@ -123,6 +143,11 @@ Kugelblitz::active_update(float elapsed_time)
     }
     if (Sector::current()->solids->get_tile_at(get_pos())->getAttributes() == 16) {
       //HIT WATER
+      Sector::current()->solids->change_all(75,1421);
+      Sector::current()->solids->change_all(76,1422);
+      physic.set_velocity_x(0);
+      physic.set_velocity_y(0);
+      electrify_timer.start(1);
     }
   }
   BadGuy::active_update(elapsed_time);  
@@ -133,4 +158,15 @@ Kugelblitz::kill_fall()
 {
 }
 
+void
+Kugelblitz::explode()
+{
+  if (!dying) {
+    sprite->set_action("pop");
+    lifetime.start(0.2);
+    dying = true;
+  }
+  else remove_me();
+}
+
 IMPLEMENT_FACTORY(Kugelblitz, "kugelblitz")
index d630922..5e59120 100644 (file)
@@ -29,12 +29,14 @@ public:
   Kugelblitz(const lisp::Lisp& reader);
 
   void activate();
-  HitResponse collision_solid(GameObject& other, const CollisionHit& hit);
   HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit);
+  HitResponse collision_solid(GameObject& other, const CollisionHit& hit);
+  HitResponse collision_player(Player& player, const CollisionHit& hit);
 
   void write(lisp::Writer& writer);
   void active_update(float);
   void kill_fall();
+  void explode();
 
 private:
   HitResponse hit(const CollisionHit& hit);
@@ -43,6 +45,7 @@ private:
   bool dying;
   Timer movement_timer;
   Timer lifetime;
+  Timer electrify_timer;
   int direction;
 };
 
index d37ae5c..8775418 100644 (file)
@@ -281,4 +281,13 @@ TileMap::change_at(const Vector& pos, uint32_t newtile)
   change(int(pos.x)/32, int(pos.y)/32, newtile);
 }
 
+void
+TileMap::change_all(uint32_t oldtile, uint32_t newtile)
+{
+  for (size_t x = 0; x < get_width(); x++)
+    for (size_t y = 0; y < get_height(); y++) {
+      if (get_tile(x,y)->getID() == oldtile) change(x,y,newtile);
+    }
+}
+
 IMPLEMENT_FACTORY(TileMap, "tilemap");
index dcd7478..e344fa0 100644 (file)
@@ -79,6 +79,9 @@ public:
 
   void change_at(const Vector& pos, uint32_t newtile);
 
+  /// changes all tiles with the given ID
+  void change_all(uint32_t oldtile, uint32_t newtile);
+
   TileManager* get_tilemanager() const
   {
     return tilemanager;
index cb20718..5ff6b03 100644 (file)
@@ -56,7 +56,6 @@
 #include "object/bullet.hpp"
 #include "object/text_object.hpp"
 #include "badguy/jumpy.hpp"
-#include "badguy/spike.hpp"
 #include "trigger/sequence_trigger.hpp"
 #include "player_status.hpp"
 #include "scripting/script_interpreter.hpp"