|
Gama C Library
Gama C API Documentation
|
Defines collision structures and provides functions for 2D collision detection. More...
Go to the source code of this file.
Data Structures | |
| struct | gm_collision |
| Structure to store detailed information about a collision between two bodies. More... | |
Typedefs | |
| typedef struct gm_collision | gmCollision |
| Structure to store detailed information about a collision between two bodies. | |
Functions | |
| gmCollision * | gm_collision_detect (gmBody *a, gmBody *b) |
| Detects a collision between two physics bodies based on their collider types. | |
| int | gm_body_contains (gmBody *body, double x, double y) |
| Checks if a given point (x, y) is contained within a body's collider. | |
| int | gm_mouse_in_rect (const double x, const double y, const double w, const double h) |
| Checks if the mouse cursor is currently within a given rectangular area. | |
| int | gm_mouse_in_circle (const double x, const double y, const double r) |
| Checks if the mouse cursor is currently within a given circular area. | |
Defines collision structures and provides functions for 2D collision detection.
This file contains the core logic for detecting collisions between different types of physics bodies (rectangles and circles) and structures to hold collision information.
| typedef struct gm_collision gmCollision |
Structure to store detailed information about a collision between two bodies.
| int gm_body_contains | ( | gmBody * | body, |
| double | x, | ||
| double | y ) |
Checks if a given point (x, y) is contained within a body's collider.
Checks if a point is contained within a body's collider.
This function performs a point-in-rectangle test for GM_COLLIDER_RECT and a point-in-circle test for GM_COLLIDER_CIRCLE.
| body | Pointer to the body to check. |
| x | The x-coordinate of the point. |
| y | The y-coordinate of the point. |
| gmCollision * gm_collision_detect | ( | gmBody * | a, |
| gmBody * | b ) |
Detects a collision between two physics bodies based on their collider types.
Detects a collision between two physics bodies.
This function dispatches to specific collision tests (e.g., AABB vs AABB, Circle vs Circle, Circle vs AABB) based on the collider_type of the input bodies.
| a | Pointer to the first body. |
| b | Pointer to the second body. |
| int gm_mouse_in_circle | ( | const double | x, |
| const double | y, | ||
| const double | r ) |
Checks if the mouse cursor is currently within a given circular area.
| x | The x-coordinate of the center of the circle. |
| y | The y-coordinate of the center of the circle. |
| r | The radius of the circle. |
| int gm_mouse_in_rect | ( | const double | x, |
| const double | y, | ||
| const double | w, | ||
| const double | h ) |
Checks if the mouse cursor is currently within a given rectangular area.
| x | The x-coordinate of the center of the rectangle. |
| y | The y-coordinate of the center of the rectangle. |
| w | The width of the rectangle. |
| h | The height of the rectangle. |