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/>.
17 #include "badguy/flame.hpp"
21 #include "audio/sound_manager.hpp"
22 #include "supertux/object_factory.hpp"
23 #include "util/reader.hpp"
25 static const std::string SOUNDFILE = "sounds/flame.wav";
27 Flame::Flame(const Reader& reader) :
28 BadGuy(reader, "images/creatures/flame/flame.sprite", LAYER_FLOATINGOBJECTS),
34 reader.get("radius", radius);
35 reader.get("speed", speed);
36 bbox.set_pos(Vector(start_position.x + cos(angle) * radius,
37 start_position.y + sin(angle) * radius));
39 sound_manager->preload(SOUNDFILE);
41 set_colgroup_active(COLGROUP_TOUCHABLE);
45 Flame::active_update(float elapsed_time)
47 angle = fmodf(angle + elapsed_time * speed, (float) (2*M_PI));
48 Vector newpos(start_position.x + cos(angle) * radius,
49 start_position.y + sin(angle) * radius);
50 movement = newpos - get_pos();
52 sound_source->set_position(get_pos());
58 sound_source.reset(sound_manager->create_sound_source(SOUNDFILE));
59 sound_source->set_position(get_pos());
60 sound_source->set_looping(true);
61 sound_source->set_gain(2.0);
62 sound_source->set_reference_distance(32);
77 IMPLEMENT_FACTORY(Flame, "flame");