X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2FAnimation.h;h=6af75d0a64639ae129a803b96f4c5249c4c7afea;hb=fbf5a98f8fd0da951e469003fe87d575a6bb30a4;hp=0f33541f0397ce41ce479f4442246bf0b3fd8654;hpb=abede3a0c94a057bc70305a1a858363a2a686f7e;p=l2e.git diff --git a/src/graphics/Animation.h b/src/graphics/Animation.h index 0f33541..6af75d0 100644 --- a/src/graphics/Animation.h +++ b/src/graphics/Animation.h @@ -39,15 +39,29 @@ public: void Stop() { timer = app::Timer(); } + bool Started() const { + return timer.Started(); + } bool Running() const { return timer.Running() && (repeat || timer.Iteration() < NumFrames()); } + bool Finished() const { + return Started() && !Running(); + } + bool JustFinished() const { + return timer.JustHit() && timer.Iteration() == NumFrames(); + } + + const app::Timer &GetTimer() { return timer; } void SetColOffset(int offset) { colOffset = offset; } int ColOffset() const { return colOffset; } void SetRowOffset(int offset) { rowOffset = offset; } int RowOffset() const { return rowOffset; } + const Sprite *GetSprite() const { return sprite; } + void ChangeSprite(const Sprite *s) { sprite = s; } + virtual void Draw(SDL_Surface *dest, geometry::Point position) const { sprite->Draw(dest, position, Col() + ColOffset(), Row() + RowOffset()); } @@ -64,8 +78,9 @@ public: Draw(dest, position + offset); } -protected: int Frame() const { return Running() ? (timer.Iteration() % NumFrames()) : 0; } + +protected: virtual int Col() const = 0; virtual int Row() const = 0; virtual int NumFrames() const = 0;