crisp-game-lib-arduboy
Functions | Variables
cglab.c File Reference

Functions

bool colRect (Collision *cl, uint8_t color)
 Whether it's colliding with rects. More...
 
bool colText (Collision *cl, char text)
 Whether it's colliding with texts. More...
 
bool colCharacter (Collision *cl, char character)
 Whether it's colliding with characters. More...
 
Collision rect (float x, float y, float w, float h)
 Draw a rectangle. Returns information on objects that collided while drawing. More...
 
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 constText (const char *msg, float x, float y)
 Draw a const text. Returns information on objects that collided while drawing. More...
 
Collision character (char character, float x, float y)
 
void play (uint8_t type)
 
void enableSound (void)
 Enable playing background music and sound effects. More...
 
void disableSound (void)
 Disable playing background music and sound effects. More...
 
void toggleSound (void)
 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...
 
bool btn (uint8_t button)
 Whether the button is being pressed. Button are INPUT_*. More...
 
bool btnp (uint8_t button)
 Whether the button is just pressed now. Button are INPUT_*. More...
 
bool btnr (uint8_t button)
 Whether the button is just released now. Button are INPUT_*. More...
 
float rnd (float low, float high)
 Get a random float value of [low, high). More...
 
int16_t rndi (int16_t low, int16_t high)
 Get a random int value of [low, high - 1]. More...
 
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...
 
void gameOver (void)
 Transit to the game-over state. More...
 
void setupGame (const char *_title, const char *_description, const CharacterData *_characters, const uint8_t **_sounds, void(*_update)(void))
 Setup game. More...
 
void initGame (void)
 Initialize game. More...
 
bool updateGame (void)
 Update game frames if it's every 1/60 second timing. More...
 

Variables

uint16_t ticks
 A variable incremented by one every 1/60 of a second (readonly). More...
 
float score
 Game score. More...
 
float difficulty
 
int8_t color
 
float thickness
 Set the thickness for drawing line(), bar() and arc(). More...
 
float barCenterPosRatio
 
bool hasCollision
 

Function Documentation

◆ addScore()

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.

◆ arc()

Collision arc ( float  centerX,
float  centerY,
float  radius,
float  angleFrom,
float  angleTo 
)

Draw a arc. Returns information on objects that collided while drawing.

◆ bar()

Collision bar ( float  x,
float  y,
float  length,
float  angle 
)

Draw a bar. Returns information on objects that collided while drawing.

◆ box()

Collision box ( float  x,
float  y,
float  w,
float  h 
)

Draw a box. Returns information on objects that collided while drawing.

◆ btn()

bool btn ( uint8_t  button)

Whether the button is being pressed. Button are INPUT_*.

◆ btnp()

bool btnp ( uint8_t  button)

Whether the button is just pressed now. Button are INPUT_*.

◆ btnr()

bool btnr ( uint8_t  button)

Whether the button is just released now. Button are INPUT_*.

◆ character()

Collision character ( char  character,
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.

◆ clamp()

float clamp ( float  v,
float  low,
float  high 
)

Clamp a value to [low, high].

◆ colCharacter()

bool colCharacter ( Collision cl,
char  character 
)

Whether it's colliding with characters.

◆ colRect()

bool colRect ( Collision cl,
uint8_t  color 
)

Whether it's colliding with rects.

◆ colText()

bool colText ( Collision cl,
char  text 
)

Whether it's colliding with texts.

◆ constText()

Collision constText ( const char *  msg,
float  x,
float  y 
)

Draw a const text. Returns information on objects that collided while drawing.

◆ disableSound()

void disableSound ( void  )

Disable playing background music and sound effects.

◆ enableSound()

void enableSound ( void  )

Enable playing background music and sound effects.

◆ gameOver()

void gameOver ( void  )

Transit to the game-over state.

◆ initGame()

void initGame ( void  )

Initialize game.

◆ line()

Collision line ( float  x1,
float  y1,
float  x2,
float  y2 
)

Draw a line. Returns information on objects that collided while drawing.

◆ particle()

void particle ( float  x,
float  y,
float  count,
float  speed,
float  angle,
float  angleWidth 
)

Add particles.

◆ play()

void play ( uint8_t  type)

Play a sound effect. Type are COIN, LASER, EXPLOSION, POWER_UP, HIT, JUMP, SELECT, CLICK and RANDOM.

◆ rect()

Collision rect ( float  x,
float  y,
float  w,
float  h 
)

Draw a rectangle. Returns information on objects that collided while drawing.

◆ rnd()

float rnd ( float  low,
float  high 
)

Get a random float value of [low, high).

◆ rndi()

int16_t rndi ( int16_t  low,
int16_t  high 
)

Get a random int value of [low, high - 1].

◆ setupGame()

void setupGame ( const char *  _title,
const char *  _description,
const CharacterData _characters,
const uint8_t **  _sounds,
void(*)(void)  _update 
)

Setup game.

◆ text()

Collision text ( char *  msg,
float  x,
float  y 
)

Draw a text. Returns information on objects that collided while drawing.

◆ toggleSound()

void toggleSound ( void  )

Toggle sound playing flag.

◆ updateGame()

bool updateGame ( void  )

Update game frames if it's every 1/60 second timing.

◆ wrap()

float wrap ( float  v,
float  low,
float  high 
)

Wrap a value to [low, high).

Variable Documentation

◆ barCenterPosRatio

float barCenterPosRatio

A value from 0 to 1 that defines where the center coordinates are on the bar(), default: 0.5.

◆ color

int8_t 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 = LIGHT1 to restore and use the original colors. Colors are DARK*, LIGHT*, INVERT* and TRANSPARENT.

◆ difficulty

float difficulty

A variable that is one at the beginning of the game, two after 1 minute, and increasing by one every minute (readonly).

◆ hasCollision

bool hasCollision

If hasCollision is set to true, the drawn rectangle will have no collision with other rectangles. Used to improve performance.

◆ score

float score

Game score.

◆ thickness

float thickness

Set the thickness for drawing line(), bar() and arc().

◆ ticks

uint16_t ticks

A variable incremented by one every 1/60 of a second (readonly).