cmdfx 0.1.1
Lightweight game engine for your terminal
Loading...
Searching...
No Matches
force.h File Reference

Force-related physics declarations. More...

Go to the source code of this file.

Functions

CmdFX_Vector ** Sprite_getAllForces (CmdFX_Sprite *sprite)
 Gets all of the forces acting on a sprite.
 
CmdFX_VectorSprite_getNetForce (CmdFX_Sprite *sprite)
 Gets the net force acting on a sprite.
 
int Sprite_addForce (CmdFX_Sprite *sprite, CmdFX_Vector *force)
 Adds a force to a sprite.
 
int Sprite_removeForce (CmdFX_Sprite *sprite, CmdFX_Vector *force)
 Removes a force from a sprite.
 
int Sprite_removeAllForces (CmdFX_Sprite *sprite)
 Removes all forces from a sprite.
 
double Sprite_getFrictionCoefficient (CmdFX_Sprite *sprite)
 Gets the friction coefficient of a sprite.
 
int Sprite_setFrictionCoefficient (CmdFX_Sprite *sprite, double coefficient)
 Sets the friction coefficient of a sprite.
 
int Sprite_resetFrictionCoefficient (CmdFX_Sprite *sprite)
 Resets the friction coefficient of a sprite.
 
int Sprite_addImpulse (CmdFX_Sprite *sprite, CmdFX_Vector *force, int duration)
 Adds an impulse to a sprite.
 

Detailed Description

Force-related physics declarations.

Author
Gregory Mitchell (me@gm.nosp@m.itch.nosp@m.215.x.nosp@m.yz)
Version
0.1.1
Date
2025-02-09

Function Documentation

◆ Sprite_addForce()

int Sprite_addForce ( CmdFX_Sprite * sprite,
CmdFX_Vector * force )

Adds a force to a sprite.

Parameters
spriteThe sprite to use.
forceThe force to add.
Returns
0 if successful, -1 if an error occurred.

◆ Sprite_addImpulse()

int Sprite_addImpulse ( CmdFX_Sprite * sprite,
CmdFX_Vector * force,
int duration )

Adds an impulse to a sprite.

Parameters
spriteThe sprite to use.
forceThe impulse to add.
durationThe duration of the impulse, in milliseconds.
Returns
0 if successful, -1 if an error occurred.

◆ Sprite_getAllForces()

CmdFX_Vector ** Sprite_getAllForces ( CmdFX_Sprite * sprite)

Gets all of the forces acting on a sprite.

Parameters
spriteThe sprite to use.
Returns
The forces acting on the sprite as a vector array.

◆ Sprite_getFrictionCoefficient()

double Sprite_getFrictionCoefficient ( CmdFX_Sprite * sprite)

Gets the friction coefficient of a sprite.

The friction coefficient is a value between 0 and 1 that determines how much a sprite will slow down when moving on the ground.

If the sprite does not have a custom friction coefficient, the default value of Engine_getDefaultFrictionCoefficient will be returned.

Parameters
spriteThe sprite to use.
Returns
The friction coefficient of the sprite.

◆ Sprite_getNetForce()

CmdFX_Vector * Sprite_getNetForce ( CmdFX_Sprite * sprite)

Gets the net force acting on a sprite.

Parameters
spriteThe sprite to use.
Returns
The net force acting on the sprite.

◆ Sprite_removeAllForces()

int Sprite_removeAllForces ( CmdFX_Sprite * sprite)

Removes all forces from a sprite.

Parameters
spriteThe sprite to use.
Returns
0 if successful, -1 if an error occurred.

◆ Sprite_removeForce()

int Sprite_removeForce ( CmdFX_Sprite * sprite,
CmdFX_Vector * force )

Removes a force from a sprite.

The force will be removed if it is found in the sprite's force array.

Parameters
spriteThe sprite to use.
forceThe force to remove.
Returns
0 if successful, -1 if an error occurred.

◆ Sprite_resetFrictionCoefficient()

int Sprite_resetFrictionCoefficient ( CmdFX_Sprite * sprite)

Resets the friction coefficient of a sprite.

The friction coefficient will be reset to the default value.

Parameters
spriteThe sprite to use.
Returns
0 if successful, -1 if an error occurred.

◆ Sprite_setFrictionCoefficient()

int Sprite_setFrictionCoefficient ( CmdFX_Sprite * sprite,
double coefficient )

Sets the friction coefficient of a sprite.

The friction coefficient is a value between 0 and 1 that determines how much a sprite will slow down when moving on the ground.

Parameters
spriteThe sprite to use.
coefficientThe friction coefficient to set.
Returns
0 if successful, -1 if an error occurred.