added PoisonIvy badguy contributed by Stephen Groundwater
authorMarek Moeckel <wansti@gmx.de>
Sun, 2 Jan 2005 19:00:43 +0000 (19:00 +0000)
committerMarek Moeckel <wansti@gmx.de>
Sun, 2 Jan 2005 19:00:43 +0000 (19:00 +0000)
SVN-Revision: 2271

data/images/shared/poisonivy-left-0.png [new file with mode: 0644]
data/images/shared/poisonivy-left-1.png [new file with mode: 0644]
data/images/shared/poisonivy-left-2.png [new file with mode: 0644]
data/images/shared/poisonivy-squished-left.png [new file with mode: 0644]
data/images/supertux.strf
data/levels/test/mrtree.stl
src/badguy/poisonivy.cpp [new file with mode: 0644]
src/badguy/poisonivy.h [new file with mode: 0644]

diff --git a/data/images/shared/poisonivy-left-0.png b/data/images/shared/poisonivy-left-0.png
new file mode 100644 (file)
index 0000000..2a984f3
Binary files /dev/null and b/data/images/shared/poisonivy-left-0.png differ
diff --git a/data/images/shared/poisonivy-left-1.png b/data/images/shared/poisonivy-left-1.png
new file mode 100644 (file)
index 0000000..f2fc982
Binary files /dev/null and b/data/images/shared/poisonivy-left-1.png differ
diff --git a/data/images/shared/poisonivy-left-2.png b/data/images/shared/poisonivy-left-2.png
new file mode 100644 (file)
index 0000000..bd010c6
Binary files /dev/null and b/data/images/shared/poisonivy-left-2.png differ
diff --git a/data/images/shared/poisonivy-squished-left.png b/data/images/shared/poisonivy-squished-left.png
new file mode 100644 (file)
index 0000000..4ca8651
Binary files /dev/null and b/data/images/shared/poisonivy-squished-left.png differ
index ec8b35a..1eddb4e 100644 (file)
          (images "shared/dummyguy-dead.png")))
 
 
+  ; MrTree  
+  (sprite (name "mrtree")
+      (action
+        (y-offset -3)
+        (fps 5)
+        (name "left")
+        (images "shared/mrtree-walk-left-0.png"
+                "shared/mrtree-walk-left-1.png"
+                "shared/mrtree-walk-left-2.png")
+      )
+      (action
+        (y-offset -3)
+        (fps 5)
+        (name "right")
+        (mirror-action "left")
+      )
+      (action
+        (y-offset -3)
+        (name "small-left")
+        (images "shared/mrtree-small-left-0.png"
+                "shared/mrtree-small-left-1.png"
+                "shared/mrtree-small-left-2.png")
+      )
+      (action
+        (y-offset -3)
+        (name "small-right")
+        (mirror-action "small-left")
+      )
+      (action
+        (y-offset -6)
+        (name "squished-left")
+        (images "shared/mrtree-squished-left.png")
+      )
+      (action
+        (y-offset -6)
+        (name "squished-right")
+        (mirror-action "squished-left")
+      )
+  )
+
+ ; PoisonIvy
+ (sprite (name "poisonivy")
+       (action
+         (name "left")
+         (x-offset 2)
+         (y-offset 4)
+         (images "shared/poisonivy-left-0.png"
+                 "shared/poisonivy-left-1.png"
+                 "shared/poisonivy-left-2.png"))
+
+       (action
+         (name "right")
+         (x-offset 2)
+         (y-offset 4)
+         (mirror-action "left"))
+       (action
+         (name "squished-left")
+         (x-offset 1)
+         (y-offset -19)
+         (images "shared/poisonivy-squished-left.png"))
+
+       (action
+         (name "squished-right")
+         (x-offset 1)
+         (y-offset -19)
+         (mirror-action "squished-left")))
+
          
 ;; Game elements follow
           
         (images "tilesets/bonus2-d.png"))
   )                                        
 
