]> git.localhorst.tv Git - l2e.git/blobdiff - src/graphics/SimpleAnimation.h
removed useless comments
[l2e.git] / src / graphics / SimpleAnimation.h
index dffd863a2be6bbf287039e2a44179d457b2aae0e..7e5a99a9a2630b6e4ba7eadf59e1a993349a6940 100644 (file)
@@ -1,62 +1,41 @@
-/*
- *  SimpleAnimation.h
- *
- *  Created on: Aug 11, 2012
- *      Author: holy
- */
-
 #ifndef GRAPHICS_SIMPLEANIMATION_H_
 #define GRAPHICS_SIMPLEANIMATION_H_
 
-#include "Sprite.h"
-#include "../app/Application.h"
-#include "../app/State.h"
-#include "../app/Timer.h"
-#include "../geometry/Point.h"
-
-#include <SDL.h>
+#include "Animation.h"
 
 namespace graphics {
 
-class SimpleAnimation {
+class SimpleAnimation
+: public Animation {
+
+public:
+       static const int TYPE_ID = 408;
 
 public:
-       SimpleAnimation()
-       : sprite(0), frameTime(0), numFrames(0), col(0), row(0), repeat(false) { }
-       SimpleAnimation(const Sprite *sprite, int frameTime, int numFrames, int col = 0, int row = 0, bool repeat = false)
-       : sprite(sprite), frameTime(frameTime), numFrames(numFrames), col(col), row(row), repeat(repeat) { }
+       SimpleAnimation();
+       SimpleAnimation(const Sprite *sprite, int frameTime, int numFrames,
+                       int col = 0, int row = 0, bool repeat = false);
 
 public:
-       void Start(app::State &ctrl) {
-               timer = ctrl.GraphicsTimers().StartInterval(frameTime);
-       }
-       void Start(app::Application &ctrl) {
-               timer = ctrl.GlobalTimers().StartInterval(frameTime);
-       }
-       void Stop() {
-               timer = app::Timer<Uint32>();
-       }
-       bool Running() const {
-               return timer.Running() && (repeat || timer.Iteration() < numFrames);
-       }
-       void Draw(SDL_Surface *dest, geometry::Point<int> position) {
-               sprite->Draw(dest, position, col, Running() ? row + (timer.Iteration() % numFrames) : row);
-       }
-       void DrawCenterBottom(SDL_Surface *dest, geometry::Point<int> position) const {
-               sprite->DrawCenterBottom(dest, position, col, Running() ? row + (timer.Iteration() % numFrames) : row);
-       }
+       void SetNumFrames(int n) { numFrames = n; }
+       void SetCol(int c) { col = c; }
+       void SetRow(int r) { row = r; }
+
+       static void CreateTypeDescription();
+       static void Construct(void *);
+
+protected:
+       virtual int NumFrames() const;
+       virtual int Col(int frame) const;
+       virtual int Row(int frame) const;
 
 private:
-       const Sprite *sprite;
-       app::Timer<Uint32> timer;
-       int frameTime;
        int numFrames;
        int col;
        int row;
-       bool repeat;
 
 };
 
 }
 
-#endif /* GRAPHICS_SIMPLEANIMATION_H_ */
+#endif