added (temporary) dispenser sprites
authorMarek Moeckel <wansti@gmx.de>
Thu, 25 Nov 2004 13:19:51 +0000 (13:19 +0000)
committerMarek Moeckel <wansti@gmx.de>
Thu, 25 Nov 2004 13:19:51 +0000 (13:19 +0000)
improved nolok code

SVN-Revision: 2186

data/images/shared/dispenser-broken.png [new file with mode: 0644]
data/images/shared/dispenser-working.png [new file with mode: 0644]
data/images/supertux.strf
src/badguy/dispenser.cpp
src/badguy/nolok_01.cpp
src/badguy/nolok_01.h

diff --git a/data/images/shared/dispenser-broken.png b/data/images/shared/dispenser-broken.png
new file mode 100644 (file)
index 0000000..dbd6dcc
Binary files /dev/null and b/data/images/shared/dispenser-broken.png differ
diff --git a/data/images/shared/dispenser-working.png b/data/images/shared/dispenser-working.png
new file mode 100644 (file)
index 0000000..c36e655
Binary files /dev/null and b/data/images/shared/dispenser-working.png differ
index f689b05..85c185e 100644 (file)
           (x-offset 0)
           (y-offset 0)
           (images "shared/walkingtree-left-small-1.png")))
-          
+         
+  ; Dispenser
+  (sprite (name "dispenser")
+       (action
+         (name "working")
+          (x-offset 0)
+          (y-offset 0)
+          (images "shared/dispenser-working.png"))
+       (action
+          (name "broken")
+          (x-offset 0)
+          (y-offset 0)
+          (images "shared/dispenser-broken.png")))          
+   
    ; Dummyguy
    (sprite (name "dummyguy")
        (action
index 2975c1a..953a321 100644 (file)
@@ -12,9 +12,8 @@ Dispenser::Dispenser(LispReader& reader)
   reader.read_float("cycle", cycle);
   reader.read_string("badguy", badguy);
   bbox.set_size(32, 32);
-  //FIXME: Create dispenser sprite
-  sprite = sprite_manager->create("dummyguy");
-  sprite->set_action("stand");
+  sprite = sprite_manager->create("dispenser");
+  sprite->set_action("working");
 }
 
 void
@@ -40,7 +39,9 @@ Dispenser::activate()
 bool
 Dispenser::collision_squished(Player& player)
 {
-  remove_me();
+  //FIXME: Should act like a normal tile when killed
+  sprite->set_action("broken");
+  dispense_timer.start(0);
   player.bounce(*this);
   return true;
 }
index 4bbc14e..180ee83 100644 (file)
@@ -44,7 +44,8 @@ Nolok_01::activate()
 {
   physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
   sprite->set_action(dir == LEFT ? "left" : "right");
-  action_timer.start(SHOOT_TIME, true);
+  action = WALKING;
+  action_timer.start(SHOOT_TIME);
 }
 
 void
@@ -52,18 +53,24 @@ Nolok_01::active_action(float elapsed_time)
 {
    movement = physic.get_movement(elapsed_time);
    if (action_timer.check()) {
-      physic.set_velocity_y(700);
-      jump_timer.start(JUMP_TIME);
-   }
-   if (jump_timer.check()) {
-      sprite->set_action("throw");
-      idle_timer.start(IDLE_TIME);
-   }
-   if (idle_timer.check()) {
-      Sector::current()->add_object(new BouncingSnowball(get_pos().x-32, get_pos().y, LEFT));
-      Sector::current()->add_object(new BouncingSnowball(get_pos().x, get_pos().y, RIGHT));
-      physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
-      sprite->set_action(dir == LEFT ? "left" : "right");
+     if (action == WALKING) {
+        physic.set_velocity_y(700);
+        action = JUMPING;
+        action_timer.start(JUMP_TIME);
+     }
+     else if (action == JUMPING) {
+        sprite->set_action("throw");
+        action = IDLE;
+        action_timer.start(IDLE_TIME);
+     }
+     else if (action == IDLE) {
+        Sector::current()->add_object(new BouncingSnowball(get_pos().x-32, get_pos().y, LEFT));
+        Sector::current()->add_object(new BouncingSnowball(get_pos().x, get_pos().y, RIGHT));
+        physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
+        sprite->set_action(dir == LEFT ? "left" : "right");
+        action = WALKING;
+        action_timer.start(SHOOT_TIME);
+     }
    }
 }
 
index 4049892..ff32034 100644 (file)
@@ -18,8 +18,8 @@ public:
 protected:
   bool collision_squished(Player& player);
   Timer2 action_timer;
-  Timer2 idle_timer;
-  Timer2 jump_timer;
+  enum { IDLE, WALKING, JUMPING, SHOOTING };
+  int action;
 };
 
 #endif