From 327e45d47ab5ea89493ac8677ce2209810dafeea Mon Sep 17 00:00:00 2001 From: Ricardo Cruz Date: Mon, 26 Apr 2004 14:40:17 +0000 Subject: [PATCH] Implemented kicking (as asked by Ingo). The kick timing can be changed in defines.h 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 | 1 + src/defines.h | 4 ++++ src/player.cpp | 9 +++++++++ src/player.h | 1 + 4 files changed, 15 insertions(+) diff --git a/src/badguy.cpp b/src/badguy.cpp index 6e60bbfa8..0c9f9a168 100644 --- a/src/badguy.cpp +++ b/src/badguy.cpp @@ -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); diff --git a/src/defines.h b/src/defines.h index 9c86b6db3..4bdaab24c 100644 --- a/src/defines.h +++ b/src/defines.h @@ -85,6 +85,10 @@ enum DyingType { #define LEVEL_WIDTH 375 +/* Timing constants (in ms): */ + +#define KICKING_TIME 3000 + /* Debugging */ diff --git a/src/player.cpp b/src/player.cpp index ec3e89960..82fe8a5f7 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -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) diff --git a/src/player.h b/src/player.h index 4271c4ffd..708d2ae21 100644 --- a/src/player.h +++ b/src/player.h @@ -127,6 +127,7 @@ public: Timer skidding_timer; Timer safe_timer; Timer frame_timer; + Timer kick_timer; Physic physic; public: -- 2.11.0