Gama C Library
Gama C API Documentation
Loading...
Searching...
No Matches
body.h File Reference
#include "gapi.h"
#include <stdint.h>

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

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 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.
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.

Macro Definition Documentation

◆ gnothing

#define gnothing   NULL

Enumeration Type Documentation

◆ gmColliderType

Enum to define the type of collider for a physics body.

Enumerator
GM_COLLIDER_CIRCLE 

Circular collider

GM_COLLIDER_RECT 

Rectangular collider

Function Documentation

◆ gm_body_contains()

int gm_body_contains ( gmBody * body,
double x,
double y )

Checks if a point is contained within a body's collider.

Parameters
bodyPointer to the body to check.
xThe x-coordinate of the point.
yThe y-coordinate of the point.
Returns
1 if the point is inside the body, 0 otherwise.

◆ gm_body_create()

gmBody gm_body_create ( double mass,
double x,
double y,
double w,
double h,
gmColliderType c )

Creates a new physics body with specified properties.

Parameters
massThe mass of the body.
xThe x-coordinate of the body's position.
yThe y-coordinate of the body's position.
wThe width of the body.
hThe height of the body.
cThe type of collider for the body.
Returns
A new gmBody instance.

◆ gm_circle_body()

gmBody gm_circle_body ( double m,
double x,
double y,
double r )

Creates a circular physics body.

Parameters
mThe mass of the body.
xThe x-coordinate of the body's position.
yThe y-coordinate of the body's position.
rThe radius of the body.
Returns
A new circular gmBody instance.

◆ gm_max_speed()

void gm_max_speed ( gmBody * body,
double max_speed )

Limits the maximum speed of a body.

Parameters
bodyPointer to the body to modify.
max_speedThe maximum allowed speed.

◆ gm_max_speed_anim()

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.

Parameters
bodyPointer to the body to modify.
max_speedThe maximum allowed speed.
animatorFunction pointer to animate the velocity change.
dtDelta time for animation.
tTime parameter for animation.

◆ gm_min_speed()

void gm_min_speed ( gmBody * body,
double min_speed )

Sets the minimum speed of a body.

Parameters
bodyPointer to the body to modify.
min_speedThe minimum allowed speed.

◆ gm_min_speed_anim()

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.

Parameters
bodyPointer to the body to modify.
min_speedThe minimum allowed speed.
animatorFunction pointer to animate the velocity change.
dtDelta time for animation.
tTime parameter for animation.

◆ gm_rectangle_body()

gmBody gm_rectangle_body ( double m,
double x,
double y,
double w,
double h )

Creates a rectangular physics body.

Parameters
mThe mass of the body.
xThe x-coordinate of the body's position.
yThe y-coordinate of the body's position.
wThe width of the body.
hThe height of the body.
Returns
A new rectangular gmBody instance.

◆ gm_speed()

void gm_speed ( gmBody * body,
double speed )

Sets the speed of a body while preserving its direction.

Parameters
bodyPointer to the body to modify.
speedThe speed to set.

◆ gm_speed_anim()

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.

Parameters
bodyPointer to the body to modify.
speedThe speed to set.
animatorFunction pointer to animate the velocity change.
dtDelta time for animation.
tTime parameter for animation.