From aec9bf199857d0ae1a5dc54cd96ae37177493deb Mon Sep 17 00:00:00 2001 From: Christoph Sommer Date: Sat, 26 May 2007 17:42:23 +0000 Subject: [PATCH] Delayed root hatching SVN-Revision: 5034 --- src/badguy/root.cpp | 10 +++++++++- src/badguy/root.hpp | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/badguy/root.cpp b/src/badguy/root.cpp index 6fa949e20..cad33cbc0 100644 --- a/src/badguy/root.cpp +++ b/src/badguy/root.cpp @@ -21,9 +21,11 @@ #include "root.hpp" #include "sprite/sprite_manager.hpp" +#include "timer.hpp" static const float SPEED_GROW = 256; static const float SPEED_SHRINK = 128; +static const float HATCH_TIME = 0.75; Root::Root(const Vector& pos) : BadGuy(pos, "images/creatures/ghosttree/root.sprite", LAYER_TILES-1), @@ -55,7 +57,13 @@ void Root::active_update(float elapsed_time) { if (mystate == STATE_APPEARING) { - if (base_sprite->animation_done()) mystate = STATE_GROWING; + if (base_sprite->animation_done()) { + hatch_timer.start(HATCH_TIME); + mystate = STATE_HATCHING; + } + } + if (mystate == STATE_HATCHING) { + if (!hatch_timer.started()) mystate = STATE_GROWING; } else if (mystate == STATE_GROWING) { offset_y -= elapsed_time * SPEED_GROW; diff --git a/src/badguy/root.hpp b/src/badguy/root.hpp index 32ec2fa2e..d693f232d 100644 --- a/src/badguy/root.hpp +++ b/src/badguy/root.hpp @@ -22,6 +22,8 @@ #include #include "badguy.hpp" +class Timer; + class Root : public BadGuy { public: @@ -38,11 +40,12 @@ public: protected: enum MyState { - STATE_APPEARING, STATE_GROWING, STATE_SHRINKING, STATE_VANISHING + STATE_APPEARING, STATE_HATCHING, STATE_GROWING, STATE_SHRINKING, STATE_VANISHING }; MyState mystate; std::auto_ptr base_sprite; float offset_y; + Timer hatch_timer; }; #endif -- 2.11.0