4 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * Ambient Sound Source, gamma version. Features:
24 * - "rounded rectancle" geometry with position, dimension and
25 * "rounding radius" (extending in all directions) of a 100%
26 * volume area, adjustable maximum volume, inverse square
27 * falloff outside area.
29 * - degenerates gracefully to a disc for dimension=0
34 * width, height dimension
35 * distance_factor high = steep fallofff
36 * distance_bias high = big "100% disc"
37 * silence_distance defaults reasonably.
38 * sample sample to be played back in loop mode
43 #ifndef __AMBIENT_SOUND_H__
44 #define __AMBIENT_SOUND_H__
46 #include "game_object.hpp"
47 #include "resources.hpp"
49 #include "script_interface.hpp"
50 #include "scripting/ambient_sound.hpp"
54 class AmbientSound : public GameObject, public ScriptInterface, public Scripting::AmbientSound
57 AmbientSound(const lisp::Lisp& lisp);
58 AmbientSound(Vector pos, float factor, float bias, float vol, std::string file);
61 void set_pos(Vector newpos)
65 const Vector get_pos() const
70 // --- Scripting Interface ---
72 void set_pos(float x, float y);
73 float get_pos_x() const;
74 float get_pos_y() const;
77 virtual void hit(Player& player);
78 virtual void update(float time);
79 virtual void draw(DrawingContext&);
80 virtual void start_playing();
81 virtual void stop_playing();
82 virtual void expose(HSQUIRRELVM vm, SQInteger table_idx);
83 virtual void unexpose(HSQUIRRELVM vm, SQInteger table_idx);
85 std::string name; /**< user-defined name for use in scripts or empty string if not scriptable */
90 SoundSource* sound_source;
93 float distance_factor; /// distance scaling
94 float distance_bias; /// 100% volume disc radius
95 float silence_distance; /// not implemented yet
97 float maximumvolume; /// maximum volume
98 float targetvolume; /// how loud we want to be
99 float currentvolume; /// how loud we are
101 float * volume_ptr; /// this will be used by the volume adjustment effect.