updated Y to y X to x width to w height to h etc
authorIvan Hernandez <iturtleman128@gmail.com>
Sun, 9 Jan 2011 20:45:11 +0000 (14:45 -0600)
committerIvan Hernandez <iturtleman128@gmail.com>
Sun, 9 Jan 2011 20:45:11 +0000 (14:45 -0600)
Background.cpp
Background.h
Sprite.cpp
Sprite.h
fns.cpp
fns.h

index 1a33a68..5e395b0 100644 (file)
@@ -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;///<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;
@@ -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);
        }
 }
index 2742d6c..1a72d6d 100644 (file)
@@ -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
index 03917ab..39fb7e9 100644 (file)
@@ -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);
 }
index 9d22e36..3062991 100644 (file)
--- 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 (file)
--- 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 (file)
--- 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<class T> string to_string(const T& t);
-
-
 #endif