X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2FComplexAnimation.h;h=f4a5db575d8f657809ffeaf3684b0f7fd2d6f12c;hb=cc3d698b8c1ad09d7a3f9e3f28bc84e0ac1735ea;hp=a1ffaaabafd85923660829e7e55843497bf41124;hpb=ebeefe8b81fbb2e69939d67972453c01b023ec22;p=l2e.git diff --git a/src/graphics/ComplexAnimation.h b/src/graphics/ComplexAnimation.h index a1ffaaa..f4a5db5 100644 --- a/src/graphics/ComplexAnimation.h +++ b/src/graphics/ComplexAnimation.h @@ -1,55 +1,45 @@ -/* - * ComplexAnimation.h - * - * Created on: Aug 12, 2012 - * Author: holy - */ - #ifndef GRAPHICS_COMPLEXANIMATION_H_ #define GRAPHICS_COMPLEXANIMATION_H_ #include "Animation.h" -#include - namespace graphics { class ComplexAnimation : public Animation { public: - ComplexAnimation() { } - ComplexAnimation(const Sprite *sprite, int frameTime, bool repeat = false) - : Animation(sprite, frameTime, repeat) { } + static const int TYPE_ID = 402; public: - void AddFrame(int col, int row, const geometry::Vector &disposition = geometry::Vector()) { - frames.push_back(FrameProp(col, row, disposition)); - } - void AddFrames(int col, int row, const geometry::Vector &disposition, int amount) { - for (int i(0); i < amount; ++i) { - AddFrame(col, row, disposition); - } - } - - virtual void Draw(SDL_Surface *dest, geometry::Point position) const { - Animation::Draw(dest, position + frames[Frame()].disposition); - } - -protected: - virtual int Col() const { return frames[Frame()].col; } - virtual int Row() const { return frames[Frame()].row; } - virtual int NumFrames() const { return frames.size(); }; + ComplexAnimation() : frames(0), numFrames(0) { } + ComplexAnimation(const Sprite *sprite, int frameTime, bool repeat = false) + : Animation(sprite, frameTime, repeat), frames(0), numFrames(0) { } -private: +public: struct FrameProp { + static const int TYPE_ID = 403; + FrameProp() : col(0), row(0) { } FrameProp(int col, int row, const geometry::Vector &disposition) : col(col), row(row), disposition(disposition) {} int col; int row; geometry::Vector disposition; }; - std::vector frames; + void SetFrames(const FrameProp *f, int num) { frames = f; numFrames = num; } + + static void CreateTypeDescription(); + static void Construct(void *); + +protected: + virtual int NumFrames() const { return numFrames; }; + virtual int Col(int frame) const { return frames[frame].col; } + virtual int Row(int frame) const { return frames[frame].row; } + virtual geometry::Vector Offset(int frame) const { return frames[frame].disposition; } + +private: + const FrameProp *frames; + int numFrames; };