summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2Animation.h
blob: 9612d633e0545d44f9883e667538705d1eb78401 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef T2DLL_T2ANIMATION_H
#define T2DLL_T2ANIMATION_H
#include "../common.h"
#include "T2Sprite.h"

struct AnimationDef {
	POINT position;
	short pattern;
};

struct SpriteDef {
	unsigned int resID;
	short count;
	short width;
	short height;
};

class AFX_CLASS_EXPORT T2Animation {
private:
    void operator=(const T2Animation &); // no assignment

public:
	T2Animation(T2TowerDoc* inDoc, short inNumOfFrame, short inNumOfSprite, const SpriteDef* inSpriteDef, const AnimationDef* inAnimationDef, T2Sprite::ELayer inLayer);
	~T2Animation();
	BOOL Start(POINT inPt, int inLen);
	BOOL Idle();
	void Play(POINT inPt, int inLen);
	BOOL Step();

	void Rewind() { SetFrame(0); }
	BOOL HasNextStep() const {
		return (mFrame >= 0) && (mFrame < mNumOfFrame);
	}
	BOOL SetFrame(int inFrame) {
		mFrame = inFrame;
		return HasNextStep();
	}
	int GetFrame() const { return mFrame; }

protected:
	void Draw();

	T2TowerDoc *mDocument;
	short mNumOfFrame;
	short mNumOfSprite;
	const AnimationDef *mAnimationDef;
	int *mSpriteIndices;
	T2ImageObj **mImageObjs;
	T2BitImage **mImages;
	POINT mPoint;
	short mFrame;
	int mInterval;
	DWORD mTickCount;
};
#endif