dungeon_crawler

diff prototype/src/tile.cc @ 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 diff
     1.1 --- a/prototype/src/tile.cc	Mon Sep 17 08:40:59 2012 +0300
     1.2 +++ b/prototype/src/tile.cc	Tue Sep 18 00:34:29 2012 +0300
     1.3 @@ -9,6 +9,7 @@
     1.4  #include "tileset.h"
     1.5  #include "renderer.h"
     1.6  #include "datapath.h"
     1.7 +#include "cfg.h"
     1.8  
     1.9  using std::map;
    1.10  
    1.11 @@ -49,9 +50,18 @@
    1.12  	return 0;
    1.13  }
    1.14  
    1.15 -const struct psys_attributes * const *Tile::get_unique_psys() const
    1.16 +int Tile::get_audio_source_count() const
    1.17  {
    1.18 -	return &psattr[0];
    1.19 +	return (int)ausrc.size();
    1.20 +}
    1.21 +
    1.22 +const Tile::AudioSourceDesc &Tile::get_audio_source(int idx) const
    1.23 +{
    1.24 +	if(idx < 0 || idx >= (int)ausrc.size()) {
    1.25 +		static AudioSourceDesc d = { Vector3(), 0 };
    1.26 +		return d;
    1.27 +	}
    1.28 +	return ausrc[idx];
    1.29  }
    1.30  
    1.31  int Tile::get_unique_psys_count() const
    1.32 @@ -59,6 +69,22 @@
    1.33  	return (int)psattr.size();
    1.34  }
    1.35  
    1.36 +struct psys_attributes *Tile::get_unique_psys(int idx)
    1.37 +{
    1.38 +	if(idx < 0 || idx >= (int)psattr.size()) {
    1.39 +		return 0;
    1.40 +	}
    1.41 +	return psattr[idx];
    1.42 +}
    1.43 +
    1.44 +const struct psys_attributes *Tile::get_unique_psys(int idx) const
    1.45 +{
    1.46 +	if(idx < 0 || idx >= (int)psattr.size()) {
    1.47 +		return 0;
    1.48 +	}
    1.49 +	return psattr[idx];
    1.50 +}
    1.51 +
    1.52  bool Tile::load(const char *fname)
    1.53  {
    1.54  	if(!fname) {
    1.55 @@ -97,9 +123,11 @@
    1.56  	aiReleaseImport(scn);
    1.57  
    1.58  	// XXX get the default audio samples for now
    1.59 -	SampleSet *sampleset = tset->get_samples();
    1.60 -	samples[TILE_SAMPLE_WALK] = sampleset->get("walk_stone.ogg");
    1.61 -	samples[TILE_SAMPLE_RUN] = sampleset->get("run_stone.ogg");
    1.62 +	if(cfg.sound) {
    1.63 +		SampleSet *sampleset = tset->get_samples();
    1.64 +		samples[TILE_SAMPLE_WALK] = sampleset->get("walk_stone.ogg");
    1.65 +		samples[TILE_SAMPLE_RUN] = sampleset->get("run_stone.ogg");
    1.66 +	}
    1.67  	return true;
    1.68  }
    1.69  
    1.70 @@ -258,6 +286,16 @@
    1.71  				fprintf(stderr, "failed to create global particle system\n");
    1.72  			}
    1.73  
    1.74 +			// ... AND make an audio source out of each light source
    1.75 +			if(cfg.sound) {
    1.76 +				SampleSet *sampleset = tset->get_samples();
    1.77 +				AudioSample *sample = sampleset->get("fire.ogg");
    1.78 +				if(sample) {
    1.79 +					AudioSourceDesc adesc = {lt->get_position(), sample};
    1.80 +					ausrc.push_back(adesc);
    1.81 +				}
    1.82 +			}
    1.83 +
    1.84  		} else {
    1.85  			meshes.push_back(mesh);
    1.86  			mesh_side.push_back(side);