-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlevel.h
56 lines (42 loc) · 1.69 KB
/
level.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef LEVEL_H
#define LEVEL_H
#include <stdbool.h>
#include "mob.h"
#include "item.h"
#include "list.h"
/** The width of a level in characters. */
#define LEVELWIDTH 80
/** The height of a level in characters. */
#define LEVELHEIGHT 20
/**
* A cell is an individual space in a level, they have a base symbol,
* may be solid, may contain at most one occupant mob, and a list of
* items.
*/
typedef struct Cell {
char baseSymbol; /**< The symbol of the cell (floor, wall, etc). */
int colour; /**< The colour to use to render the cell (if unoccupied). */
bool solid; /**< Whether the cell is solid (impassible) or not. */
bool illuminated; /**< Whether the cell is lit by a light or not. */
unsigned int luminosity; /**< Number of light sources in the cell */
struct Mob * occupant; /**< The occpuant (may be NULL). */
struct List * items; /**< The list of items (may be NULL). */
} Cell;
/**
* A level is the current part of the game which is active, it gets rendered
* to the screen, has a bunch of mobs, and a single player.
* Levels form a doubly-linked list.
*/
typedef struct Level {
List levels; /**< The list of levels to which this belongs */
List * mobs; /**< The list of mobs in the level. */
struct Mob * player; /**< The player mob (must also be in mobs). */
unsigned int depth; /**< The depth of the level.*/
int startx, starty; /**< The x and y positions of the stairs from the previous level. */
int endx, endy; /**< The x and y positions of the stairs to the next level. */
struct Cell * cells[LEVELWIDTH][LEVELHEIGHT]; /**< The map. */
} Level;
void build_level(Level * level);
void run_turn(Level * level);
void display_level(Level * level);
#endif /* LEVEL_H */