Raylib C++  1.0.0
Encapsulates the raylib library
Static Public Member Functions | List of all members
raylib::helper::Collision2DHelper Class Reference

Helper class for 2D collision detection. More...

#include <Collision2DHelper.hpp>

Collaboration diagram for raylib::helper::Collision2DHelper:
Collaboration graph

Static Public Member Functions

static bool checkCollisionRecs (const Rectangle &rec1, const Rectangle &rec2)
 Check if two rectangles are colliding. More...
 
static bool checkCollisionCircles (const Vector2f &center1, const float &radius1, const Vector2f &center2, const float &radius2)
 Check if two circles are colliding. More...
 
static bool checkCollisionCircleRec (const Vector2f &center, const float &radius, const Rectangle &rec)
 Check if a circle is colliding with a rectangle. More...
 
static bool checkCollisionPointRec (const Vector2f &point, const Rectangle &rec)
 Check if point is inside rectangle. More...
 
static bool checkCollisionPointCircle (const Vector2f &point, const Vector2f &center, const float &radius)
 Check if point is inside circle. More...
 
static bool checkCollisionPointTriangle (const Vector2f &point, const Vector2f &p1, const Vector2f &p2, const Vector2f &p3)
 Check if point is inside a triangle. More...
 
static bool checkCollisionLines (const Vector2f &startPos1, const Vector2f &endPos1, const Vector2f &startPos2, const Vector2f &endPos2, Vector2f &collisionPoint)
 Check the collision between two lines defined by two points each, returns collision point by reference. More...
 
static bool checkCollisionPointLine (const Vector2f &point, const Vector2f &p1, const Vector2f &p2, const int &threshold)
 Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]. More...
 
static Rectangle getCollisionRec (const Rectangle &rec1, const Rectangle &rec2)
 Get collision rectangle for two rectangles collision. More...
 

Detailed Description

Helper class for 2D collision detection.

Member Function Documentation

◆ checkCollisionCircleRec()

bool raylib::helper::Collision2DHelper::checkCollisionCircleRec ( const Vector2f center,
const float &  radius,
const Rectangle &  rec 
)
static

Check if a circle is colliding with a rectangle.

Parameters
centerthe circle center
radiusthe circle radius
recthe rectangle
Returns
true if the circle is colliding with the rectangle, false otherwise
Here is the call graph for this function:

◆ checkCollisionCircles()

bool raylib::helper::Collision2DHelper::checkCollisionCircles ( const Vector2f center1,
const float &  radius1,
const Vector2f center2,
const float &  radius2 
)
static

Check if two circles are colliding.

Parameters
center1the first circle center
radius1the first circle radius
center2the second circle center
radius2the second circle radius
Returns
true if the circles are colliding, false otherwise
Here is the call graph for this function:

◆ checkCollisionLines()

bool raylib::helper::Collision2DHelper::checkCollisionLines ( const Vector2f startPos1,
const Vector2f endPos1,
const Vector2f startPos2,
const Vector2f endPos2,
Vector2f collisionPoint 
)
static

Check the collision between two lines defined by two points each, returns collision point by reference.

Parameters
startPos1the first line start position
endPos1the first line end position
startPos2the second line start position
endPos2the second line end position
collisionPointthe collision point (stored in it)
Returns
true if the lines are colliding, false otherwise
Here is the call graph for this function:

◆ checkCollisionPointCircle()

bool raylib::helper::Collision2DHelper::checkCollisionPointCircle ( const Vector2f point,
const Vector2f center,
const float &  radius 
)
static

Check if point is inside circle.

Parameters
pointthe point
centerthe circle center
radiusthe circle radius
Returns
true if the point is colliding with the circle, false otherwise
Here is the call graph for this function:

◆ checkCollisionPointLine()

bool raylib::helper::Collision2DHelper::checkCollisionPointLine ( const Vector2f point,
const Vector2f p1,
const Vector2f p2,
const int &  threshold 
)
static

Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold].

Parameters
pointthe point
p1the first line point
p2the second line point
thresholdthe margin in pixels
Returns
true if the point is colliding with the line, false otherwise
Here is the call graph for this function:

◆ checkCollisionPointRec()

bool raylib::helper::Collision2DHelper::checkCollisionPointRec ( const Vector2f point,
const Rectangle &  rec 
)
static

Check if point is inside rectangle.

Parameters
pointthe point
recthe rectangle
Returns
true if the point is colliding with the rectangle, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkCollisionPointTriangle()

bool raylib::helper::Collision2DHelper::checkCollisionPointTriangle ( const Vector2f point,
const Vector2f p1,
const Vector2f p2,
const Vector2f p3 
)
static

Check if point is inside a triangle.

Parameters
pointthe point
p1the first triangle point
p2the second triangle point
p3the third triangle point
Returns
true if the point is colliding with the triangle, false otherwise
Here is the call graph for this function:

◆ checkCollisionRecs()

bool raylib::helper::Collision2DHelper::checkCollisionRecs ( const Rectangle &  rec1,
const Rectangle &  rec2 
)
static

Check if two rectangles are colliding.

Parameters
rec1the first rectangle
rec2the second rectangle
Returns
true if the rectangles are colliding, false otherwise

◆ getCollisionRec()

Rectangle raylib::helper::Collision2DHelper::getCollisionRec ( const Rectangle &  rec1,
const Rectangle &  rec2 
)
static

Get collision rectangle for two rectangles collision.

Parameters
rec1the first rectangle
rec2the second rectangle
Returns
the collision rectangle

The documentation for this class was generated from the following files: