-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpriteObject.cpp
More file actions
127 lines (107 loc) · 3.07 KB
/
SpriteObject.cpp
File metadata and controls
127 lines (107 loc) · 3.07 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//SPECIFICATION FILE
#include "SpriteObject.h"
#include <iostream> //debug only
using namespace std;
//CONSTRUCTOR AND DESTRUCTORS///////////////////////////////////////
// ObjectID::ObjectID(char ch, int num)
// {
// objChar = ch;
// objNum = num;
// }
SpriteObject::SpriteObject(string Name, int Xinit, int Yinit, float scaleValue, string ObNum, float fpsTimer) :
name(Name), xPos(Xinit), yPos(Yinit), ID(ObNum), scaleX(scaleValue), scaleY(scaleValue), spriteFrameTime(fpsTimer)
{
if (scaleValue <= 0 || scaleValue == 1.0)
scaled = false;
else
scaled = true;
active = false;
visible = false;
currentFrameTime = 0.0;
//CREATE PARAMATERS FOR THESE LATER
}
//GETTER FUNCTIONS////////////////////////////////////////////////////
int const SpriteObject::GetXPos(){
return xPos;
}
int const SpriteObject::GetYPos(){
return yPos;
}
// int const SpriteObject::GetObjNum(){
// return ID.objNum;
// }
//
// int const SpriteObject::GetObjChar(){
// return ID.objChar;
// }
// int const SpriteObject::GetCurrentFrameCount(){
// return currentFrameCount;
// }
string const SpriteObject::GetObjID(){
return ID;
}
bool const SpriteObject::IsVisible(){
return visible;
}
bool const SpriteObject::IsActive(){
return active;
}
float const SpriteObject::GetCurrentFrameTime(){
return currentFrameTime;
}
float const SpriteObject::GetSpriteFrameTime(){
return spriteFrameTime;
}
//TRANSFORMER FUNCTIONS/////////////////////////////////////////////////////
void SpriteObject::ChangePos(int x, int y){
xPos = x;
yPos = y;
}
void SpriteObject::Activate(){
active = true;
}
void SpriteObject::DeActivate(){
active = false;
}
bool SpriteObject::DrawMe(){
if (currentFrame){
if (!scaled)
al_draw_bitmap(currentFrame, xPos, yPos, 0); //the 0 will need to be replaced to flipping verticly/horizontally eventually to see both directions. paramater may need to be added
else
al_draw_scaled_bitmap(currentFrame, 0 , 0, al_get_bitmap_width(currentFrame), al_get_bitmap_height(currentFrame),
xPos, yPos, al_get_bitmap_width(currentFrame) * scaleX, al_get_bitmap_height(currentFrame) * scaleY, 0);
}
else
return 0;
return 1;
}
// bool SpriteObject::AddFrameTime(float time)
// { /*VIRTUAL -- NOT TO BE IMPLEMENTED HERE -- VIRTUAL*/
// return false;
// }
bool const SpriteObject::operator==(const SpriteObject &s)
{ return (ID == s.ID); }
bool const SpriteObject::operator!=(const SpriteObject &s)
{ return (ID != s.ID); }
bool const SpriteObject::operator>=(const SpriteObject &s)
{ return (ID >= s.ID); }
bool const SpriteObject::operator<=(const SpriteObject &s)
{ return (ID <= s.ID); }
bool const SpriteObject::operator> (const SpriteObject &s)
{ return (ID > s.ID); }
bool const SpriteObject::operator< (const SpriteObject &s)
{ return (ID < s.ID); }
//BELOW ARE ALL PROTECTED FUNCTIONS////////////////////////////////////////////////////
bool SpriteObject::NewFrame(ALLEGRO_BITMAP* frame){
if (frame)
{
currentFrame = frame;
}
else
return 0;
return 1;
}
void SpriteObject::AddTime(float time)
{
currentFrameTime += time;
}