|
Gama C Library
Gama C API Documentation
|
Go to the source code of this file.
Data Structures | |
| struct | gmBody |
| Structure representing a physics body with properties for collision and movement. More... | |
Macros | |
| #define | gnothing NULL |
| Macro representing a NULL pointer, for use where a generic null is needed. | |
Enumerations | |
| enum | gmColliderType { GM_COLLIDER_CIRCLE , GM_COLLIDER_RECT } |
| Enum to define the type of collider for a physics body. More... | |
Functions | |
| gmBody | gm_body_create (double mass, double x, double y, double w, double h, gmColliderType c) |
| Creates a new physics body with specified properties. | |
| void | gm_max_speed (gmBody *body, double max_speed) |
| Limits the maximum speed of a body. | |
| void | gm_min_speed (gmBody *body, double min_speed) |
| Sets the minimum speed of a body. | |
| void | gm_speed (gmBody *body, double speed) |
| Sets the speed of a body while preserving its current direction. | |
| void | gm_max_speed_anim (gmBody *body, double max_speed, void animator(double *value, double target, double dt, double t), double dt, double t) |
| Limits the maximum speed of a body using an animation function. | |
| void | gm_min_speed_anim (gmBody *body, double min_speed, void animator(double *value, double target, double dt, double t), double dt, double t) |
| Sets the minimum speed of a body using an animation function. | |
| void | gm_speed_anim (gmBody *body, double speed, void animator(double *value, double target, double dt, double t), double dt, double t) |
| Sets the speed of a body using an animation function, preserving its direction. | |
| gmBody | gm_rectangle_body (double m, double x, double y, double w, double h) |
| Creates a rectangular physics body. | |
| gmBody | gm_circle_body (double m, double x, double y, double r) |
| Creates a circular physics body. | |
| int | gm_body_contains (gmBody *body, double x, double y) |
| Checks if a point is contained within a body's collider. | |
| #define gnothing NULL |
Macro representing a NULL pointer, for use where a generic null is needed.
| enum gmColliderType |
| int gm_body_contains | ( | gmBody * | body, |
| double | x, | ||
| double | y ) |
Checks if a point is contained within a body's collider.
| body | Pointer to the body to check. |
| x | The x-coordinate of the point. |
| y | The y-coordinate of the point. |
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. |
| gmBody gm_body_create | ( | double | mass, |
| double | x, | ||
| double | y, | ||
| double | w, | ||
| double | h, | ||
| gmColliderType | c ) |
Creates a new physics body with specified properties.
The radius for circular colliders is automatically set based on w (or h if smaller). For rectangular colliders, radius is set to w < h ? w : h.
| mass | The mass of the body. Set to 0 for infinite mass. |
| x | The x-coordinate of the body's initial position. |
| y | The y-coordinate of the body's initial position. |
| w | The width of the body (or diameter for circles). |
| h | The height of the body (or diameter for circles). |
| c | The type of collider for the body (GM_COLLIDER_RECT or GM_COLLIDER_CIRCLE). |
| gmBody gm_circle_body | ( | double | m, |
| double | x, | ||
| double | y, | ||
| double | r ) |
Creates a circular physics body.
| m | The mass of the body. |
| x | The x-coordinate of the body's position. |
| y | The y-coordinate of the body's position. |
| r | The radius of the body. |
| void gm_max_speed | ( | gmBody * | body, |
| double | max_speed ) |
Limits the maximum speed of a body.
If the body's current speed exceeds max_speed, its velocity is scaled down to match max_speed while preserving its direction.
| body | Pointer to the body to modify. |
| max_speed | The maximum allowed speed. |
| void gm_max_speed_anim | ( | gmBody * | body, |
| double | max_speed, | ||
| void | animatordouble *value, double target, double dt, double t, | ||
| double | dt, | ||
| double | t ) |
Limits the maximum speed of a body using an animation function.
This function applies a smooth animation to the body's velocity components if its speed exceeds max_speed.
| body | Pointer to the body to modify. |
| max_speed | The maximum allowed speed. |
| animator | Function pointer to animate the velocity change. |
| dt | Delta time for animation. |
| t | Time parameter for animation. |
| void gm_min_speed | ( | gmBody * | body, |
| double | min_speed ) |
Sets the minimum speed of a body.
If the body's current speed falls below min_speed (and is not zero), its velocity is scaled up to match min_speed while preserving its direction. If the body is stationary (speed is 0), its velocity remains 0.
| body | Pointer to the body to modify. |
| min_speed | The minimum allowed speed. |
| void gm_min_speed_anim | ( | gmBody * | body, |
| double | min_speed, | ||
| void | animatordouble *value, double target, double dt, double t, | ||
| double | dt, | ||
| double | t ) |
Sets the minimum speed of a body using an animation function.
This function applies a smooth animation to the body's velocity components if its speed falls below min_speed (and is not zero).
| body | Pointer to the body to modify. |
| min_speed | The minimum allowed speed. |
| animator | Function pointer to animate the velocity change. |
| dt | Delta time for animation. |
| t | Time parameter for animation. |
| gmBody gm_rectangle_body | ( | double | m, |
| double | x, | ||
| double | y, | ||
| double | w, | ||
| double | h ) |
Creates a rectangular physics body.
| m | The mass of the body. |
| x | The x-coordinate of the body's position. |
| y | The y-coordinate of the body's position. |
| w | The width of the body. |
| h | The height of the body. |
| void gm_speed | ( | gmBody * | body, |
| double | speed ) |
Sets the speed of a body while preserving its current direction.
If the body is stationary, it starts moving along the X-axis with the specified speed.
| body | Pointer to the body to modify. |
| speed | The target speed to set. |
| void gm_speed_anim | ( | gmBody * | body, |
| double | speed, | ||
| void | animatordouble *value, double target, double dt, double t, | ||
| double | dt, | ||
| double | t ) |
Sets the speed of a body using an animation function, preserving its direction.
This function applies a smooth animation to the body's velocity components to reach the speed. If the body is stationary, it starts moving along the X-axis.
| body | Pointer to the body to modify. |
| speed | The target speed to set. |
| animator | Function pointer to animate the velocity change. |
| dt | Delta time for animation. |
| t | Time parameter for animation. |