From: Ivan Hernandez Date: Sun, 9 Jan 2011 20:45:11 +0000 (-0600) Subject: updated Y to y X to x width to w height to h etc X-Git-Url: http://git.mmlx.us/?a=commitdiff_plain;h=c84b137d0933b1b2f8ff5f61b8bb4120adafb02a;p=IvanGame.git updated Y to y X to x width to w height to h etc --- diff --git a/Background.cpp b/Background.cpp index 1a33a68..5e395b0 100644 --- a/Background.cpp +++ b/Background.cpp @@ -3,14 +3,13 @@ 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); @@ -20,12 +19,12 @@ void Background::draw(){ /** \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;/// X) // move it to the left til it's on the screen x -= X; @@ -133,8 +132,8 @@ void Background::draw(){ } } else { - dest.x = mPos.X; - dest.y = mPos.Y; + dest.x = mPos.x; + dest.y = mPos.y; SDL_BlitSurface(mBackground, &source, mScreen, &dest); } } diff --git a/Background.h b/Background.h index 2742d6c..1a72d6d 100644 --- a/Background.h +++ b/Background.h @@ -44,10 +44,10 @@ class Background{ 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 diff --git a/Sprite.cpp b/Sprite.cpp index 03917ab..39fb7e9 100644 --- a/Sprite.cpp +++ b/Sprite.cpp @@ -29,8 +29,8 @@ void Sprite::draw() } } 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); } diff --git a/Sprite.h b/Sprite.h index 9d22e36..3062991 100644 --- a/Sprite.h +++ b/Sprite.h @@ -28,11 +28,11 @@ class Sprite 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: diff --git a/fns.cpp b/fns.cpp index 844b467..17b4405 100644 --- a/fns.cpp +++ b/fns.cpp @@ -41,27 +41,27 @@ SDL_Surface* LoadImage( std::string filename ) } 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; } diff --git a/fns.h b/fns.h index 35870c2..ee09912 100644 --- a/fns.h +++ b/fns.h @@ -9,25 +9,23 @@ using namespace std; 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 */ @@ -43,24 +41,22 @@ class SizeD { 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 string to_string(const T& t); - - #endif