Claire's Game Engine
Full C++ Engine using OpenGL
|
Represents a 2D axis-aligned rectangle used for UI, collision detection, or rendering. Supports AABB collision checks and conversion to SDL's rectangle format. More...
#include <Rectangle.h>
Public Member Functions | |
Rectangle (Vector2 pPosition=Vector2::ZERO, Vector2 pDimensions=Vector2::ONE) | |
Constructor for Rectangle. | |
SDL_Rect | ToSdlRect () const |
Converts the rectangle to an SDL_Rect structure for rendering or input detection. | |
bool | operator== (const Rectangle &other) const |
bool | operator!= (const Rectangle &other) const |
Static Public Member Functions | |
static bool | Collision (const Rectangle &a, const Rectangle &b) |
Checks for AABB (Axis-Aligned Bounding Box) collision between two rectangles. | |
Public Attributes | |
Vector2 | position |
Top-left corner of the rectangle. | |
Vector2 | dimensions |
Width (x) and height (y) of the rectangle. | |
Static Public Attributes | |
static const Rectangle | NullRect |
A predefined rectangle with zero size and position. | |
Represents a 2D axis-aligned rectangle used for UI, collision detection, or rendering. Supports AABB collision checks and conversion to SDL's rectangle format.
Rectangle::Rectangle | ( | Vector2 | pPosition = Vector2::ZERO, |
Vector2 | pDimensions = Vector2::ONE ) |
Constructor for Rectangle.
pPosition | The top-left position of the rectangle (default: Vector2::ZERO). |
pDimensions | The width and height of the rectangle (default: Vector2::ONE). |
Checks for AABB (Axis-Aligned Bounding Box) collision between two rectangles.
a | The first rectangle. |
b | The second rectangle. |
bool Rectangle::operator!= | ( | const Rectangle & | other | ) | const |
bool Rectangle::operator== | ( | const Rectangle & | other | ) | const |
SDL_Rect Rectangle::ToSdlRect | ( | ) | const |
Converts the rectangle to an SDL_Rect structure for rendering or input detection.
Vector2 Rectangle::dimensions |
Width (x) and height (y) of the rectangle.
|
static |
A predefined rectangle with zero size and position.
Vector2 Rectangle::position |
Top-left corner of the rectangle.