Mr Bomb turns arround again when colliding with other badguys.
[supertux.git] / src / badguy / flame.cpp
index 7e98cb4..9acd1c6 100644 (file)
@@ -1,7 +1,7 @@
 //  $Id$
-// 
+//
 //  SuperTux
-//  Copyright (C) 2005 Matthias Braun <matze@braunis.de>
+//  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
 //
 //  This program is free software; you can redistribute it and/or
 //  modify it under the terms of the GNU General Public License
 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 //  GNU General Public License for more details.
-// 
+//
 //  You should have received a copy of the GNU General Public License
 //  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-//  02111-1307, USA.
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include <config.h>
 
-#include "flame.h"
+#include "flame.hpp"
+#include "log.hpp"
+
+static const std::string SOUNDFILE = "sounds/flame.wav";
 
 Flame::Flame(const lisp::Lisp& reader)
-  : angle(0), radius(100), speed(2)
+  : BadGuy(reader, "images/creatures/flame/flame.sprite", LAYER_FLOATINGOBJECTS), angle(0), radius(100), speed(2)
 {
-  reader.get("x", start_position.x);
-  reader.get("y", start_position.y);
   reader.get("radius", radius);
   reader.get("speed", speed);
   bbox.set_pos(Vector(start_position.x + cos(angle) * radius,
                       start_position.y + sin(angle) * radius));
-  bbox.set_size(32, 32);  
-  sprite = sprite_manager->create("flame");
+  countMe = false;
+  sound_manager->preload(SOUNDFILE);
 }
 
 void
@@ -55,6 +55,27 @@ Flame::active_update(float elapsed_time)
   Vector newpos(start_position.x + cos(angle) * radius,
                 start_position.y + sin(angle) * radius);
   movement = newpos - get_pos();
+
+  sound_source->set_position(get_pos());
+}
+
+void
+Flame::activate()
+{
+  set_group(COLGROUP_TOUCHABLE);
+
+  sound_source.reset(sound_manager->create_sound_source(SOUNDFILE));
+  sound_source->set_position(get_pos());
+  sound_source->set_looping(true);
+  sound_source->set_gain(2.0);
+  sound_source->set_reference_distance(32);
+  sound_source->play();
+}
+
+void
+Flame::deactivate()
+{
+  sound_source.reset();
 }
 
 void