12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
#ifndef __ANIMATION_H__ #define __ANIMATION_H__ #include <SDL/SDL.h> #include <fstream> #include <vector> #include <string> #include "sprite.h" #include "cache.h" class Frame { public: Frame(); ~Frame(); void blit(Sint16 x, Sint16 y, Uint16 *palette); vector<Uint8*> runs; Sint16 width, height; Sint16 centerX; Sint16 centerY; }; class Animation { public: Animation(); ~Animation(); Uint16 runningTime() { return interval*frameCount; } Uint16 palette[0x100]; Uint32 frameCount; Frame *frames; Uint16 delay; Uint16 interval; void produce(Uint32 index, Animation &anim) throw (string); void recycle(Animation &anim); }; class AnimationState { public: AnimationState(); bool hasEnded(); void blit(int x, int y); void start(unsigned int times); Uint32 animIndex; protected: Uint32 startedAt; unsigned int timesLeft; }; class Animations { public: Animations(); ~Animations(); Cache<Uint32, Animation, Animation> anims; ifstream adatafile; ifstream animidx; ifstream animfile; }; #endif