Patch by Matt McCutchen to prevent division by zero when Tux spawns exactly at a...
[supertux.git] / src / badguy / treewillowisp.cpp
index db417a6..a1a6343 100644 (file)
 #include <config.h>
 
 #include "treewillowisp.hpp"
+
 #include "ghosttree.hpp"
 #include "object/lantern.hpp"
+#include "audio/sound_source.hpp"
+#include "lisp/writer.hpp"
+#include "object_factory.hpp"
+#include "object/player.hpp"
+#include "audio/sound_manager.hpp"
+#include "sprite/sprite.hpp"
+
+#include <math.h>
 
 static const std::string SOUNDFILE = "sounds/willowisp.wav";
 static const float       SUCKSPEED = 25;
@@ -38,6 +47,8 @@ TreeWillOWisp::TreeWillOWisp(GhostTree* tree, const Vector& pos,
   this->angle  = 0;
   this->speed  = speed;
   start_position = tree->get_pos() + treepos_delta;
+
+  set_colgroup_active(COLGROUP_MOVING);
 }
 
 TreeWillOWisp::~TreeWillOWisp()
@@ -53,8 +64,6 @@ TreeWillOWisp::activate()
   sound_source->set_gain(2.0);
   sound_source->set_reference_distance(32);
   sound_source->play();
-
-  set_group(COLGROUP_MOVING);
 }
 
 void
@@ -62,7 +71,7 @@ TreeWillOWisp::vanish()
 {
   mystate = STATE_VANISHING;
   sprite->set_action("vanishing", 1);
-  set_group(COLGROUP_DISABLED);
+  set_colgroup_active(COLGROUP_DISABLED);
 }
 
 void
@@ -92,6 +101,19 @@ TreeWillOWisp::collides(GameObject& other, const CollisionHit& ) {
 }
 
 void
+TreeWillOWisp::draw(DrawingContext& context)
+{
+  sprite->draw(context, get_pos(), layer);
+
+  context.push_target();
+  context.set_target(DrawingContext::LIGHTMAP);
+
+  sprite->draw(context, get_pos(), layer);
+
+  context.pop_target();
+}
+
+void
 TreeWillOWisp::active_update(float elapsed_time)
 {
   // remove TreeWillOWisp if it has completely vanished