![]() |
cmdfx 0.2.0
Lightweight game engine for your terminal
|
Global physics engine declarations. More...
#include "cmdfx/core/sprites.h"
Go to the source code of this file.
Functions | |
int | Sprite_isStatic (CmdFX_Sprite *sprite) |
Gets whether this sprite is static. | |
int | Sprite_setStatic (CmdFX_Sprite *sprite, int isStatic) |
Sets whether this sprite is static. | |
double | Engine_getForceOfGravity () |
Gets the force of gravity, in characters per second squared. | |
int | Engine_setForceOfGravity (double force) |
Sets the force of gravity, in characters per second squared. | |
double | Engine_getTerminalVelocity () |
Gets the terminal velocity, in characters per second. | |
int | Engine_setTerminalVelocity (double velocity) |
Sets the terminal velocity, in characters per second. | |
int | Engine_getGroundY () |
Gets the Y level of the ground for the physics engine. | |
int | Engine_setGroundY (int y) |
Sets the Y level of the ground for the physics engine. | |
double | Engine_getDefaultFrictionCoefficient () |
Gets the default friction coefficient for a sprite. | |
int | Engine_setDefaultFrictionCoefficient (double coefficient) |
Sets the default friction coefficient for a sprite. | |
double | Engine_getCharacterMass (char c) |
Gets the default mass of a character. | |
int | Engine_setCharacterMass (char c, double mass) |
Sets the default mass of a character. | |
int | Engine_start () |
Starts up the physics engine. | |
CmdFX_Sprite ** | Engine_tick () |
Ticks the physics engine. | |
int | Engine_cleanup () |
Cleans up the physics engine. | |
int | Engine_end () |
Stops the physics engine. | |
Global physics engine declarations.
int Engine_cleanup | ( | ) |
Cleans up the physics engine.
This is different from Engine_end
, in that it claens up any loose variables before stopping the engine. This is automatically called by Engine_end
and is not intended to be called independently to avoid undefined behavior.
int Engine_end | ( | ) |
Stops the physics engine.
double Engine_getCharacterMass | ( | char | c | ) |
Gets the default mass of a character.
The mass of a sprite is calculated by the number of non-whitespace characters in a sprite map. ANSI codes have no effect on the mass of a character.
You can modify the output value of Sprite_getDefaultMass
by changing the default mass of a character. Every character by default has a mass of 1.
double Engine_getDefaultFrictionCoefficient | ( | ) |
Gets the default friction coefficient for a sprite.
The default friction coefficient is a value between 0 and 1 that determines how much friction is applied to a sprite. A value of 0 means no friction, while a value of 1 means full friction, meaning it will stop immediately.
The default value is 0.25.
double Engine_getForceOfGravity | ( | ) |
Gets the force of gravity, in characters per second squared.
This method returns the force of gravity, in characters per second squared. The default value is 1.0 c/s^2.
int Engine_getGroundY | ( | ) |
Gets the Y level of the ground for the physics engine.
The default value is the canvas height, because (0, 0) refers to the top left of the terminal. The Y level of the ground helps determine when a sprite has landed on the ground.
double Engine_getTerminalVelocity | ( | ) |
Gets the terminal velocity, in characters per second.
This method returns the terminal velocity, in characters per second. The default value is 10.0 c/s.
int Engine_setCharacterMass | ( | char | c, |
double | mass ) |
Sets the default mass of a character.
The mass of a sprite is calculated by the number of non-whitespace characters in a sprite map. ANSI codes have no effect on the mass of a character.
You can modify the output value of Sprite_getDefaultMass
by changing the default mass of a character. Every character by default has a mass of 1.
c | The character to set the mass of. |
mass | The default mass of the character. |
int Engine_setDefaultFrictionCoefficient | ( | double | coefficient | ) |
Sets the default friction coefficient for a sprite.
The default friction coefficient is a value between 0 and 1 that determines how much friction is applied to a sprite. A value of 0 means no friction, while a value of 1 means full friction, meaning it will stop immediately.
The default value is 0.25.
coefficient | The default friction coefficient. |
int Engine_setForceOfGravity | ( | double | force | ) |
Sets the force of gravity, in characters per second squared.
This method sets the force of gravity, in characters per second squared. The default value is 1.0 c/s^2.
force | The force of gravity, in c/s^2. |
int Engine_setGroundY | ( | int | y | ) |
Sets the Y level of the ground for the physics engine.
The default value is the canvas height. The Y level of the ground helps determine when a sprite has landed on the ground.
y | The Y level of the ground. |
int Engine_setTerminalVelocity | ( | double | velocity | ) |
Sets the terminal velocity, in characters per second.
This method sets the terminal velocity, in characters per second. The default value is 10 c/s.
velocity |
int Engine_start | ( | ) |
Starts up the physics engine.
This method starts up the physics engine. This method will automatically enable thread safety if it is not already enabled.
CmdFX_Sprite ** Engine_tick | ( | ) |
Ticks the physics engine.
This method ticks the physcis engine, if it is running. This is automatically called once per frame.
NULL
pointer. The array is automatically freed by the engine, so it should not be freed by the caller. int Sprite_isStatic | ( | CmdFX_Sprite * | sprite | ) |
Gets whether this sprite is static.
A sprite is static if it is not affected by the physics engine.
sprite | The sprite to check. |
int Sprite_setStatic | ( | CmdFX_Sprite * | sprite, |
int | isStatic ) |
Sets whether this sprite is static.
A sprite is static if it is not affected by the physics engine. Use this method to set whether a sprite is static or not.
sprite | The sprite to modify. |
isStatic | 1 if the sprite is static, 0 otherwise. |