diff --git a/include/ZE_ZRect.h b/include/ZE_ZRect.h
index 8d01cc6..24b64cd 100644
--- a/include/ZE_ZRect.h
+++ b/include/ZE_ZRect.h
@@ -13,7 +13,7 @@
File: ZE_ZRect.h
Description: Header file for core ZEngine Rectangle Object.
Author(s): James Turk
-$Id: ZE_ZRect.h,v 1.2 2002/12/01 08:36:39 cozman Exp $
+$Id: ZE_ZRect.h,v 1.3 2002/12/04 05:22:40 cozman Exp $
\file ZE_ZRect.h
\brief Definition file for ZRect.
@@ -38,13 +38,13 @@ class ZRect
{
protected:
//! X Position of top left corner of rectangle.
- int rX;
+ float rX;
//! Y Position of top left corner of rectangle.
- int rY;
+ float rY;
//! Width of Rectangle.
- int rWidth;
+ float rWidth;
//! Height of Rectangle.
- int rHeight;
+ float rHeight;
public:
@@ -64,7 +64,7 @@ class ZRect
\param width Value for width.
\param height Value for height.
**/
- ZRect(int x, int y, int width, int height);
+ ZRect(float x, float y, float width, float height);
/*!
\brief Copy constructor for ZRect.
@@ -111,7 +111,7 @@ class ZRect
\param x New x position for rectangle.
\param y New y position for rectangle.
**/
- void Move(int x, int y);
+ void Move(float x, float y);
/*!
\brief Changes the location of the rectangle based upon the current location.
@@ -120,7 +120,7 @@ class ZRect
\param xMove Offset for new x position from current.
\param yMove Offset for new y position from current.
**/
- void MoveRel(int xMove, int yMove);
+ void MoveRel(float xMove, float yMove);
/*!
\brief Resize rectangle.
@@ -129,7 +129,7 @@ class ZRect
\param width New width for rectangle.
\param height New height for rectangle.
**/
- void Resize(int width, int height);
+ void Resize(float width, float height);
/*!
\brief Grows or shrinks current rectangle.
@@ -138,7 +138,7 @@ class ZRect
\param widthChange Amount to add or subtract from width.
\param heightChange Amount to add or subtract from height.
**/
- void ResizeRel(int widthChange, int heightChange);
+ void ResizeRel(float widthChange, float heightChange);
/*!
\brief Check if one ZRect intersects another.
@@ -157,7 +157,7 @@ class ZRect
\param y Y value of poitn to check.
\return Boolean variable, true if point is inside rectangle, false otherwise.
**/
- bool Contains(int x, int y) const;
+ bool Contains(float x, float y) const;
/*!
\brief Check if a rectangle contains a given point.
@@ -191,7 +191,7 @@ class ZRect
Access private X location member.
\return Value of mX.
**/
- int X() const;
+ float X() const;
/*!
\brief Returns Y Location.
@@ -199,7 +199,7 @@ class ZRect
Access private Y location member.
\return Value of mY.
**/
- int Y() const;
+ float Y() const;
/*!
\brief Return position of left side.
@@ -207,7 +207,7 @@ class ZRect
Find X position of left side of rectangle.
\return X position of left side.
**/
- int Left() const;
+ float Left() const;
/*!
\brief Return position of right side.
@@ -215,7 +215,7 @@ class ZRect
Find X position of right side of rectangle.
\return X position of right side.
**/
- int Right() const;
+ float Right() const;
/*!
\brief Return position of top side.
@@ -223,7 +223,7 @@ class ZRect
Find Y position of top side of rectangle.
\return Y position of top side.
**/
- int Top() const;
+ float Top() const;
/*!
\brief Return position of bottom side.
@@ -231,7 +231,7 @@ class ZRect
Find Y position of left side of rectangle.
\return Y position of bottom side.
**/
- int Bottom() const;
+ float Bottom() const;
/*!
\brief Returns Width.
@@ -239,7 +239,7 @@ class ZRect
Access private width member.
\return Value of mWidth.
**/
- int Width() const;
+ float Width() const;
/*!
\brief Returns Height.
@@ -247,7 +247,7 @@ class ZRect
Access private height member.
\return Value of mHeight.
**/
- int Height() const;
+ float Height() const;
};
} //namspace ZE
diff --git a/src/ZE_ZRect.cpp b/src/ZE_ZRect.cpp
index e0755f2..513268c 100644
--- a/src/ZE_ZRect.cpp
+++ b/src/ZE_ZRect.cpp
@@ -13,7 +13,7 @@
File: ZE_ZRect.cpp
Description: Implementation source file for core ZEngine Rectangle Object.
Author(s): James Turk
-$Id: ZE_ZRect.cpp,v 1.2 2002/12/01 08:36:39 cozman Exp $
+$Id: ZE_ZRect.cpp,v 1.3 2002/12/04 05:22:39 cozman Exp $
\file ZE_ZRect.cpp
\brief Source file for ZRect.
@@ -31,7 +31,7 @@ ZRect::ZRect() :
{
}
-ZRect::ZRect(int x, int y, int width, int height) :
+ZRect::ZRect(float x, float y, float width, float height) :
rX(x),rY(y),rWidth(width),rHeight(height)
{
}
@@ -90,32 +90,32 @@ void ZRect::Draw(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha)
{
glColor4ub(red,green,blue,alpha);
glBegin(GL_QUADS);
- glVertex2i(rX, rY);
- glVertex2i(rX+rWidth, rY);
- glVertex2i(rX+rWidth, rY+rHeight);
- glVertex2i(rX, rY+rHeight);
+ glVertex2f(rX, rY);
+ glVertex2f(rX+rWidth, rY);
+ glVertex2f(rX+rWidth, rY+rHeight);
+ glVertex2f(rX, rY+rHeight);
glEnd();
}
-void ZRect::Move(int x, int y)
+void ZRect::Move(float x, float y)
{
rX = x;
rY = y;
}
-void ZRect::MoveRel(int xMove, int yMove)
+void ZRect::MoveRel(float xMove, float yMove)
{
rX += xMove;
rY += yMove;
}
-void ZRect::Resize(int width, int height)
+void ZRect::Resize(float width, float height)
{
rWidth = width;
rHeight = height;
}
-void ZRect::ResizeRel(int widthChange, int heightChange)
+void ZRect::ResizeRel(float widthChange, float heightChange)
{
rWidth += widthChange;
rHeight += heightChange;
@@ -127,7 +127,7 @@ bool ZRect::Intersects(const ZRect &rect) const
rY > rect.Bottom() || rect.Top() > rY+rHeight);
}
-bool ZRect::Contains(int x, int y) const
+bool ZRect::Contains(float x, float y) const
{
return x > rX && x < rX+rWidth && y > rY && y < rY+rHeight;
}
@@ -141,7 +141,7 @@ bool ZRect::Contains(const ZRect &rect) const
ZRect ZRect::Intersection(const ZRect &rect) const
{
- int tempX=0,tempY=0,tempW=0,tempH=0;
+ float tempX=0,tempY=0,tempW=0,tempH=0;
if(Intersects(rect))
{
@@ -169,42 +169,42 @@ SDL_Rect ZRect::SDLrect() const
return ret;
}
-int ZRect::X() const
+float ZRect::X() const
{
return rX;
}
-int ZRect::Y() const
+float ZRect::Y() const
{
return rY;
}
-int ZRect::Left() const
+float ZRect::Left() const
{
return rX;
}
-int ZRect::Right() const
+float ZRect::Right() const
{
return rX+rWidth;
}
-int ZRect::Top() const
+float ZRect::Top() const
{
return rY;
}
-int ZRect::Bottom() const
+float ZRect::Bottom() const
{
return rY+rHeight;
}
-int ZRect::Width() const
+float ZRect::Width() const
{
return rWidth;
}
-int ZRect::Height() const
+float ZRect::Height() const
{
return rHeight;
}
diff --git a/test/ZRectTest.cpp b/test/ZRectTest.cpp
index 902875f..adc1ca2 100644
--- a/test/ZRectTest.cpp
+++ b/test/ZRectTest.cpp
@@ -35,6 +35,7 @@ void Test()
{
ZEngine *engine = ZEngine::GetInstance();
ZRect moveRect(0,0,25,25),stillRect(100,100,100,100);
+ double movDelta;
do
{
@@ -49,14 +50,15 @@ void Test()
if(engine->KeyIsPressed(SDLK_ESCAPE))
engine->RequestQuit();
//movement//
+ movDelta = engine->GetFrameTime()*30;
if(engine->KeyPress(SDLK_LEFT))
- moveRect.MoveRel(-3,0);
+ moveRect.MoveRel(-movDelta,0);
if(engine->KeyPress(SDLK_RIGHT))
- moveRect.MoveRel(3,0);
+ moveRect.MoveRel(movDelta,0);
if(engine->KeyPress(SDLK_UP))
- moveRect.MoveRel(0,-3);
+ moveRect.MoveRel(0,-movDelta);
if(engine->KeyPress(SDLK_DOWN))
- moveRect.MoveRel(0,3);
+ moveRect.MoveRel(0,movDelta);
if(engine->KeyIsPressed(SDLK_EQUALS))
{
moveRect.MoveRel(-1,-1);