Go to the source code of this file.
◆ DEFAULT_MODE
◆ DISTANCE_MODE
◆ EXIT_COST
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
◆ NORMAL_MODE
◆ QUIT_MODE
◆ VISION_MODE
◆ Map
◆ Monster
◆ Player
◆ State
Sructure of the game state.
- Parameters
-
| turn | The current turn of the game |
| mode | The mode of the game, 0: normal, 1: distance, 2 vision, -1: exit mode |
| map | The map of the game, contains the cells, items and projectiles |
| first_pass | The first pass is used in the generation of the map |
| second_pass | The second pass is used in the generation of the map as well |
| wall_prob | The probability of a wall to be generated, default is 40% |
| player | The player of the game, contains the inventory |
| monsters | The monsters of the game (array of pointers) |
| nMonsters | The number of monsters |
◆ calculateState()
| void calculateState |
( |
State * |
st, |
|
|
int |
input_key |
|
) |
| |
Calulates the state based on the input key.
- Parameters
-
| st | Calculated state |
| input_key | Input 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
-
◆ freeState()
| void freeState |
( |
void * |
p | ) |
|
Free the game state.
Free the map, the player and the monsters
- Parameters
-
| p | a 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
-
| st | The game state to update |
| input_key | The input key from player |