LI2 Roguelite
cell.h
Go to the documentation of this file.
1 #ifndef _CELL_H_
2 #define _CELL_H_
3 
27 typedef struct cell {
28  char symbol;
29  unsigned int x;
30  unsigned int y;
31  unsigned int is_walkable;
32  unsigned int block_light; // is this cell blocking light?
33  unsigned int was_visible; // was this cell visible?
34  unsigned int is_visible; // is this cell visible?
35  int distance_to_player; // initialized to -1
36  unsigned int has_item; // does this cell have an item?
37  unsigned int has_player; // does this cell have the player?
38  int monster_index; // does this cell have a monster? -1 if not else index in the monster array
39  int effect; // effect of the cell caused by projectiles (0 by default)
40  int effect_duration; // duration of the effect if any (0 by default)
41  int color;
42 } Cell;
43 
44 #define EXIT_SYMBOL 'K' // aka Gate Keeper
45 #define EXIT_COLOR COLOR_YELLOW
46 #define FLOOR_SYMBOL '.'
47 #define FLOOR_COLOR COLOR_GREEN
48 #define WALL_SYMBOL '#'
49 #define WALL_COLOR COLOR_CYAN
50 #define COLOR_SHADOW COLOR_BLUE
51 
52 Cell *initCell(int x, int y, char symbol, int is_walkable, int block_light, int color);
53 Cell *initCellFloor(int x, int y);
54 Cell *initCellWall(int x, int y);
57 int isCellItem(Cell *cell);
58 int isCellMonster(Cell *cell);
59 int isCellExit(Cell *cell);
60 void freeCell(void *p);
61 
62 #endif
Cell * initCellFloor(int x, int y)
Initializes a new floor cell with the initCell() function.
Definition: cell.c:45
int isCellWalkable(Cell *cell)
Checks if a cell is walkable. returns the cell->is_walkable field.
Definition: cell.c:68
int isCellBlockingLight(Cell *cell)
Checks if a cell is blocking light. returns the cell->block_light field.
Definition: cell.c:78
struct cell Cell
Structure of a cell.
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.
Definition: cell.c:18
void freeCell(void *p)
Frees the memory allocated for a cell by initCell(). Sets all the cell fields to 0.
Definition: cell.c:124
Cell * initCellWall(int x, int y)
Initializes a new wall cell with the initCell() function.
Definition: cell.c:58
int isCellMonster(Cell *cell)
Checks if a cell is has a monster.
Definition: cell.c:98
int isCellItem(Cell *cell)
Checks if a cell is has a item. returns the cell->has_item field.
Definition: cell.c:88
int isCellExit(Cell *cell)
Checks if a cell is the exit cell.
Definition: cell.c:115
Structure of a cell.
Definition: cell.h:27
unsigned int x
Definition: cell.h:29
unsigned int was_visible
Definition: cell.h:33
unsigned int is_visible
Definition: cell.h:34
char symbol
Definition: cell.h:28
unsigned int has_player
Definition: cell.h:37
unsigned int has_item
Definition: cell.h:36
int effect
Definition: cell.h:39
int distance_to_player
Definition: cell.h:35
int color
Definition: cell.h:41
int monster_index
Definition: cell.h:38
int effect_duration
Definition: cell.h:40
unsigned int y
Definition: cell.h:30
unsigned int is_walkable
Definition: cell.h:31
unsigned int block_light
Definition: cell.h:32