2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 * Ambient Sound Source, gamma version. Features:
20 * - "rounded rectangle" geometry with position, dimension and
21 * "rounding radius" (extending in all directions) of a 100%
22 * volume area, adjustable maximum volume, inverse square
23 * falloff outside area.
25 * - degenerates gracefully to a disc for dimension=0
30 * width, height dimension
31 * distance_factor high = steep falloff
32 * distance_bias high = big "100% disc"
33 * silence_distance defaults reasonably.
34 * sample sample to be played back in loop mode
39 #ifndef HEADER_SUPERTUX_OBJECT_AMBIENT_SOUND_HPP
40 #define HEADER_SUPERTUX_OBJECT_AMBIENT_SOUND_HPP
42 #include "scripting/ambient_sound.hpp"
43 #include "supertux/game_object.hpp"
44 #include "supertux/script_interface.hpp"
45 #include "util/reader_fwd.hpp"
50 class AmbientSound : public GameObject,
51 public ScriptInterface,
52 public scripting::AmbientSound
55 AmbientSound(const Reader& lisp);
56 AmbientSound(Vector pos, float factor, float bias, float vol, std::string file);
59 void set_pos(Vector newpos)
63 const Vector get_pos() const
69 * @name Scriptable Methods
72 void set_pos(float x, float y);
73 float get_pos_x() const;
74 float get_pos_y() const;
80 virtual void hit(Player& player);
81 virtual void update(float time);
82 virtual void draw(DrawingContext&);
83 virtual void start_playing();
84 virtual void stop_playing();
85 virtual void expose(HSQUIRRELVM vm, SQInteger table_idx);
86 virtual void unexpose(HSQUIRRELVM vm, SQInteger table_idx);
89 std::string name; /**< user-defined name for use in scripts or empty string if not scriptable */
94 SoundSource* sound_source;
97 float distance_factor; /// distance scaling
98 float distance_bias; /// 100% volume disc radius
99 float silence_distance; /// not implemented yet
101 float maximumvolume; /// maximum volume
102 float targetvolume; /// how loud we want to be
103 float currentvolume; /// how loud we are
105 float * volume_ptr; /// this will be used by the volume adjustment effect.
108 AmbientSound(const AmbientSound&);
109 AmbientSound& operator=(const AmbientSound&);