dungeon_crawler

view prototype/src/level.h @ 49:303743485aba

pretty much implemented the positional torch sound sources
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 18 Sep 2012 00:34:29 +0300
parents aa9e28670ae2
children c40efa9cf844
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 const GridCell *get_cell(int x, int y) const;
38 Vector3 get_cell_pos(int x, int y) const;
39 void get_cell_coords_at(const Vector3 &pos, int *xptr, int *yptr) const;
40 unsigned int get_cell_dirmask(int x, int y) const;
42 void set_player_position(const Vector3 &ppos);
43 void update(unsigned long msec, float dt);
45 void draw() const;
46 void draw_lights() const;
47 void draw_post() const;
49 AudioSample *get_sample(int x, int y, int which) const;
50 };
52 class GridCell {
53 private:
54 // each grid-cell might contain multiple tiles.
55 std::vector<Tile*> tiles;
57 // particle systems
58 std::vector<struct psys_emitter*> psys;
60 public:
61 GridCell(Tile *tile = 0);
63 void add_tile(Tile *tile);
65 void update(unsigned long msec, float dt);
67 void draw(unsigned int draw_mask) const;
68 void draw_lights(unsigned int draw_mask) const;
69 void draw_post(unsigned int draw_mask) const;
71 AudioSample *get_sample(int which) const;
73 std::list<Tile::AudioSourceDesc> get_audio_sources() const;
74 };
76 #endif // LEVEL_H_