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

Go to the source code of this file.

Classes

struct  cell
 Structure of a cell. More...
 

Macros

#define EXIT_SYMBOL   'K'
 
#define EXIT_COLOR   COLOR_YELLOW
 
#define FLOOR_SYMBOL   '.'
 
#define FLOOR_COLOR   COLOR_GREEN
 
#define WALL_SYMBOL   '#'
 
#define WALL_COLOR   COLOR_CYAN
 
#define COLOR_SHADOW   COLOR_BLUE
 

Typedefs

typedef struct cell Cell
 Structure of a cell. More...
 

Functions

CellinitCell (int x, int y, char symbol, int is_walkable, int block_light, int color)
 Initializes a new cell. Allocates memory for a new cell and initializes its fields. More...
 
CellinitCellFloor (int x, int y)
 Initializes a new floor cell with the initCell() function. More...
 
CellinitCellWall (int x, int y)
 Initializes a new wall cell with the initCell() function. More...
 
int isCellWalkable (Cell *cell)
 Checks if a cell is walkable. returns the cell->is_walkable field. More...
 
int isCellBlockingLight (Cell *cell)
 Checks if a cell is blocking light. returns the cell->block_light field. More...
 
int isCellItem (Cell *cell)
 Checks if a cell is has a item. returns the cell->has_item field. More...
 
int isCellMonster (Cell *cell)
 Checks if a cell is has a monster. More...
 
int isCellExit (Cell *cell)
 Checks if a cell is the exit cell. More...
 
void freeCell (void *p)
 Frees the memory allocated for a cell by initCell(). Sets all the cell fields to 0. More...
 

Macro Definition Documentation

◆ COLOR_SHADOW

#define COLOR_SHADOW   COLOR_BLUE

◆ EXIT_COLOR

#define EXIT_COLOR   COLOR_YELLOW

◆ EXIT_SYMBOL

#define EXIT_SYMBOL   'K'

◆ FLOOR_COLOR

#define FLOOR_COLOR   COLOR_GREEN

◆ FLOOR_SYMBOL

#define FLOOR_SYMBOL   '.'

◆ WALL_COLOR

#define WALL_COLOR   COLOR_CYAN

◆ WALL_SYMBOL

#define WALL_SYMBOL   '#'

Typedef Documentation

◆ Cell

typedef struct cell Cell

Structure of a cell.

A cell is a single unit of the map with 2D coordinates, a symbol, a walkable flag, a blocking light flag, a distance to the player, a visibility flag and a color.

Parameters
symbolCharacter to be displayed on the screen
xX coordinate
yY coordinate
is_walkable1 if the cell is walkable, 0 otherwise
block_light1 if the cell blocks light, 0 otherwise
was_visible1 if the cell was visible, 0 otherwise
is_visible1 if the cell is visible, 0 otherwise
distance_to_playerDistance to the player, initialized to -1
has_item1 if the cell has an item, 0 otherwise
has_player1 if the cell has the player, 0 otherwise
monster_index1 if the cell has a monster, 0 otherwise
effectEffect of the cell caused by projectiles (0 by default)
effect_durationDuration of the effect if any (0 by default)
colorColor of the cell

TODO:

Parameters
monsterMonster in this cell, if not NULL instead of monster_index

Function Documentation

◆ freeCell()

void freeCell ( void *  p)

Frees the memory allocated for a cell by initCell(). Sets all the cell fields to 0.

Parameters
pCell to free

◆ initCell()

Cell* initCell ( int  x,
int  y,
char  symbol,
int  is_walkable,
int  block_light,
int  color 
)

Initializes a new cell. Allocates memory for a new cell and initializes its fields.

Parameters
xCell x coordinate
yCell y coordinate
symbolCell symbol
is_walkableIs the cell walkable?
block_lightIs the cell blocking light?
colorCell color
Returns
Cell* Initialized cell

◆ initCellFloor()

Cell* initCellFloor ( int  x,
int  y 
)

Initializes a new floor cell with the initCell() function.

A floor cell is walkable, doesn't block light and has a grey color.

Parameters
xCell x coordinate
yCell y coordinate
Returns
Cell* Initialized cell as a floor cell

◆ initCellWall()

Cell* initCellWall ( int  x,
int  y 
)

Initializes a new wall cell with the initCell() function.

A wall cell is not walkable, blocks light and has a black color.

Parameters
xCell x coordinate
yCell y coordinate
Returns
Cell* Initialized cell as a wall cell

◆ isCellBlockingLight()

int isCellBlockingLight ( Cell cell)

Checks if a cell is blocking light. returns the cell->block_light field.

Parameters
cellCell to check
Returns
int 1 if the cell is blocking light, 0 otherwise

◆ isCellExit()

int isCellExit ( Cell cell)

Checks if a cell is the exit cell.

Parameters
cellCell to check
Returns
int 1 if the cell is the exit cell, 0 otherwise

◆ isCellItem()

int isCellItem ( Cell cell)

Checks if a cell is has a item. returns the cell->has_item field.

Parameters
cellCell to check
Returns
int 1 if the cell has a item, 0 otherwise

◆ isCellMonster()

int isCellMonster ( Cell cell)

Checks if a cell is has a monster.

Parameters
cellCell to check
Returns
int 1 if the cell has a monster, 0 otherwise

◆ isCellWalkable()

int isCellWalkable ( Cell cell)

Checks if a cell is walkable. returns the cell->is_walkable field.

Parameters
cellCell to check
Returns
int 1 if the cell is walkable, 0 otherwise