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