Getting rid of nasty tabs
[supertux.git] / src / badguy / darttrap.cpp
index 06381fe..b2e7f55 100644 (file)
@@ -1,7 +1,7 @@
 //  $Id$
 //
 //  DartTrap - Shoots a Dart at regular intervals
-//  Copyright (C) 2006 Christoph Sommer <supertux@2006.expires.deltadevelopment.de>
+//  Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
 //
 //  This program is free software; you can redistribute it and/or
 //  modify it under the terms of the GNU General Public License
 #include "dart.hpp"
 
 namespace {
-  const float MUZZLE_Y = 28; /**< [px] muzzle y-offset from top */
+  const float MUZZLE_Y = 25; /**< [px] muzzle y-offset from top */
 }
 
-DartTrap::DartTrap(const lisp::Lisp& reader) 
-       : BadGuy(reader, "images/creatures/darttrap/darttrap.sprite"), set_direction(true), initial_direction(LEFT), initial_delay(0), fire_delay(2), ammo(-1), state(IDLE)
+DartTrap::DartTrap(const lisp::Lisp& reader)
+  : BadGuy(reader, "images/creatures/darttrap/darttrap.sprite", LAYER_TILES-1), initial_delay(0), fire_delay(2), ammo(-1), state(IDLE)
 {
   reader.get("initial-delay", initial_delay);
   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;
+  state = IDLE;
+  set_colgroup_active(COLGROUP_DISABLED);
+  if (initial_delay == 0) initial_delay = 0.1f;
 }
 
 void
@@ -48,17 +53,18 @@ DartTrap::write(lisp::Writer& writer)
 }
 
 void
-DartTrap::activate()
+DartTrap::initialize()
 {
-  if (set_direction) dir = initial_direction;
-  state = IDLE;
   sprite->set_action(dir == LEFT ? "idle-left" : "idle-right");
+}
 
-  if (initial_delay == 0) initial_delay = 0.1;
+void
+DartTrap::activate()
+{
   fire_timer.start(initial_delay);
 }
 
-HitResponse 
+HitResponse
 DartTrap::collision_player(Player& , const CollisionHit& )
 {
   return ABORT_MOVE;
@@ -96,11 +102,10 @@ DartTrap::fire()
   float py = get_pos().y;
   py += MUZZLE_Y;
 
-  sound_manager->play("sounds/squish.wav", get_pos());
+  sound_manager->play("sounds/dartfire.wav", get_pos());
   Sector::current()->add_object(new Dart(Vector(px, py), dir, this));
   state = IDLE;
   sprite->set_action(dir == LEFT ? "idle-left" : "idle-right");
 }
 
 IMPLEMENT_FACTORY(DartTrap, "darttrap")
-