Explorar o código

Merge pull request #222 from blackberry-gaming/next-setaylor

Next setaylor
Sean Paul Taylor %!s(int64=13) %!d(string=hai) anos
pai
achega
b1b068da23
Modificáronse 2 ficheiros con 18 adicións e 18 borrados
  1. 11 11
      gameplay/src/Rectangle.cpp
  2. 7 7
      gameplay/src/Rectangle.h

+ 11 - 11
gameplay/src/Rectangle.cpp

@@ -9,12 +9,12 @@ Rectangle::Rectangle()
 {
 }
 
-Rectangle::Rectangle(unsigned int width, unsigned int height) :
+Rectangle::Rectangle(float width, float height) :
     x(0), y(0), width(width), height(height)
 {
 }
 
-Rectangle::Rectangle(float x, float y, unsigned int width, unsigned int height) :
+Rectangle::Rectangle(float x, float y, float width, float height) :
     x(x), y(y), width(width), height(height)
 {
 }
@@ -44,7 +44,7 @@ void Rectangle::set(const Rectangle& r)
     set(r.x, r.y, r.width, r.height);
 }
 
-void Rectangle::set(float x, float y, unsigned int width, unsigned int height)
+void Rectangle::set(float x, float y, float width, float height)
 {
     this->x = x;
     this->y = y;
@@ -70,22 +70,22 @@ float Rectangle::top() const
 
 float Rectangle::right() const
 {
-    return x + (float)width;
+    return x + width;
 }
 
 float Rectangle::bottom() const
 {
-    return y + (float)height;
+    return y + height;
 }
 
 bool Rectangle::contains(float x, float y) const
 {
-    return (x >= x && x <= (x + (float)width) && y >= y && y <= (y + (float)height));
+    return (x >= x && x <= (x + width) && y >= y && y <= (y + height));
 }
 
-bool Rectangle::contains(float x, float y, unsigned int width, unsigned int height) const
+bool Rectangle::contains(float x, float y, float width, float height) const
 {
-    return (contains(x, y) && contains(x + (float)width, y + (float)height));
+    return (contains(x, y) && contains(x + width, y + height));
 }
 
 bool Rectangle::contains(const Rectangle& r) const
@@ -93,12 +93,12 @@ bool Rectangle::contains(const Rectangle& r) const
     return contains(r.x, r.y, r.width, r.height);
 }
 
-bool Rectangle::intersects(float x, float y, unsigned int width, unsigned int height) const
+bool Rectangle::intersects(float x, float y, float width, float height) const
 {
     const float left   = max(this->x, x);
     const float top    = max(this->y, y);
-    const float right  = min(x + (float)width, x + (float)width);
-    const float bottom = min(y + (float)height, y + (float)height);
+    const float right  = min(x + width, x + width);
+    const float bottom = min(y + height, y + height);
 
     return (right > left && bottom > top);
 }

+ 7 - 7
gameplay/src/Rectangle.h

@@ -25,12 +25,12 @@ public:
     /**
      * Specifies the width of the rectangle.
      */
-    unsigned int width;
+    float width;
 
     /**
      * Specifies the height of the rectangle.
      */
-    unsigned int height;
+    float height;
 
     /**
      * Constructs a new rectangle initialized to all zeros.
@@ -43,7 +43,7 @@ public:
      * @param width The width of the rectangle.
      * @param height The height of the rectangle.
      */
-    Rectangle(unsigned int width, unsigned int height);
+    Rectangle(float width, float height);
 
     /**
      * Constructs a new rectangle with the specified x, y, width and height.
@@ -53,7 +53,7 @@ public:
      * @param width The width of the rectangle.
      * @param height The height of the rectangle.
      */
-    Rectangle(float x, float y, unsigned int width, unsigned int height);
+    Rectangle(float x, float y, float width, float height);
 
     /**
      * Constructs a new rectangle that is a copy of the specified rectangle.
@@ -89,7 +89,7 @@ public:
      * @param width The width of the rectangle.
      * @param height The height of the rectangle.
      */
-    void set(float x, float y, unsigned int width, unsigned int height);
+    void set(float x, float y, float width, float height);
 
     /**
      * Sets the values of this rectangle to those in the specified rectangle.
@@ -155,7 +155,7 @@ public:
      * @return true if the rectangle contains the specified rectangle, false
      * otherwise.
      */
-    bool contains(float x, float y, unsigned int width, unsigned int height) const;
+    bool contains(float x, float y, float width, float height) const;
 
     /**
      * Determines whether this rectangle contains a specified rectangle.
@@ -177,7 +177,7 @@ public:
      * 
      * @return true if the specified Rectangle intersects with this one, false otherwise.
      */
-    bool intersects(float x, float y, unsigned int width, unsigned int height) const;
+    bool intersects(float x, float y, float width, float height) const;
 
     /**
      * Determines whether a specified rectangle intersects with this rectangle.