Rect¶
-
struct Rect : public SDL_FRect¶
A 2D rectangle.
Public Functions
-
Rect() = default¶
-
inline Rect(float x, float y, float w, float h)¶
Construct a new rectangle.
- Parameters:
x – The x position.
y – The y position.
w – The width.
h – The height.
-
inline Rect(int x, int y, int w, int h)¶
-
void setSize(const math::Vec2 &size)¶
Set the size of the rectangle.
- Parameters:
size – The new size.
-
bool collidePoint(const math::Vec2 &pos) const¶
Check if the rectangle collides with a point.
- Parameters:
pos – The point to check.
- Returns:
Whether the rectangle collides with a point.
-
bool collideRect(const Rect &rect) const¶
Check if the rectangle collides with another rectangle.
- Parameters:
rect – The rectangle to check.
- Returns:
Whether the rectangle collides with another rectangle.
-
void clamp(const math::Vec2 &min, const math::Vec2 &max)¶
Clamp the rectangle.
- Parameters:
min – The minimum value.
max – The maximum value.
-
void setLeft(float x)¶
-
void setRight(float x)¶
-
void setTop(float y)¶
-
void setBottom(float y)¶
-
float getLeft() const¶
-
float getRight() const¶
-
float getTop() const¶
-
float getBottom() const¶
-
Rect() = default¶