e2d::core::Rect Class Reference

Inheritance diagram for e2d::core::Rect:

e2d::graphics::Image e2d::graphics::ImageData e2d::graphics::Label e2d::graphics::Sprite e2d::graphics::TileMap e2d::graphics::TTF e2d::graphics::Video e2d::graphics::Window

List of all members.


Detailed Description

In fact, this class is a simple wrapper around SDL_Rect, with some nice constructors and getter and setter methods.

Public Member Functions

 Rect (int x, int y, int w, int h)
 Constructor.
 Rect (const Rect &original)
 Copy constructor.
void Add (const Rect &other_rect)
 Sums up both rects.
bool Collide (const Rect &other_rect)
 Tests if two rects are colliding (overlapping).
void Copy (const Rect &other_rect)
 Copy other rect's data to this one.
bool Equals (const Rect &other_rect)
 Compares two rects.
SDL_Rect * GetSDL_Rect (void)
 Getter for the rectangle.
int GetH (void)
 Getter for height.
int GetX (void)
 Getter for X coordinate.
int GetY (void)
 Getter for Y coordinate.
int GetW (void)
 Getter for width.
void Move (int x, int y)
 Adds to the current position.
void Resize (int w, int h)
 Adds to the current dimension.
void SetDimension (int w, int h)
 Sets dimension.
void SetPosition (int x, int y)
 Sets position.
void SetH (int h)
 Setter for height.
void SetX (int x)
 Setter for X coordinate.
void SetY (int y)
 Setter for Y coordinate.
void SetW (int w)
 Setter for width.

Constructor & Destructor Documentation

e2d::core::Rect::Rect ( int  x,
int  y,
int  w,
int  h 
)

Initializes the rectangle.

Parameters:
x X coordinate of upper-left point.
y Y coordinate of upper-left point.
w Width of the rectangle, in pixels.
h Height of the rectangle, in pixels.

e2d::core::Rect::Rect ( const Rect original  ) 

Makes a copy of another rectangle.

Parameters:
original Rectangle to copy data from.


Member Function Documentation

void e2d::core::Rect::Add ( const Rect other_rect  ) 

Sums up both rects and sets the result to this rect.

Parameters:
other_rect Rect to sum.

bool e2d::core::Rect::Collide ( const Rect other_rect  ) 

Tests if two rects are colliding (overlapping)

Parameters:
other_rect Rect to test against.
Returns:
true if rects collide, false otherwise.

void e2d::core::Rect::Copy ( const Rect other_rect  ) 

Copies the X, Y, W and H attributes of the other rect into this.

Parameters:
other_rect Rect to copy data from.

bool e2d::core::Rect::Equals ( const Rect other_rect  ) 

Compares two rects.

Parameters:
other_rect Rect to compare to.
Returns:
true if other_rect is equal to this, false otherwise

SDL_Rect * e2d::core::Rect::GetSDL_Rect ( void   ) 

Getter for the rectangle

Returns:
Pointer to SDL_Rect (SDL_Rect is part of SDL)

void e2d::core::Rect::Move ( int  x,
int  y 
)

Adds to the current position.

Parameters:
x Amount to add in the X axis.
y Amount to add in the Y axis.

void e2d::core::Rect::Resize ( int  w,
int  h 
)

Adds to the current dimension.

Parameters:
w Amount to add to the Width (W)
h Amount to add to the Height (H)

void e2d::core::Rect::SetDimension ( int  w,
int  h 
)

Modifies W and H coordinates

Parameters:
w New width.
h New height.

void e2d::core::Rect::SetPosition ( int  x,
int  y 
)

Modifies X and Y coordinates.

Parameters:
x New position in the X axis.
y New position the Y axis.


Generated on Tue Dec 8 10:32:44 2009 for Easy2D by  doxygen 1.5.6