-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphicObject.cpp
More file actions
49 lines (42 loc) · 1.32 KB
/
GraphicObject.cpp
File metadata and controls
49 lines (42 loc) · 1.32 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
//SPECIFICATION FILE
#include "GraphicObject.h"
//CONSTRUCTOR AND DESTRUCTORS///////////////////////////////////////
GraphicObject::GraphicObject(string Name, vector<ALLEGRO_BITMAP*> imgSequence, int Xinit, int Yinit, float scaledValue, string objNum, float fpsTimer) :
SpriteObject(Name, Xinit, Yinit, scaledValue, objNum, fpsTimer), currentFrameNum(0)
{
//animation = GetImgSequence(imgSequence, subFolders);
animation = imgSequence;
NewFrame(animation[0]);
numFrames = animation.size() - 1;
}
GraphicObject::~GraphicObject(){
//BITMAP DESTRUCTION HANDLED BY LEVELOBJECT
animation.clear();
}
//GETTER FUNCTIONS////////////////////////////////////////////////////
int const GraphicObject::GetCurrentFrameCount(){
return currentFrameNum;
}
//TRANSFORMER FUNCTIONS/////////////////////////////////////////////////////
bool GraphicObject::NextFrame(){
currentFrameNum++;
if (animation.empty())
return 0;
if (currentFrameNum < numFrames)
NewFrame(animation.at(currentFrameNum));
else{
NewFrame(animation[0]);
currentFrameNum = 0;
}
return 1;
}
bool GraphicObject::AddFrameTime(float time){
bool framechanged = false;
AddTime(time);
while (GetSpriteFrameTime() < GetCurrentFrameTime()){
AddTime(-GetSpriteFrameTime());
NextFrame();
framechanged = true;
}
return framechanged;
}