-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHumanObject.cpp
More file actions
53 lines (45 loc) · 1.73 KB
/
HumanObject.cpp
File metadata and controls
53 lines (45 loc) · 1.73 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
//SPECIFICATION FILE
#include "HumanObject.h"
//CONSTRUCTOR AND DESTRUCTORS///////////////////////////////////////
HumanSprite::HumanSprite(string Name, string imgSequence, int Xinit, int Yinit, char ObChar, int ObNum, string subFolders, int timer):
SpriteObject(Name, Xinit, Yinit, ObChar, ObNum), frameTimer(timer)
{
animation[IDLE] = GetImgSequence(imgSequence + "_IDLE", subFolders);
animation[WALK] = GetImgSequence(imgSequence + "_WALK", subFolders);
animation[JUMP] = GetImgSequence(imgSequence + "_JUMP", subFolders);
animation[CLIMB] = GetImgSequence(imgSequence + "_CLIMB", subFolders);
animation[HURT] = GetImgSequence(imgSequence + "_HURT", subFolders);
}
HumanSprite::~HumanSprite(){
for (int x = 0; x < 5; x++)
for (int y = 0; y < animation[x].size(); y++)
al_destroy_bitmap(animation[x][y]);
}
//GETTER FUNCTIONS////////////////////////////////////////////////////
bool const HumanSprite::GetFrameTimer()
{ return frameTimer;}
int const HumanSprite::GetCurrentFrameCount()
{ return currentFrameCount;}
//TRANSFORMER FUNCTIONS/////////////////////////////////////////////////////
bool HumanSprite::ChangeGraphic(AnimationType type)
{
if (animation[type].size() > 0){
currentAnimation = type;
currentFrameCount = 0;
NewFrame(animation[currentAnimation][0]);
return true;
}
return false;
}
bool HumanSprite::NextFrame(){
if (currentFrameCount == animation[currentAnimation].size() - 1){
currentFrameCount = 0;
NewFrame(animation[currentAnimation][0]);
return true;
}
else {
currentFrameCount++;
NewFrame(animation[currentAnimation][currentFrameCount]);
return true;
}
}