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