#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),
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;
#include <memory>
#include "badguy.hpp"
+class Timer;
+
class Root : public BadGuy
{
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<Sprite> base_sprite;
float offset_y;
+ Timer hatch_timer;
};
#endif