crisp-game-lib-portable
Classes | Macros
cglp.h File Reference

Go to the source code of this file.

Classes

struct  Collisions
 
struct  Collision
 
struct  ButtonState
 
struct  Input
 
struct  Options
 
struct  CharacterOptions
 

Macros

#define FOR_EACH(array, index)    for (int 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 (int 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

◆ Collisions

struct Collisions
Class Members
bool character[ASCII_CHARACTER_COUNT]
bool rect[COLOR_COUNT]
bool text[ASCII_CHARACTER_COUNT]

◆ Collision

struct Collision
Class Members
Collisions isColliding

◆ ButtonState

struct ButtonState
Class Members
bool isJustPressed
bool isJustReleased
bool isPressed

◆ Input

struct Input
Class Members
ButtonState a
ButtonState b
ButtonState down
bool isJustPressed
bool isJustReleased
bool isPressed
ButtonState left
ButtonState right
ButtonState up

◆ Options

struct Options
Class Members
bool isDarkColor
int soundSeed
int viewSizeX
int viewSizeY

◆ CharacterOptions

struct CharacterOptions
Class Members
bool isMirrorX
bool isMirrorY
int rotation

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:
int counter = 0; \
do { \
for (int 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 (int 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 (int 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 (int index = 0; index < count; index++)

Iterate count times with variable index