using namespace std;
Background::Background(SDL_Surface *screen, std::string name, std::string filename, bool wrap, Point2D ScreenPosition, SizeD ScreenSize, Point2D bgSamplePos, SizeD bgSize):mScreen(screen),_name(name),wrapping(wrap),mPos(ScreenPosition),mScreenSize(ScreenSize){
-/// \todo refactor all width as w height as h X as x Y as y so on and so forth for everything. different things are annoying
- mScreenSize.width = screen->w;
- mScreenSize.height = screen->h;
+ mScreenSize.w = screen->w;
+ mScreenSize.h = screen->h;
- source.w = bgSize.width;
- source.h = bgSize.height;
- source.x = bgSamplePos.X;
- source.y = bgSamplePos.Y;
+ source.w = bgSize.w;
+ source.h = bgSize.h;
+ source.x = bgSamplePos.x;
+ source.y = bgSamplePos.y;
load(filename);
/** \todo decide if wrapping should be a good default.*/
///destination rectangle only position is used and describes where the output is drawn.
SDL_Rect dest;///<the place where the sample will be drawn (can be reused)
- double x = mPos.X;
- double y = mPos.Y;
- const double X = mScreenSize.width;
- const double Y = mScreenSize.height;
- const double W = _imageSize.width;
- const double H = _imageSize.height;
+ double x = mPos.x;
+ double y = mPos.y;
+ const double X = mScreenSize.w;
+ const double Y = mScreenSize.h;
+ const double W = _imageSize.w;
+ const double H = _imageSize.h;
/*
while (x > X) // move it to the left til it's on the screen
x -= X;
}
}
else {
- dest.x = mPos.X;
- dest.y = mPos.Y;
+ dest.x = mPos.x;
+ dest.y = mPos.y;
SDL_BlitSurface(mBackground, &source, mScreen, &dest);
}
}
SizeD getPosition(){return mPos;}
void setWrap(bool tf);
bool getWrap();
- void xadd(int num) {mPos.X += num;}/**< Increase X coordiante by a given amount. */
- void yadd(int num) {mPos.Y += num;}/**< Increase Y coordinate by a given amount. */
- void xset(int x) {mPos.X = x;}/**< Sets the Background's X Coordinate. */
- void yset(int y) {mPos.Y = y;}/**< Sets the Background's Y coordinate. */
- void setPosition(int x, int y) {mPos.X = x; mPos.Y = y;}/**< Sets the Background's X an Y coordinate. */
+ void xadd(int num) {mPos.x += num;}/**< Increase x coordiante by a given amount. */
+ void yadd(int num) {mPos.y += num;}/**< Increase y coordinate by a given amount. */
+ void xset(int x) {mPos.x = x;}/**< Sets the Background's x Coordinate. */
+ void yset(int y) {mPos.y = y;}/**< Sets the Background's y coordinate. */
+ void setPosition(int x, int y) {mPos.x = x; mPos.y = y;}/**< Sets the Background's x an y coordinate. */
};
#endif
}
}
SDL_Rect dest;
- dest.x = mPos.X;
- dest.y = mPos.Y;
+ dest.x = mPos.x;
+ dest.y = mPos.y;
if(mVisible == true)
SDL_BlitSurface(mActor.mAnimations[mActor.mCurrentAnimation]->mAnim[mActor.mFrame].image,NULL,mScreen,&dest);
}
void rewind() {mActor.mFrame = 0;}/**< Resets the Sprite's animation to the first frame. */
std::string name;
void draw();/**< draws Sprite. */
- void xadd(int num) {mPos.X += num;}/**< Increase X coordiante by a given amount. */
- void yadd(int num) {mPos.Y += num;}/**< Increase Y coordinate by a given amount. */
- void xset(int x) {mPos.X = x;}/**< Sets the Sprite's X Coordinate. */
- void yset(int y) {mPos.Y = y;}/**< Sets the Sprite's Y coordinate. */
- void setPosition(int x, int y) {mPos.X = x; mPos.Y = y;}/**< Sets the Sprite's X an Y coordinate. */
+ void xadd(int num) {mPos.x += num;}/**< Increase X coordiante by a given amount. */
+ void yadd(int num) {mPos.y += num;}/**< Increase y coordinate by a given amount. */
+ void xset(int x) {mPos.x = x;}/**< Sets the Sprite's x Coordinate. */
+ void yset(int y) {mPos.y = y;}/**< Sets the Sprite's y coordinate. */
+ void setPosition(int x, int y) {mPos.x = x; mPos.y = y;}/**< Sets the Sprite's x an y coordinate. */
private:
}
double Point2D::length(){
- return sqrt(X*X + Y*Y);///< \todo find math.sqrt
+ return sqrt(x*x + y*y);///< \todo find math.sqrt
}
Point2D Point2D::add(Point2D pt){
- X += pt.X;
- Y += pt.Y;
+ x += pt.x;
+ y += pt.y;
return *this;
}
Point2D Point2D::sub(Point2D pt){
- X -= pt.X;
- Y -= pt.Y;
+ x -= pt.x;
+ y -= pt.y;
return *this;
}
Point2D Point2D::mult(double d){
- X *= d;
- Y *= d;
+ x *= d;
+ y *= d;
return *this;
}
Point2D Point2D::div(double d){
- X /= d;
- Y /= d;
+ x /= d;
+ y /= d;
return *this;
}
SDL_Surface* LoadImage( std::string filename );/**< Loads supported images. */
-class SizeD;
/** 2D position or vector placed here because of general access*/
class Point2D
{
public:
friend class SizeD;
- Point2D ():X(0),Y(0){}
- Point2D (double x, double y):X(x),Y(y){}
+ Point2D ():x(0),y(0){}
+ Point2D (double X, double Y):x(X),y(Y){}
Point2D (const Point2D& copy)///< Copy object
{
- X = copy.X;
- Y = copy.Y;
+ x = copy.x;
+ y = copy.y;
}
-
- Point2D (const SizeD& copy);///< Copy object
+ Point2D (/*const SizeD& copy*/int i);///< Copy object \todo make SizeD work here
/** \todo add typical vector functionality like length, nomal vectors etc. */
- double X;/**< X position */
- double Y;/**< Y Position */
+ double x;/**< x position */
+ double y;/**< y Position */
double length();/**< The length of the Point (from origin)
\return length of the vector/point
*/
{
public:
friend class Pont2D;
- SizeD ():width(0),height(0){}
- SizeD (double w, double h):width(w),height(h){}
+ SizeD ():w(0),h(0){}
+ SizeD (double width, double height):w(width),h(height){}
SizeD (const SizeD& copy)
{
- width = copy.width;
- height = copy.height;
+ w = copy.w;
+ h = copy.h;
}
SizeD (const Point2D& copy)
{
- width = copy.X;
- height = copy.Y;
+ w = copy.x;
+ h = copy.y;
}
- double width;/**< X position */
- double height;/**< Y Position */
+ double w;/**< x position */
+ double h;/**< y Position */
};
//template<class T> string to_string(const T& t);
-
-
#endif