-  (sprite (name "mrtree")
-      (action
-        (y-offset -3)
-        (fps 5)
-        (name "left")
-        (images "shared/mrtree-walk-left-0.png"
-                "shared/mrtree-walk-left-1.png"
-                "shared/mrtree-walk-left-2.png")
-      )
-      (action
-        (y-offset -3)
-        (fps 5)
-        (name "right")
-        (mirror-action "left")
-      )
-      (action
-        (y-offset -3)
-        (name "small-left")
-        (images "shared/mrtree-small-left-0.png"
-                "shared/mrtree-small-left-1.png"
-                "shared/mrtree-small-left-2.png")
-      )
-      (action
-        (y-offset -3)
-        (name "small-right")
-        (mirror-action "small-left")
-      )
-      (action
-        (y-offset -6)
-        (name "squished-left")
-        (images "shared/mrtree-squished-left.png")
-      )
-      (action
-        (y-offset -6)
-        (name "squished-right")
-        (mirror-action "squished-left")
-      )
-  )
-
   ; Stomp
   (sprite (name "stomp")
        (action
index cee56ad..3c37f5f 100644 (file)
     ))
 
     (mrtree (x 200) (y 10))
+    (poisonivy (x 800) (y 10))
+    (poisonivy (x 1000) (y 10))
+    (poisonivy (x 1200) (y 10))
+    (poisonivy (x 1400) (y 10))
+    (poisonivy (x 1800) (y 10))
+    (poisonivy (x 2000) (y 10))
+    (poisonivy (x 2500) (y 10))
+    (poisonivy (x 3000) (y 10))
    )
  )
 
diff --git a/src/badguy/poisonivy.cpp b/src/badguy/poisonivy.cpp
new file mode 100644 (file)
index 0000000..7739b82
--- /dev/null
@@ -0,0 +1,79 @@
+#include <config.h>
+
+#include "poisonivy.h"
+
+static const float WALKSPEED = 80;
+
+PoisonIvy::PoisonIvy(const lisp::Lisp& reader)
+{
+  reader.get("x", start_position.x);
+  reader.get("y", start_position.y);
+  bbox.set_size(31.8, 31.8);
+  sprite = sprite_manager->create("poisonivy");
+  set_direction = false;
+}
+
+PoisonIvy::PoisonIvy(float pos_x, float pos_y, Direction d)
+{
+  start_position.x = pos_x;
+  start_position.y = pos_y;
+  bbox.set_size(31.8, 31.8);
+  sprite = sprite_manager->create("poisonivy");
+  set_direction = true;
+  initial_direction = d;
+}
+
+void
+PoisonIvy::write(lisp::Writer& writer)
+{
+  writer.start_list("poisonivy");
+
+  writer.write_float("x", start_position.x);
+  writer.write_float("y", start_position.y);
+
+  writer.end_list("poisonivy");
+}
+
+void
+PoisonIvy::activate()
+{
+  if (set_direction) {dir = initial_direction;}
+  physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
+  sprite->set_action(dir == LEFT ? "left" : "right");
+}
+
+bool
+PoisonIvy::collision_squished(Player& player)
+{
+  sprite->set_action(dir == LEFT ? "squished-left" : "squished-right");
+  kill_squished(player);
+  return true;
+}
+
+HitResponse
+PoisonIvy::collision_solid(GameObject& , const CollisionHit& hit)
+{
+  if(fabsf(hit.normal.y) > .5) { // hit floor or roof?
+    physic.set_velocity_y(0);
+  } else { // hit right or left
+    dir = dir == LEFT ? RIGHT : LEFT;
+    sprite->set_action(dir == LEFT ? "left" : "right");
+    physic.set_velocity_x(-physic.get_velocity_x());
+  }
+
+  return CONTINUE;
+}
+
+HitResponse
+PoisonIvy::collision_badguy(BadGuy& , const CollisionHit& hit)
+{
+  if(fabsf(hit.normal.x) > .8) { // left or right hit
+    dir = dir == LEFT ? RIGHT : LEFT;
+    sprite->set_action(dir == LEFT ? "left" : "right");
+    physic.set_velocity_x(-physic.get_velocity_x());       
+  }
+
+  return CONTINUE;
+}
+
+IMPLEMENT_FACTORY(PoisonIvy, "poisonivy")
diff --git a/src/badguy/poisonivy.h b/src/badguy/poisonivy.h
new file mode 100644 (file)
index 0000000..811fc4e
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef __POISONIVY_H__
+#define __POISONIVY_H__
+
+#include "badguy.h"
+
+class PoisonIvy : public BadGuy
+{
+public:
+  PoisonIvy(const lisp::Lisp& reader);
+  PoisonIvy(float pos_x, float pos_y, Direction d);
+
+  void activate();
+  void write(lisp::Writer& writer);
+  HitResponse collision_solid(GameObject& other, const CollisionHit& hit);
+  HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit);
+  
+protected:
+  bool collision_squished(Player& player);
+  bool set_direction;
+  Direction initial_direction;  
+};
+
+#endif