3 #define PI 3.14159265358979323846 16 SDL_Rect frame, dest, pos, buff, movedBuff;
19 double x, y, velX, velY, speed;
23 struct color { Uint8 r, g, b, a; };
28 SDL_Rect getBuff()
const {
return buff;}
29 SDL_Rect getMovedBuff()
const {
return movedBuff;}
30 void actGravity(
bool g) {gravity=g;}
40 void setX(
double sx) { x = sx; }
42 void setY(
double sy) { y = sy; }
46 void moveX(
double mx) { x += mx; }
48 void moveY(
double my) { y += my; }
50 double getX()
const {
return x; }
52 double getY()
const {
return y; }
70 SDL_Rect
getPos()
const {
return pos; }
74 void setDest(SDL_Rect i) { buff=dest;
if(movedBuff.x!=buff.x && movedBuff.y!=buff.y) {movedBuff=buff;} dest = i; }
91 void setFrameW(
int w) { frame.w = w; }
92 void setFrameH(
int h) { frame.h = h; }
93 int getFrameX()
const {
return frame.x; }
94 int getFrameY()
const {
return frame.y; }
95 int getFrameW()
const {
return frame.w; }
96 int getFrameH()
const {
return frame.h; }
97 void setDest(
int x,
int y,
int w,
int h) { buff=dest;
if(movedBuff.x!=buff.x || movedBuff.y!=buff.y) {movedBuff=buff;} setDestCoord(x, y); setDestSize(w, h); }
98 void setDestCoord(
int x,
int y) { setDestX(x); setDestY(y); }
99 void setDestSize(
int w,
int h) { setDestW(w); setDestH(h); }
100 void setDestX(
int x) { buff=dest;
if(movedBuff.x!=buff.x || movedBuff.y!=buff.y) {movedBuff=buff;} dest.x = x; }
101 void setDestY(
int y) { buff=dest;
if(movedBuff.x!=buff.x || movedBuff.y!=buff.y) {movedBuff=buff;} dest.y = y; }
102 void setDestW(
int w) { buff=dest;
if(movedBuff.x!=buff.x || movedBuff.y!=buff.y) {movedBuff=buff;} dest.w = w; }
103 void setDestH(
int h) { buff=dest;
if(movedBuff.x!=buff.x || movedBuff.y!=buff.y) {movedBuff=buff;} dest.h = h; }
104 int getDestX()
const {
return dest.x; }
105 int getDestY()
const {
return dest.y; }
106 int getDestW()
const {
return dest.w; }
107 int getDestH()
const {
return dest.h; }
108 void setPos(
int x,
int y,
int w,
int h) { setPosCoord(x, y); setPosSize(w, h); }
109 void setPosCoord(
int x,
int y) { setPosX(x); setPosY(y); }
110 void setPosSize(
int w,
int h) { setPosW(w); setPosH(h); }
111 void setPosX(
int x) { pos.x = x; }
112 void setPosY(
int y) { pos.y = y; }
113 void setPosW(
int w) { pos.w = w; }
114 void setPosH(
int h) { pos.h = h; }
115 int getPosX()
const {
return pos.x; }
116 int getPosY()
const {
return pos.y; }
117 int getPosW()
const {
return pos.w; }
118 int getPosH()
const {
return pos.h; }
119 void moveFrame(
int x,
int y) { moveFrameX(x); moveFrameY(y); }
120 void moveFrameX(
int x) { frame.x += x; }
121 void moveFrameY(
int y) { frame.y += y; }
122 void moveDest(
int x,
int y) { moveDestX(x); moveDestY(y); }
123 void moveDestX(
int x) { buff=dest;
if(movedBuff.x!=buff.x || movedBuff.y!=buff.y) {movedBuff=buff;} dest.x += x; }
124 void moveDestY(
int y) { buff=dest;
if(movedBuff.x!=buff.x || movedBuff.y!=buff.y) {movedBuff=buff;} dest.y += y; }
125 void movePos(
int x,
int y) { movePosX(x); movePosY(y); }
126 void movePosX(
int x) { pos.x += x; }
127 void movePosY(
int y) { pos.y += y; }
128 double getVelX() {
return velX; }
129 double getVelY() {
return velY; }
130 void setVelX(
double vx) { velX = vx; }
131 void setVelY(
double vy) { velY = vy; }
133 double getSpeed() {
return speed; }
134 void setSpeed(
double s) { speed = s; }
135 void setName(
string s);
137 void centerOn(
Input i);
138 void centerOn(
int cx,
int cy);
139 void centerOn(
Object obj);
141 color red = {0xff,0,0,0xff};
142 color green = {0,0xff,0,0xff};
143 color blue = {0,0,0xff,0xff};
144 void setColor(color c) {objsColor = c;}
145 void setColor(Uint8 r, Uint8 g, Uint8 b) {objsColor.r=r;objsColor.g=g;objsColor.b=b;}
146 void setTransparency(Uint8 a) {objsColor.a = a;}
147 bool imageSet()
const {
return objsImage;}
148 color getColor()
const {
return objsColor;}
149 void rotateAngle(
int rot);
This class stores information for an Object in the game.
double getY() const
Get the current y coordinate.
void setImage(Image i)
Set the Object's Image with a given Image.
void setFrameY(int y)
Set the y coordinate of the frame.
void setDisplayable(bool d)
This sets if you want the Object to visible on the screen by passing in a boolean.
void setY(double sy)
Set the y coordinate with a given y.
double getX() const
Get the current x coordinate.
void moveY(double my)
Move along the y coordinate with a given y amount.
void setFrame(SDL_Rect i)
Set the frame with a given SDL_Rect.
void loadImage(string file, SDL_Renderer *ren)
Load in either a BMP or PNG file with the path and renderer.
void setDest(SDL_Rect i)
Set the destination with a given SDL_Rect.
SDL_Rect getDest() const
Get the destination for the Object to be displayed on screen.
void setCoord(double x, double y)
Set the coordinate of the Object with a given x and y.
double getAngle() const
Get the Object's angle.
void setFrame(int x, int y, int w, int h)
Set the frame with a given x and y coordinate and width and height.
virtual void checkDisplayable(Object screen)
Checks if the Object is in the given screen.
bool isDisplayable(Object screen)
Check if the Object is displayable by seeing if it is in a given screen.
void setX(double sx)
Set the x coordinate with a given x.
void move(double x, double y)
Move along the x and y coordinate with a given x and y amount.
SDL_Rect getPos() const
Get the position of the Object in the world.
void setFrameSize(int w, int h)
Set the size of the frame with a width and height.
Image getImage() const
Get the Object's Image.
void center(int w, int h)
Center the Object based on a width and height.
void setImage(string file, SDL_Renderer *ren)
Give the path and renderer to create the Object's Image.
Class used for calculating different types of collision between given Objects.
Class for loading in SDL Textures.
SDL_Rect getFrame() const
Get the frame that the Object parses from the Image.
void setPos(SDL_Rect i)
Set the position with a given SDL_Rect.
void lookAt(Object o)
Set the object's angle towards another object.
void setFrameCoord(int x, int y)
Set the x and y coordinate of the frame.
void setVelTo(Object o)
Set the object's velocity toward another object.
void setFrameX(int x)
Set the x coordinate of the frame.
void setAngle(double a)
Set the angle.
void moveX(double mx)
Move along the x coordinate with a given x amount.