-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimation.h
More file actions
83 lines (70 loc) · 1.84 KB
/
animation.h
File metadata and controls
83 lines (70 loc) · 1.84 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef _ANIMATION_H_
#define _ANIMATION_H_
#include <SDL/SDL.h>
#include <vector>
#include <string>
#include "widget.h"
using std::vector;
using std::string;
namespace dragonfighting {
class AnimationSequence
{
public:
enum AnimationStyle {
LOOP,
ONCE,
};
protected:
string name;
Uint32 animRateFrame;
int curIndex;
bool ended;
enum AnimationStyle playStyle;
int *indexArray;
int size;
public:
AnimationSequence(const char *name);
~AnimationSequence();
bool nameCompare(const char *name);
void setFrameRate(Uint32 frame);
Uint32 getFrameRate();
void setPlayStyle(enum AnimationStyle style);
enum AnimationStyle getPlayStyle();
void setIndexArray(int indexarray[], int length);
int getCurrentFrameIndex();
int getNextFrameIndex();
int getPrevFrameIndex();
bool isEnd();
void reset();
};
class Animation : public Widget
{
protected:
SDL_Surface *fullImage;
SDL_Surface *flipedFullImage;
vector<SDL_Rect> frameRects;
vector<SDL_Rect> frameAnchorPoints;
vector<AnimationSequence *> sequences;
int currentFrame;
int currentSequence;
int defaultSequence;
Uint32 oldFrameStamp;
bool flipHorizontal;
bool backorder;
public:
Animation();
virtual ~Animation();
void setFullImage(SDL_Surface *img);
SDL_Surface *getFullImage();
void addFrame(SDL_Rect rect, SDL_Rect anchorpoint);
void addSequence(const char *name, Uint32 framerate, AnimationSequence::AnimationStyle style, int indexarray[], int length);
void setFlipHorizontal(bool b);
void setDefaultSequence(const char *name);
SDL_Rect getCurAnchor();
void playSequence(const char *name);
void playSequenceBackorder(const char *name);
virtual void update(Uint32 frameStamp);
virtual void draw(SDL_Surface *dst);
};
}
#endif