dungeon_crawler

view prototype/src/level.h @ 40:38e16366efc2

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 30 Aug 2012 03:05:04 +0300
parents 862461b686f4
children dfd3a413ef9e
line source
1 #ifndef LEVEL_H_
2 #define LEVEL_H_
4 #include <vector>
5 #include "vmath/vmath.h"
7 class GridCell;
8 class Tile;
10 class Level {
11 private:
12 // cells are stored as a linear array of pointers to GridCells
13 // null pointers mean unpopulated cells.
14 GridCell **cells;
15 int xsz, ysz;
16 float cell_size;
18 // secondary data structure, simple list of all populated cells
19 std::vector<GridCell*> cell_list;
21 void draw_grid() const;
23 public:
24 Level();
25 ~Level();
27 bool load(const char *fname);
28 bool save(const char *fname) const;
30 const GridCell *get_cell(int x, int y) const;
31 Vector3 get_cell_pos(int x, int y) const;
32 unsigned int get_cell_dirmask(int x, int y) const;
34 void update(unsigned long msec, float dt);
36 void draw() const;
37 void draw_lights() const;
38 void draw_post() const;
39 };
41 class GridCell {
42 private:
43 // each grid-cell might contain multiple tiles.
44 std::vector<Tile*> tiles;
46 public:
47 GridCell(Tile *tile = 0);
49 void add_tile(Tile *tile);
51 void update(unsigned long msec, float dt);
53 void draw(unsigned int draw_mask) const;
54 void draw_lights(unsigned int draw_mask) const;
55 void draw_post(unsigned int draw_mask) const;
56 };
58 #endif // LEVEL_H_