nuclear@1: #ifndef LEVEL_H_ nuclear@1: #define LEVEL_H_ nuclear@1: nuclear@1: #include nuclear@1: #include "vmath/vmath.h" nuclear@45: #include "psys/psys.h" nuclear@1: nuclear@1: class GridCell; nuclear@1: class Tile; nuclear@1: nuclear@1: class Level { nuclear@1: private: nuclear@1: // cells are stored as a linear array of pointers to GridCells nuclear@1: // null pointers mean unpopulated cells. nuclear@1: GridCell **cells; nuclear@1: int xsz, ysz; nuclear@1: float cell_size; nuclear@1: nuclear@38: // secondary data structure, simple list of all populated cells nuclear@38: std::vector cell_list; nuclear@38: nuclear@1: void draw_grid() const; nuclear@1: nuclear@1: public: nuclear@1: Level(); nuclear@1: ~Level(); nuclear@1: nuclear@1: bool load(const char *fname); nuclear@1: bool save(const char *fname) const; nuclear@1: nuclear@1: const GridCell *get_cell(int x, int y) const; nuclear@1: Vector3 get_cell_pos(int x, int y) const; nuclear@23: unsigned int get_cell_dirmask(int x, int y) const; nuclear@1: nuclear@38: void update(unsigned long msec, float dt); nuclear@38: nuclear@1: void draw() const; nuclear@23: void draw_lights() const; nuclear@40: void draw_post() const; nuclear@1: }; nuclear@1: nuclear@1: class GridCell { nuclear@1: private: nuclear@1: // each grid-cell might contain multiple tiles. nuclear@38: std::vector tiles; nuclear@1: nuclear@45: // particle systems nuclear@45: std::vector psys; nuclear@45: nuclear@1: public: nuclear@38: GridCell(Tile *tile = 0); nuclear@5: nuclear@38: void add_tile(Tile *tile); nuclear@38: nuclear@38: void update(unsigned long msec, float dt); nuclear@1: nuclear@5: void draw(unsigned int draw_mask) const; nuclear@23: void draw_lights(unsigned int draw_mask) const; nuclear@40: void draw_post(unsigned int draw_mask) const; nuclear@1: }; nuclear@1: nuclear@1: #endif // LEVEL_H_