dungeon_crawler

annotate prototype/src/level.h @ 53:1ea56011c1ff

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