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