Go to the source code of this file.
◆ COLOR_SHADOW
| #define COLOR_SHADOW COLOR_BLUE |
◆ EXIT_COLOR
| #define EXIT_COLOR COLOR_YELLOW |
◆ EXIT_SYMBOL
◆ FLOOR_COLOR
| #define FLOOR_COLOR COLOR_GREEN |
◆ FLOOR_SYMBOL
◆ WALL_COLOR
| #define WALL_COLOR COLOR_CYAN |
◆ WALL_SYMBOL
◆ 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
-
| symbol | Character to be displayed on the screen |
| x | X coordinate |
| y | Y coordinate |
| is_walkable | 1 if the cell is walkable, 0 otherwise |
| block_light | 1 if the cell blocks light, 0 otherwise |
| was_visible | 1 if the cell was visible, 0 otherwise |
| is_visible | 1 if the cell is visible, 0 otherwise |
| distance_to_player | Distance to the player, initialized to -1 |
| has_item | 1 if the cell has an item, 0 otherwise |
| has_player | 1 if the cell has the player, 0 otherwise |
| monster_index | 1 if the cell has a monster, 0 otherwise |
| effect | Effect of the cell caused by projectiles (0 by default) |
| effect_duration | Duration of the effect if any (0 by default) |
| color | Color of the cell |
TODO:
- Parameters
-
| monster | Monster in this cell, if not NULL instead of monster_index |
◆ freeCell()
| void freeCell |
( |
void * |
p | ) |
|
Frees the memory allocated for a cell by initCell(). Sets all the cell fields to 0.
- Parameters
-
◆ 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
-
| x | Cell x coordinate |
| y | Cell y coordinate |
| symbol | Cell symbol |
| is_walkable | Is the cell walkable? |
| block_light | Is the cell blocking light? |
| color | Cell 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
-
| x | Cell x coordinate |
| y | Cell 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
-
| x | Cell x coordinate |
| y | Cell 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
-
- 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
-
- 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
-
- 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
-
- 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
-
- Returns
- int 1 if the cell is walkable, 0 otherwise