f6fd285088dc554735106bd6072f099a67de17d6
[supertux.git] / src / object / ambient_sound.h
1 // ambient_sound.h   basti_
2 // 
3 //  SuperTux
4 //
5 //  This program is free software; you can redistribute it and/or
6 //  modify it under the terms of the GNU General Public License
7 //  as published by the Free Software Foundation; either version 2
8 //  of the License, or (at your option) any later version.
9 //
10 //  This program is distributed in the hope that it will be useful,
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //  GNU General Public License for more details.
14 // 
15 //  You should have received a copy of the GNU General Public License
16 //  along with this program; if not, write to the Free Software
17 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 //  02111-1307, USA.
19
20 /**
21  *  Ambient Sound Source, beta version. Features:
22  *
23  *  - "disc" like structure. Full volume up to some distance
24  *    (distance_bias) to the source, then fading proportional to
25  *    inverse square distance
26  *  
27  *  This is experimental and clicks a little. It is not possible to
28  *  get the clicks out without sample-granular volume adjustment.
29  *
30  *      basti_ 
31  */
32
33 #ifndef __AMBIENT_SOUND_H__
34 #define __AMBIENT_SOUND_H__
35
36
37 #include "game_object.h"
38 #include "resources.h"
39 #include "player.h"
40 #include "SDL_mixer.h"
41
42 class AmbientSound : public GameObject
43 {
44 public:
45   AmbientSound(const lisp::Lisp& lisp);
46
47 protected:
48   virtual void hit(Player& player);
49   virtual void action(float time);
50   virtual void draw(DrawingContext&);
51   virtual void startPlaying();
52 private:
53   Vector position;
54
55   std::string sample;
56   int playing;
57
58   float distance_factor;  /// distance scaling
59   float distance_bias;    /// 100% volume disc radius
60   float silence_distance; /// not implemented yet 
61
62   float targetvolume;  /// how loud we want to be
63   float currentvolume; /// how loud we are
64
65   float * volume_ptr; /// this will be used by the volume adjustment effect.
66 };
67
68 #endif
69