4 // Copyright (C) 2005 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
25 Flame::Flame(const lisp::Lisp& reader)
26 : angle(0), radius(100), speed(2)
28 reader.get("x", start_position.x);
29 reader.get("y", start_position.y);
30 reader.get("radius", radius);
31 reader.get("speed", speed);
32 bbox.set_pos(Vector(start_position.x + cos(angle) * radius,
33 start_position.y + sin(angle) * radius));
34 bbox.set_size(32, 32);
35 sprite = sprite_manager->create("flame");
39 Flame::write(lisp::Writer& writer)
41 writer.start_list("flame");
43 writer.write_float("x", start_position.x);
44 writer.write_float("y", start_position.y);
45 writer.write_float("radius", radius);
46 writer.write_float("speed", speed);
48 writer.end_list("flame");
52 Flame::active_action(float elapsed_time)
54 angle = fmodf(angle + elapsed_time * speed, 2*M_PI);
55 Vector newpos(start_position.x + cos(angle) * radius,
56 start_position.y + sin(angle) * radius);
57 movement = newpos - get_pos();
65 IMPLEMENT_FACTORY(Flame, "flame")