LI2 Roguelite
Macros | Functions
state.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <ncurses.h>
#include "state.h"
#include "player.h"
#include "map.h"
#include "cell.h"
#include "item.h"
#include "inventory.h"
#include "monster.h"
#include "combat.h"
#include "menu.h"
Include dependency graph for state.c:

Macros

#define NUMBER_OF_ITEMS   30
 

Functions

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

Macro Definition Documentation

◆ NUMBER_OF_ITEMS

#define NUMBER_OF_ITEMS   30

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