updated squirrel version
[supertux.git] / src / badguy / mriceblock.cpp
index 9c5ad78..0dcd96e 100644 (file)
@@ -1,3 +1,23 @@
+//  $Id$
+// 
+//  SuperTux
+//  Copyright (C) 2005 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
+//  as published by the Free Software Foundation; either version 2
+//  of the License, or (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  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.
+
 #include <config.h>
 
 #include "mriceblock.h"
@@ -33,8 +53,8 @@ MrIceBlock::write(lisp::Writer& writer)
 {
   writer.start_list("mriceblock");
 
-  writer.write_float("x", get_pos().x);
-  writer.write_float("y", get_pos().y);
+  writer.write_float("x", start_position.x);
+  writer.write_float("y", start_position.y);
 
   writer.end_list("mriceblock");
 }
@@ -48,15 +68,14 @@ MrIceBlock::activate()
 }
 
 void
-MrIceBlock::active_action(float elapsed_time)
+MrIceBlock::active_update(float elapsed_time)
 {
   if(ice_state == ICESTATE_FLAT && flat_timer.check()) {
-    printf("unflat.\n");
     ice_state = ICESTATE_NORMAL;
     physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
     sprite->set_action(dir == LEFT ? "left" : "right");
   }
-  BadGuy::active_action(elapsed_time);
+  BadGuy::active_update(elapsed_time);
 }
 
 HitResponse
@@ -86,8 +105,7 @@ MrIceBlock::collision_solid(GameObject& object, const CollisionHit& hit)
       dir = dir == LEFT ? RIGHT : LEFT;
       sprite->set_action(dir == LEFT ? "flat-left" : "flat-right");
       physic.set_velocity_x(-physic.get_velocity_x());
-      SoundManager::get()->play_sound(IDToSound(SND_RICOCHET), get_pos(),
-          Sector::current()->player->get_pos());
+      sound_manager->play("sounds/ricochet.wav", get_pos());
       break;
     }
     case ICESTATE_FLAT:
@@ -134,20 +152,17 @@ MrIceBlock::collision_squished(Player& player)
       }
 
       // flatten
-      SoundManager::get()->play_sound(IDToSound(SND_STOMP), get_pos(),
-          player.get_pos());
+      sound_manager->play("sounds/stomp.wav", get_pos());
       physic.set_velocity_x(0);
       physic.set_velocity_y(0); 
       
       sprite->set_action(dir == LEFT ? "flat-left" : "flat-right");
       flat_timer.start(4);
       ice_state = ICESTATE_FLAT;
-      printf("flat.\n");
       break;
     case ICESTATE_FLAT:
       // kick
-      SoundManager::get()->play_sound(IDToSound(SND_KICK), this,
-          player.get_pos());
+      sound_manager->play("sounds/kick.wav", get_pos());
 
       if(player.get_pos().x < get_pos().x) {
         dir = RIGHT;
@@ -157,7 +172,6 @@ MrIceBlock::collision_squished(Player& player)
       physic.set_velocity_x(dir == LEFT ? -KICKSPEED : KICKSPEED);
       sprite->set_action(dir == LEFT ? "flat-left" : "flat-right");
       ice_state = ICESTATE_KICKED;
-      printf("kicked.\n");
       break;
   }
 
@@ -165,3 +179,4 @@ MrIceBlock::collision_squished(Player& player)
   return true;
 }
 
+IMPLEMENT_FACTORY(MrIceBlock, "mriceblock")