crisp-game-lib-portable
|
Functions | |
Collision | rect (float x, float y, float w, float h) |
Collision | box (float x, float y, float w, float h) |
Draw a box. Returns information on objects that collided while drawing. More... | |
Collision | line (float x1, float y1, float x2, float y2) |
Draw a line. Returns information on objects that collided while drawing. More... | |
Collision | bar (float x, float y, float length, float angle) |
Draw a bar. Returns information on objects that collided while drawing. More... | |
Collision | arc (float centerX, float centerY, float radius, float angleFrom, float angleTo) |
Draw a arc. Returns information on objects that collided while drawing. More... | |
Collision | text (char *msg, float x, float y) |
Draw a text. Returns information on objects that collided while drawing. More... | |
Collision | character (char *msg, float x, float y) |
void | play (int type) |
void | enableSound () |
Enable playing background music and sound effects. More... | |
void | disableSound () |
Disable playing background music and sound effects. More... | |
void | toggleSound () |
Toggle sound playing flag. More... | |
void | addScore (float value, float x, float y) |
void | particle (float x, float y, float count, float speed, float angle, float angleWidth) |
Add particles. More... | |
EMSCRIPTEN_KEEPALIVE void | setButtonState (bool left, bool right, bool up, bool down, bool b, bool a) |
float | rnd (float low, float high) |
Get a random float value of [low, high). More... | |
int | rndi (int low, int high) |
Get a random int value of [low, high - 1]. More... | |
void | consoleLog (char *format,...) |
float | clamp (float v, float low, float high) |
Clamp a value to [low, high]. More... | |
float | wrap (float v, float low, float high) |
Wrap a value to [low, high). More... | |
char * | intToChar (int v) |
Convert a value of type int to a value of type char* . More... | |
void | gameOver () |
Transit to the game-over state. More... | |
void | goToMenu () |
Go to the game selection menu screen. More... | |
void | restartGame (int gameIndex) |
Restart another game specified by gameIndex . More... | |
EMSCRIPTEN_KEEPALIVE void | initGame () |
EMSCRIPTEN_KEEPALIVE void | updateFrame () |
Variables | |
int | ticks |
A variable incremented by one every 1/60 of a second (readonly). More... | |
float | score |
Game score. More... | |
float | difficulty |
int | color |
float | thickness |
Set the thickness for drawing line() , bar() and arc() . More... | |
float | barCenterPosRatio |
CharacterOptions | characterOptions |
Options for drawing text() and character() . More... | |
bool | hasCollision |
float | tempo = 120 |
Tempo of background music. More... | |
Input | input |
Input state from the buttons (readonly). More... | |
Input | currentInput |
Input state (used to get input on title screen) (readonly). More... | |
bool | isInMenu |
Set to true when the menu screen is open (readonly). More... | |
void addScore | ( | float | value, |
float | x, | ||
float | y | ||
) |
Add score points and draw additional score on the screen. You can also add score points simply by adding the score
variable.
Collision arc | ( | float | centerX, |
float | centerY, | ||
float | radius, | ||
float | angleFrom, | ||
float | angleTo | ||
) |
Draw a arc. Returns information on objects that collided while drawing.
Collision bar | ( | float | x, |
float | y, | ||
float | length, | ||
float | angle | ||
) |
Draw a bar. Returns information on objects that collided while drawing.
Collision box | ( | float | x, |
float | y, | ||
float | w, | ||
float | h | ||
) |
Draw a box. Returns information on objects that collided while drawing.
Collision character | ( | char * | msg, |
float | x, | ||
float | y | ||
) |
Draw a pixel art. Returns information on objects that collided while drawing. You can define pixel arts (6x6 dots) of characters with characters
array.
float clamp | ( | float | v, |
float | low, | ||
float | high | ||
) |
Clamp a value to [low, high].
void consoleLog | ( | char * | format, |
... | |||
) |
Print a message to the console (the same arguments as for printf can be used).
void disableSound | ( | ) |
Disable playing background music and sound effects.
void enableSound | ( | ) |
Enable playing background music and sound effects.
void gameOver | ( | ) |
Transit to the game-over state.
void goToMenu | ( | ) |
Go to the game selection menu screen.
EMSCRIPTEN_KEEPALIVE void initGame | ( | ) |
Initialize all games and go to the game selection menu screen. This function must be called from the machine dependent setup step.
char * intToChar | ( | int | v | ) |
Convert a value of type int
to a value of type char*
.
Collision line | ( | float | x1, |
float | y1, | ||
float | x2, | ||
float | y2 | ||
) |
Draw a line. Returns information on objects that collided while drawing.
void particle | ( | float | x, |
float | y, | ||
float | count, | ||
float | speed, | ||
float | angle, | ||
float | angleWidth | ||
) |
Add particles.
void play | ( | int | type | ) |
Play a sound effect. Type are COIN
, LASER
, EXPLOSION
, POWER_UP
, HIT
, JUMP
, SELECT
, CLICK
and RANDOM
.
Collision rect | ( | float | x, |
float | y, | ||
float | w, | ||
float | h | ||
) |
Draw a rectangle. Returns information on objects that collided while drawing.
void restartGame | ( | int | gameIndex | ) |
Restart another game specified by gameIndex
.
float rnd | ( | float | low, |
float | high | ||
) |
Get a random float value of [low, high).
int rndi | ( | int | low, |
int | high | ||
) |
Get a random int value of [low, high - 1].
EMSCRIPTEN_KEEPALIVE void setButtonState | ( | bool | left, |
bool | right, | ||
bool | up, | ||
bool | down, | ||
bool | b, | ||
bool | a | ||
) |
Set whether or not each button is pressed. This function must be called from the machine dependent input handling step.
Collision text | ( | char * | msg, |
float | x, | ||
float | y | ||
) |
Draw a text. Returns information on objects that collided while drawing.
void toggleSound | ( | ) |
Toggle sound playing flag.
EMSCRIPTEN_KEEPALIVE void updateFrame | ( | ) |
Update game frames every 1/60 second. This function must be called from the machine dependent update step.
float wrap | ( | float | v, |
float | low, | ||
float | high | ||
) |
Wrap a value to [low, high).
float barCenterPosRatio |
A value from 0 to 1 that defines where the center coordinates are on the bar()
, default: 0.5.
CharacterOptions characterOptions |
Options for drawing text()
and character()
.
int color |
Set the color for drawing rectangles, particles, texts, and characters. Setting the color prior to text()
and character()
will recolor the pixel art. Use color = BLACK
to restore and use the original colors. Colors are WHITE
, RED
, GREEN
, YELLOW
, BLUE
, PURPLE
, CYAN
, BLACK
, LIGHT_*
and TRANSPARENT
.
float difficulty |
A variable that is one at the beginning of the game, two after 1 minute, and increasing by one every minute (readonly).
bool hasCollision |
If hasCollision
is set to true
, the drawn rectangle will have no collision with other rectangles. Used to improve performance.
bool isInMenu |
Set to true
when the menu screen is open (readonly).
float score |
Game score.
float tempo = 120 |
Tempo of background music.
int ticks |
A variable incremented by one every 1/60 of a second (readonly).