-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsprite.h
86 lines (71 loc) · 2.12 KB
/
sprite.h
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
84
85
86
#ifndef _SPRITE_H_
#define _SPRITE_H_
#include "animation.h"
#include "character.h"
namespace dragonfighting {
class AI;
class Sprite : public Character, public Animation
{
struct CollisionArea
{
SDL_Rect *hitRectArray;
int sizeHit;
SDL_Rect *attackRectArray;
int sizeAttack;
};
struct CollisionAreaSequence
{
string name;
Uint32 rateFrame;
int *indexArray;
int size;
int curIndex;
void reset();
int getCurrentAreaIndex();
int getNextAreaIndex();
};
private:
float speed;
float velocity_x;
float velocity_y;
float x;
float y;
float accx;
float accy;
enum State oldstate;
bool oldforward;
vector<struct CollisionArea> collisionAreas;
vector<struct CollisionAreaSequence *> collisionAreaSequences;
struct CollisionAreaSequence *curAreaSequence;
int curAreaIndex;
Uint32 oldFrameStamp;
SDL_Rect *realHitRectArray;
SDL_Rect *realAttackRectArray;
void resetPhysic();
public:
Sprite();
virtual ~Sprite();
void setPosition(float x, float y);
void setPositionX(float x);
float getPositionX();
float getPositionY();
void setSpeed(float speed);
float getVelocityX();
float getVelocityY();
void setVelocityX(float vx);
void setVelocityY(float vy);
void setVelocity(float vx, float vy);
void hitGround();
void addCollisionRects(SDL_Rect *hitrects, int hitsize, SDL_Rect *attackrects, int attacksize);
void addCollisionSequence(const char *name, Uint32 framerate, int indexarray[], int length);
void useCollisionSequence(const char *name);
const SDL_Rect *getCurRealHitCollisionRects(int &size /*out*/);
const SDL_Rect *getCurRealAttackCollisionRects(int &size /*out*/);
virtual void update(Uint32 frameStamp);
void updateCollisionArea(Uint32 frameStamp);
//debug
void draw(SDL_Surface *dst);
friend class AI;
};
}
#endif