dd1c9881857c16dc6ad4d287b42347aed03a3090
[vrlugburz] / src / level.h
1 #ifndef LEVEL_H_
2 #define LEVEL_H_
3
4 #include "scenefile.h"
5
6 #define DEF_CELL_SIZE   3.0f
7
8 enum {
9         TILE_EMPTY,
10         TILE_STRAIGHT,
11         TILE_CORNER,
12         TILE_DOOR
13 };
14
15 enum {
16         CELL_SOLID,
17         CELL_WALK,
18         CELL_BLOCKED
19 };
20
21 struct tile {
22         char *name;
23         int type;
24         struct scenefile scn;
25         struct tile *next;
26 };
27
28 struct cell {
29         int type;
30         int wall[4];
31         int floor, ceil;
32
33         struct meshgroup *mgrp;
34         int num_mgrp;
35
36         struct cell *next;
37 };
38
39 struct level {
40         char *fname, *dirname;
41
42         int width, height;
43         int px, py;                             /* player start position */
44         float cell_size;
45         struct cell *cells;
46
47         struct tile *tiles;
48
49         /* meshes owned by the level, constructed during geometry generation or
50          * loaded, excluding meshes in tiles scenefiles
51          */
52         struct mesh *meshlist;
53 };
54
55
56 int init_level(struct level *lvl, int xsz, int ysz);
57 void destroy_level(struct level *lvl);
58
59 int load_level(struct level *lvl, const char *fname);
60 int save_level(struct level *lvl, const char *fname);
61
62 struct tile *find_level_tile(struct level *lvl, int type);
63
64 int gen_cell_geom(struct level *lvl, struct cell *cell);
65 int gen_level_geom(struct level *lvl);
66
67 #endif  /* LEVEL_H_ */