dungeon_crawler
view prototype/src/level.h @ 55:4c427e28ca00
music playback bugfixing
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 19 Sep 2012 08:19:10 +0300 |
parents | 303743485aba |
children |
line source
1 #ifndef LEVEL_H_
2 #define LEVEL_H_
4 #include <vector>
5 #include <list>
6 #include "vmath/vmath.h"
7 #include "psys/psys.h"
8 #include "tile.h"
9 #include "audio/auman.h"
11 class GridCell;
13 class Level {
14 private:
15 // cells are stored as a linear array of pointers to GridCells
16 // null pointers mean unpopulated cells.
17 GridCell **cells;
18 int xsz, ysz;
19 float cell_size;
21 // secondary data structure, simple list of all populated cells
22 std::vector<GridCell*> cell_list;
24 // audio manager for static sources in the level
25 AudioManager austatic;
26 Vector3 player_pos;
28 void draw_grid() const;
30 public:
31 Level();
32 ~Level();
34 bool load(const char *fname);
35 bool save(const char *fname) const;
37 GridCell *get_cell(int x, int y);
38 const GridCell *get_cell(int x, int y) const;
39 Vector3 get_cell_pos(int x, int y) const;
40 void get_cell_coords_at(const Vector3 &pos, int *xptr, int *yptr) const;
41 unsigned int get_cell_dirmask(int x, int y) const;
43 void set_player_position(const Vector3 &ppos);
44 void update(unsigned long msec, float dt);
46 void draw() const;
47 void draw_lights() const;
48 void draw_post() const;
50 AudioSample *get_sample(int x, int y, int which) const;
51 };
53 class GridCell {
54 private:
55 // each grid-cell might contain multiple tiles.
56 std::vector<Tile*> tiles;
58 // particle systems
59 std::vector<struct psys_emitter*> psys;
61 unsigned int adjmask;
63 public:
64 GridCell(Tile *tile = 0);
66 void set_adj_mask(unsigned int mask);
67 unsigned int get_adj_mask() const;
69 void add_tile(Tile *tile);
71 void update(unsigned long msec, float dt);
73 void draw(unsigned int draw_mask) const;
74 void draw_lights(unsigned int draw_mask) const;
75 void draw_post(unsigned int draw_mask) const;
77 AudioSample *get_sample(int which) const;
79 std::list<Tile::AudioSourceDesc> get_audio_sources() const;
80 };
82 #endif // LEVEL_H_