Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ZE::ZRect Class Reference

#include <ZE_ZRect.h>

List of all members.


Detailed Description

ZRect Rectangle class, used to define a rectangular area or perform operations on the defined area.


Public Methods

 ZRect ()
 Default constructor for ZRect.

 ZRect (int x, int y, int width, int height)
 Constructor for ZRect that takes inital values.

 ZRect (const ZRect &rhs)
 Copy constructor for ZRect.

const ZRect & operator= (const ZRect &rhs)
 Overload for = operator with ZRect.

bool operator< (const ZRect &rhs) const
 Overload for < operator with ZRect, based upon location then size.

void Move (int x, int y)
 Changes the location of the rectangle.

void MoveRel (int xMove, int yMove)
 Changes the location of the rectangle based upon the current location.

void Resize (int width, int height)
 Resize rectangle.

void ResizeRel (int widthChange, int heightChange)
 Grows or shrinks current rectangle.

bool Intersects (const ZRect &rect) const
 Check if one ZRect intersects another.

bool Contains (int x, int y) const
 Check if a rectangle contains a given point.

bool Contains (const ZRect &rect) const
 Check if a rectangle contains a given point.

ZRect Intersection (const ZRect &rect) const
 Finds intersection of two rectangles.

SDL_Rect SDLrect () const
 Returns an SDL_Rect representing the rectangle.

int X () const
 Returns X Location.

int Y () const
 Returns Y Location.

int Left () const
 Return position of left side.

int Right () const
 Return position of right side.

int Top () const
 Return position of top side.

int Bottom () const
 Return position of bottom side.

int Width () const
 Returns Width.

int Height () const
 Returns Height.


Private Attributes

int mX
 X Position of top left corner of rectangle.

int mY
 Y Position of top left corner of rectangle.

int mWidth
 Width of Rectangle.

int mHeight
 Height of Rectangle.


Constructor & Destructor Documentation

ZE::ZRect::ZRect  
 

Default constructor, initializes all values to zero.

ZE::ZRect::ZRect int    x,
int    y,
int    width,
int    height
 

Constructor for ZRect that takes inital values for all four members.

Parameters:
x  Value for x position.
y  Value for y position.
width  Value for width.
height  Value for height.

ZE::ZRect::ZRect const ZRect &    rhs
 

Takes a ZRect and constructs a new identical rectangle.

Parameters:
rhs  Rectangle to construct from.


Member Function Documentation

const ZRect & ZE::ZRect::operator= const ZRect &    rhs
 

Copies all values from one ZRect into another.

Parameters:
rhs  Rectangle to copy values from.
Returns:
New value of the ZRect.

bool ZE::ZRect::operator< const ZRect &    rhs const
 

Rectangles are sorted by y value, followed by x value, if they start at the same place, the smaller of the two is deemed less than the other.

Parameters:
rhs  Rectangle to compare.
Returns:
True if this rectangle is smaller than the rhs rectangle, false otherwise.

void ZE::ZRect::Move int    x,
int    y
 

Changes the current x,y position of the rectangle.

Parameters:
x  New x position for rectangle.
y  New y position for rectangle.

void ZE::ZRect::MoveRel int    xMove,
int    yMove
 

Changes the current x,y position of the rectangle relative to the current location.

Parameters:
xMove  Offset for new x position from current.
yMove  Offset for new y position from current.

void ZE::ZRect::Resize int    width,
int    height
 

Changes the current width and height of the rectangle.

Parameters:
width  New width for rectangle.
height  New height for rectangle.

void ZE::ZRect::ResizeRel int    widthChange,
int    heightChange
 

Changes the current width and height of the rectangle based upon current values.

Parameters:
widthChange  Amount to add or subtract from width.
heightChange  Amount to add or subtract from height.

bool ZE::ZRect::Intersects const ZRect &    rect const
 

Checks for overlap and returns boolean value based on if overlap exists.

Parameters:
rect  Rectangle to check for intersection with.
Returns:
True if intersection occured, false otherwise.

bool ZE::ZRect::Contains int    x,
int    y
const
 

Checks point against boundaries of rectangle and returns result.

Parameters:
x  X value of point to check.
y  Y value of poitn to check.
Returns:
Boolean variable, true if point is inside rectangle, false otherwise.

bool ZE::ZRect::Contains const ZRect &    rect const
 

Checks point against boundaries of rectangle and returns result.

Parameters:
rect  Rectangle to check for point.
Returns:
Boolean variable, true if point is inside rectangle, false otherwise.

ZRect ZE::ZRect::Intersection const ZRect &    rect const
 

Checks for intersection, and returns rectangle where the two rectangles intersect.

Parameters:
rect  Rectangle to check intersection with.
Returns:
ZRect describing intersection area.

SDL_Rect ZE::ZRect::SDLrect  
 

Makes a SDL_Rect representing the rectangle, for use where functions require an SDL_Rect.

Returns:
SDL_Rect representing the ZRect.

int ZE::ZRect::X  
 

Access private X location member.

Returns:
Value of mX.

int ZE::ZRect::Y  
 

Access private Y location member.

Returns:
Value of mY.

int ZE::ZRect::Left  
 

Find X position of left side of rectangle.

Returns:
X position of left side.

int ZE::ZRect::Right  
 

Find X position of right side of rectangle.

Returns:
X position of right side.

int ZE::ZRect::Top  
 

Find Y position of top side of rectangle.

Returns:
Y position of top side.

int ZE::ZRect::Bottom  
 

Find Y position of left side of rectangle.

Returns:
Y position of bottom side.

int ZE::ZRect::Width  
 

Access private width member.

Returns:
Value of mWidth.

int ZE::ZRect::Height  
 

Access private height member.

Returns:
Value of mHeight.


The documentation for this class was generated from the following files:
Generated on Sun Dec 1 02:44:14 2002 for ZEngine by doxygen1.2.18