LI2 Roguelite
Classes | Macros | Typedefs | Functions
state.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  state
 Sructure of the game state. More...
 

Macros

#define DEFAULT_MODE   VISION_MODE
 
#define NORMAL_MODE   0
 
#define DISTANCE_MODE   1
 
#define VISION_MODE   2
 
#define EXIT_MODE   -1
 
#define QUIT_MODE   -2
 
#define EXIT_COST   500
 The cost of the exit. More...
 

Typedefs

typedef struct map Map
 
typedef struct player Player
 
typedef struct monster Monster
 
typedef struct state State
 Sructure of the game state. More...
 

Functions

StateinitState (int width, int height)
 Initialize a new game state. More...
 
void freeState (void *p)
 Free the game state. More...
 
void updateState (State *st, int input_key)
 Update the game state. Used in the main loop. More...
 
void drawState (State *st)
 Draw the game state. More...
 
void calculateState (State *st, int input_key)
 Calulates the state based on the input key. More...
 

Macro Definition Documentation

◆ DEFAULT_MODE

#define DEFAULT_MODE   VISION_MODE

◆ DISTANCE_MODE

#define DISTANCE_MODE   1

◆ EXIT_COST

#define EXIT_COST   500

The cost of the exit.

The cost of the maze exit is 500 gold. It's the only way to win the game. Pay the cost by stepping on the Gate Keeper.

◆ EXIT_MODE

#define EXIT_MODE   -1

◆ NORMAL_MODE

#define NORMAL_MODE   0

◆ QUIT_MODE

#define QUIT_MODE   -2

◆ VISION_MODE

#define VISION_MODE   2

Typedef Documentation

◆ Map

typedef struct map Map

◆ Monster

typedef struct monster Monster

◆ Player

typedef struct player Player

◆ State

typedef struct state State

Sructure of the game state.

Parameters
turnThe current turn of the game
modeThe mode of the game, 0: normal, 1: distance, 2 vision, -1: exit mode
mapThe map of the game, contains the cells, items and projectiles
first_passThe first pass is used in the generation of the map
second_passThe second pass is used in the generation of the map as well
wall_probThe probability of a wall to be generated, default is 40%
playerThe player of the game, contains the inventory
monstersThe monsters of the game (array of pointers)
nMonstersThe number of monsters

Function Documentation

◆ calculateState()

void calculateState ( State st,
int  input_key 
)

Calulates the state based on the input key.

Parameters
stCalculated state
input_keyInput keyboard key
Returns
void (0: normal view, 1: distance view enabled, -1: the player win/lost/quit)

◆ drawState()

void drawState ( State st)

Draw the game state.

Draws the map, the player, the monsters, the items and the projectiles

Parameters
stThe game state to draw

◆ freeState()

void freeState ( void *  p)

Free the game state.

Free the map, the player and the monsters

Parameters
pa pointer to the State to free

◆ initState()

State* initState ( int  width,
int  height 
)

Initialize a new game state.

Generates the map, the player and the monsters Returns NULL if the state could not be initialized

Returns
State*

◆ updateState()

void updateState ( State st,
int  input_key 
)

Update the game state. Used in the main loop.

Calculates the new state based on the input key. Handles the exit and quit modes, then draws the new state.

Parameters
stThe game state to update
input_keyThe input key from player