crisp-game-lib-arduboy
Classes | Macros
cglab.h File Reference

Go to the source code of this file.

Classes

struct  CharacterHitBox
 
struct  CharacterData
 
struct  Collision
 

Macros

#define FOR_EACH(array, index)    for (uint8_t index = 0; index < sizeof(array) / sizeof(array[0]); index++)
 Iterate over an array with variable index More...
 
#define ASSIGN_ARRAY_ITEM(array, index, type, item)   type *item = &array[index]
 Assign the index th item in the array to an item variable of type More...
 
#define SKIP_IS_NOT_ALIVE(item)    if (!item->isAlive) continue
 Skip (continue) if the member isAlive of variable item is false. More...
 
#define TIMES(count, index)   for (uint8_t index = 0; index < count; index++)
 Iterate count times with variable index More...
 
#define COUNT_IS_ALIVE(array, counter)
 
#define INIT_UNALIVED_ARRAY(array)
 Set the isAlive member to false for all items in the array More...
 
#define RNDPM()   (rndi(0, 2) * 2 - 1)
 Return 1 or -1 randomly. More...
 

Class Documentation

◆ CharacterHitBox

struct CharacterHitBox
Class Members
uint8_t h:4
uint8_t w:4
uint8_t x:4
uint8_t y:4

◆ CharacterData

struct CharacterData
Class Members
uint8_t grid[CHARACTER_WIDTH]
CharacterHitBox hitBox

◆ Collision

struct Collision
Class Members
uint16_t isColliding[8]

Macro Definition Documentation

◆ ASSIGN_ARRAY_ITEM

#define ASSIGN_ARRAY_ITEM (   array,
  index,
  type,
  item 
)    type *item = &array[index]

Assign the index th item in the array to an item variable of type

◆ COUNT_IS_ALIVE

#define COUNT_IS_ALIVE (   array,
  counter 
)
Value:
uint8_t counter = 0; \
do { \
for (uint8_t i = 0; i < sizeof(array) / sizeof(array[0]); i++) { \
if (array[i].isAlive) { \
counter++; \
} \
} \
} while (0)

Count the number of items in the array for which the isAlive member is true and assigns it to a variable defined as the int variable counter

◆ FOR_EACH

#define FOR_EACH (   array,
  index 
)     for (uint8_t index = 0; index < sizeof(array) / sizeof(array[0]); index++)

Iterate over an array with variable index

◆ INIT_UNALIVED_ARRAY

#define INIT_UNALIVED_ARRAY (   array)
Value:
do { \
for (uint8_t i = 0; i < sizeof(array) / sizeof(array[0]); i++) { \
array[i].isAlive = false; \
} \
} while (0)

Set the isAlive member to false for all items in the array

◆ RNDPM

#define RNDPM ( )    (rndi(0, 2) * 2 - 1)

Return 1 or -1 randomly.

◆ SKIP_IS_NOT_ALIVE

#define SKIP_IS_NOT_ALIVE (   item)     if (!item->isAlive) continue

Skip (continue) if the member isAlive of variable item is false.

◆ TIMES

#define TIMES (   count,
  index 
)    for (uint8_t index = 0; index < count; index++)

Iterate count times with variable index