Fix music not properly fading in again
[supertux.git] / src / badguy / darttrap.cpp
index 3e66642..1fb822e 100644 (file)
@@ -21,6 +21,7 @@
 #include "sprite/sprite.hpp"
 #include "supertux/object_factory.hpp"
 #include "supertux/sector.hpp"
+#include "util/reader.hpp"
 
 namespace {
 const float MUZZLE_Y = 25; /**< [px] muzzle y-offset from top */
@@ -28,9 +29,9 @@ const float MUZZLE_Y = 25; /**< [px] muzzle y-offset from top */
 
 DartTrap::DartTrap(const Reader& reader) :
   BadGuy(reader, "images/creatures/darttrap/darttrap.sprite", LAYER_TILES-1),
-  initial_delay(0), 
-  fire_delay(2), 
-  ammo(-1), 
+  initial_delay(0),
+  fire_delay(2),
+  ammo(-1),
   state(IDLE),
   fire_timer()
 {
@@ -38,8 +39,8 @@ DartTrap::DartTrap(const Reader& reader) :
   reader.get("fire-delay", fire_delay);
   reader.get("ammo", ammo);
   countMe = false;
-  sound_manager->preload("sounds/dartfire.wav");
-  if (start_dir == AUTO) log_warning << "Setting a DartTrap's direction to AUTO is no good idea" << std::endl;
+  SoundManager::current()->preload("sounds/dartfire.wav");
+  if (start_dir == AUTO) { log_warning << "Setting a DartTrap's direction to AUTO is no good idea" << std::endl; }
   state = IDLE;
   set_colgroup_active(COLGROUP_DISABLED);
   if (initial_delay == 0) initial_delay = 0.1f;
@@ -95,12 +96,10 @@ DartTrap::fire()
   float py = get_pos().y;
   py += MUZZLE_Y;
 
-  sound_manager->play("sounds/dartfire.wav", get_pos());
-  Sector::current()->add_object(new Dart(Vector(px, py), dir, this));
+  SoundManager::current()->play("sounds/dartfire.wav", get_pos());
+  Sector::current()->add_object(std::make_shared<Dart>(Vector(px, py), dir, this));
   state = IDLE;
   sprite->set_action(dir == LEFT ? "idle-left" : "idle-right");
 }
 
-IMPLEMENT_FACTORY(DartTrap, "darttrap");
-
 /* EOF */