(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
))
(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))
)
)
--- /dev/null
+#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")
--- /dev/null
+#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