Implemented kicking (as asked by Ingo). The kick timing can be changed in defines.h
authorRicardo Cruz <rick2@aeiou.pt>
Mon, 26 Apr 2004 14:40:17 +0000 (14:40 +0000)
committerRicardo Cruz <rick2@aeiou.pt>
Mon, 26 Apr 2004 14:40:17 +0000 (14:40 +0000)
I've not tested it very well, but it doesn't seem to be working. Can anyone have a look?

SVN-Revision: 751

src/badguy.cpp
src/defines.h
src/player.cpp
src/player.h

index 6e60bbf..0c9f9a1 100644 (file)
@@ -291,6 +291,7 @@ BadGuy::action_laptop(float frame_ratio)
           old_base = base;
 
           mode=KICK;
+          tux.kick_timer.start(KICKING_TIME);
           set_sprite(img_laptop_flat_left, img_laptop_flat_right);
           physic.set_velocity_x((dir == LEFT) ? -3.5 : 3.5);
           play_sound(sounds[SND_KICK],SOUND_CENTER_SPEAKER);
index 9c86b6d..4bdaab2 100644 (file)
@@ -85,6 +85,10 @@ enum DyingType {
 
 #define LEVEL_WIDTH 375
 
+/* Timing constants (in ms): */
+
+#define KICKING_TIME 3000
+
 
 /* Debugging */
 
index ec3e899..82fe8a5 100644 (file)
@@ -92,6 +92,7 @@ Player::init()
   skidding_timer.init(true);
   safe_timer.init(true);
   frame_timer.init(true);
+  kick_timer.init(true);
 
   physic.reset();
 }
@@ -264,6 +265,7 @@ Player::action(double frame_ratio)
   skidding_timer.check();
   invincible_timer.check();
   safe_timer.check();
+  kick_timer.check();
 }
 
 bool
@@ -522,6 +524,13 @@ Player::draw()
               else
                 sprite->skid_left->draw(base.x - scroll_x, base.y); 
             }
+          else if (kick_timer.started())
+            {
+              if (dir == RIGHT)
+                sprite->kick_right->draw(base.x - scroll_x, base.y);
+              else
+                sprite->kick_left->draw(base.x - scroll_x, base.y); 
+            }
           else if (physic.get_velocity_y() != 0)
             {
               if (dir == RIGHT)
index 4271c4f..708d2ae 100644 (file)
@@ -127,6 +127,7 @@ public:
   Timer skidding_timer;
   Timer safe_timer;
   Timer frame_timer;
+  Timer kick_timer;
   Physic physic;
 
 public: