LI2 Roguelite
Functions
cell.c File Reference
#include <stdlib.h>
#include <ncurses.h>
#include "cell.h"
#include "item.h"
Include dependency graph for cell.c:

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...
 

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