]> git.localhorst.tv Git - l2e.git/blobdiff - src/graphics/Animation.h
alternate approach to battle animation
[l2e.git] / src / graphics / Animation.h
index 03ead7fc5fc3cb75cc293b8c8fd55c135eb7af2a..6af75d0a64639ae129a803b96f4c5249c4c7afea 100644 (file)
@@ -39,9 +39,20 @@ public:
        void Stop() {
                timer = app::Timer<Uint32>();
        }
+       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<Uint32> &GetTimer() { return timer; }
 
        void SetColOffset(int offset) { colOffset = offset; }
        int ColOffset() const { return colOffset; }
@@ -67,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;