Fireset
Loading...
Searching...
No Matches
Physics

Simple 2D physics simulation module. More...

Classes

struct  FsBody
 Physics body. More...
struct  FsSpace
 Physics simulation space. More...

Enumerations

enum  FsBodyType { FS_BODY_QUAD , FS_BODY_CIRCLE }
 Physics body types. More...

Functions

FsSpace fsSpaceCreate (FsVec2 gravity, FsVec2 damping)
 Creates a physics simulation space.
void fsSpaceAddBody (FsSpace *space, FsBody *body)
 Adds a body to a physics space.
void fsSpaceStep (FsSpace *space, float stepTime)
 Advances the physics simulation.
bool fsIsQuadColiding (FsBody quad1, FsBody quad2)
 Checks collision between two quad bodies.

Detailed Description

Simple 2D physics simulation module.

Enumeration Type Documentation

◆ FsBodyType

enum FsBodyType

Physics body types.

Defines the shape and behavior of a physics body.

Enumerator
FS_BODY_QUAD 

Circle Body

FS_BODY_CIRCLE 

Axis-aligned rectangle body

Function Documentation

◆ fsIsQuadColiding()

bool fsIsQuadColiding ( FsBody quad1,
FsBody quad2 )

Checks collision between two quad bodies.

Performs an axis-aligned bounding box (AABB) collision test. Only bodies of type FS_BODY_QUAD are supported.

Parameters
quad1First body.
quad2Second body.
Returns
true if the bodies are colliding, false otherwise.

◆ fsSpaceAddBody()

void fsSpaceAddBody ( FsSpace * space,
FsBody * body )

Adds a body to a physics space.

Inserts a body so it will be updated during simulation. If the body limit is exceeded, the body is not added.

Parameters
spacePointer to the physics space.
bodyPointer to the body to add.
Note
The space does not manage the lifetime of the body.

◆ fsSpaceCreate()

FsSpace fsSpaceCreate ( FsVec2 gravity,
FsVec2 damping )

Creates a physics simulation space.

Initializes a physics space with gravity and damping parameters. The space starts empty, with no bodies attached.

Parameters
gravityGravity applied to all bodies.
dampingVelocity damping applied every simulation step.
Returns
Initialized physics space.

◆ fsSpaceStep()

void fsSpaceStep ( FsSpace * space,
float stepTime )

Advances the physics simulation.

Steps the physics simulation forward using a fixed timestep. Gravity, damping and velocity integration are applied.

Parameters
spacePointer to the physics space.
stepTimeSimulation frequency (e.g. 60.0f for 60 Hz).
Note
Uses fsTimeGetDelta() internally.