dungeon_crawler

view prototype/src/level.h @ 48:aa9e28670ae2

added sound playback, more to do
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 17 Sep 2012 08:40:59 +0300
parents dfd3a413ef9e
children 303743485aba
line source
1 #ifndef LEVEL_H_
2 #define LEVEL_H_
4 #include <vector>
5 #include "vmath/vmath.h"
6 #include "psys/psys.h"
7 #include "tile.h"
9 class GridCell;
11 class Level {
12 private:
13 // cells are stored as a linear array of pointers to GridCells
14 // null pointers mean unpopulated cells.
15 GridCell **cells;
16 int xsz, ysz;
17 float cell_size;
19 // secondary data structure, simple list of all populated cells
20 std::vector<GridCell*> cell_list;
22 void draw_grid() const;
24 public:
25 Level();
26 ~Level();
28 bool load(const char *fname);
29 bool save(const char *fname) const;
31 const GridCell *get_cell(int x, int y) const;
32 Vector3 get_cell_pos(int x, int y) const;
33 void get_cell_coords_at(const Vector3 &pos, int *xptr, int *yptr) const;
34 unsigned int get_cell_dirmask(int x, int y) const;
36 void update(unsigned long msec, float dt);
38 void draw() const;
39 void draw_lights() const;
40 void draw_post() const;
42 AudioSample *get_sample(int x, int y, int which) const;
43 };
45 class GridCell {
46 private:
47 // each grid-cell might contain multiple tiles.
48 std::vector<Tile*> tiles;
50 // particle systems
51 std::vector<struct psys_emitter*> psys;
53 public:
54 GridCell(Tile *tile = 0);
56 void add_tile(Tile *tile);
58 void update(unsigned long msec, float dt);
60 void draw(unsigned int draw_mask) const;
61 void draw_lights(unsigned int draw_mask) const;
62 void draw_post(unsigned int draw_mask) const;
64 AudioSample *get_sample(int which) const;
65 };
67 #endif // LEVEL_H_