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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#ifndef map_h_included
#define map_h_included
#include "config.h"
struct Renderer;
struct World;
#define tiles_xmacro \
x(tile_stone, 0, 0) \
x(tile_block1, 16, 0) \
x(tile_block2, 32, 0) \
x(tile_brick, 48, 0) \
x(tile_ladder1, 64, 0) \
x(tile_ladder2, 80, 0) \
x(tile_stone_ramp1, 96, 0) \
x(tile_stone_ramp2, 112, 0) \
x(tile_stone_ramp3, 128, 0) \
x(tile_stone_ramp4, 144, 0) \
x(tile_stone_ramp5, 0, 16) \
x(tile_stone_ramp6, 16, 16) \
x(tile_stone_ramp7, 32, 16) \
x(tile_stone_ramp8, 48, 16) \
x(tile_stone_ramp9, 64, 16) \
x(tile_stone_ramp10, 80, 16) \
x(tile_stone_ramp11, 96, 16) \
x(tile_stone_ramp12, 112, 16) \
x(tile_stone_ramp13, 128, 16) \
x(tile_stone_ramp14, 144, 16) \
x(tile_brick_ramp5, 0, 32) \
x(tile_brick_ramp6, 16, 32) \
x(tile_brick_ramp7, 32, 32) \
x(tile_brick_ramp8, 48, 32) \
x(tile_brick_ramp9, 64, 32) \
x(tile_brick_ramp10, 80, 32) \
x(tile_brick_ramp11, 96, 32) \
x(tile_brick_ramp12, 112, 32) \
x(tile_brick_ramp13, 128, 32) \
x(tile_window_top, 0, 48) \
x(tile_window_mid, 16, 48) \
x(tile_window_bot, 32, 48) \
x(tile_brick_floor, 48, 48) \
x(tile_trapdoor1, 64, 48) \
x(tile_trapdoor2, 80, 48) \
x(tile_trapdoor3, 96, 48) \
x(tile_trapdoor4, 112, 48) \
x(tile_gate, 128, 48) \
x(tile_brick_dark, 144, 48)
typedef enum {
#define x(n, x, y) \
n,
tiles_xmacro
#undef x
tile_count
} Map_Tile;
typedef struct Map {
unsigned short tiles[map_w * map_h];
unsigned short collision[map_w * map_h];
/* collision:
* 0 = nothing
* 1 = tile
* >2 = mask
*/
} Map;
void generate_floor(Map* m, struct World* w, int fi);
void generate_intro(Map* m, struct World* w);
void generate_outro(Map* m, struct World* w);
void render_map(const Map* m, struct Renderer* r);
int room_count(void);
#endif
|