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