3a31af67d5ac51df1778529f20eedff1199938a4
[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_OPEN,
10         TILE_STR,
11         TILE_CORNER,
12         TILE_TEE,
13         TILE_CROSS,
14         TILE_STR2OPEN
15 };
16
17 enum {
18         CELL_SOLID,
19         CELL_WALK,
20         CELL_BLOCKED
21 };
22
23 struct tile {
24         char *name;
25         int type;
26         struct tile *next;
27 };
28
29 struct cell {
30         int type;
31         int wall[4];
32         int floor, ceil;
33
34         struct meshgroup *mgrp;
35         int num_mgrp;
36
37         struct cell *next;
38 };
39
40 struct level {
41         char *fname, *dirname;
42
43         int width, height;
44         int px, py;                             /* player start position */
45         float cell_size;
46         struct cell *cells;
47
48         struct tileset *tset;
49
50         /* meshes owned by the level, constructed during geometry generation or
51          * loaded, excluding meshes in tiles scenefiles
52          */
53         struct mesh *meshlist;
54 };
55
56
57 int init_level(struct level *lvl, int xsz, int ysz);
58 void destroy_level(struct level *lvl);
59
60 int load_level(struct level *lvl, const char *fname);
61 int save_level(struct level *lvl, const char *fname);
62
63 struct tile *find_level_tile(struct level *lvl, int type);
64
65 int gen_cell_geom(struct level *lvl, struct cell *cell);
66 int gen_level_geom(struct level *lvl);
67
68 #endif  /* LEVEL_H_ */