Addded property to Worldmap Spawnpoint to let Tux automatically start walking (or...
[supertux.git] / src / badguy / mriceblock.cpp
index 8b3a995..7b954bf 100644 (file)
@@ -31,7 +31,7 @@ MrIceBlock::MrIceBlock(const lisp::Lisp& reader)
   : WalkingBadguy(reader, "images/creatures/mr_iceblock/mr_iceblock.sprite", "left", "right"), ice_state(ICESTATE_NORMAL), squishcount(0)
 {
   walk_speed = 80;
-  max_drop_height = 600; 
+  max_drop_height = 600;
   sound_manager->preload("sounds/iceblock_bump.wav");
   sound_manager->preload("sounds/stomp.wav");
   sound_manager->preload("sounds/kick.wav");
@@ -40,8 +40,8 @@ MrIceBlock::MrIceBlock(const lisp::Lisp& reader)
 MrIceBlock::MrIceBlock(const Vector& pos, Direction d)
   : WalkingBadguy(pos, d, "images/creatures/mr_iceblock/mr_iceblock.sprite", "left", "right"), ice_state(ICESTATE_NORMAL), squishcount(0)
 {
-  walk_speed = 80; 
-  max_drop_height = 600; 
+  walk_speed = 80;
+  max_drop_height = 600;
   sound_manager->preload("sounds/iceblock_bump.wav");
   sound_manager->preload("sounds/stomp.wav");
   sound_manager->preload("sounds/kick.wav");
@@ -81,6 +81,11 @@ MrIceBlock::active_update(float elapsed_time)
   BadGuy::active_update(elapsed_time);
 }
 
+bool
+MrIceBlock::can_break(){
+    return ice_state == ICESTATE_KICKED;
+}
+
 void
 MrIceBlock::collision_solid(const CollisionHit& hit)
 {
@@ -97,17 +102,6 @@ MrIceBlock::collision_solid(const CollisionHit& hit)
       WalkingBadguy::collision_solid(hit);
       break;
     case ICESTATE_KICKED: {
-#if 0
-      // TODO move these into bonusblock class
-      BonusBlock* bonusblock = dynamic_cast<BonusBlock*> (&object);
-      if(bonusblock) {
-        bonusblock->try_open();
-      }
-      Brick* brick = dynamic_cast<Brick*> (&object);
-      if(brick) {
-        brick->try_break();
-      }
-#endif
       if(hit.right && dir == RIGHT) {
         dir = LEFT;
         sound_manager->play("sounds/iceblock_bump.wav", get_pos());
@@ -157,7 +151,7 @@ MrIceBlock::collision_player(Player& player, const CollisionHit& hit)
       return FORCE_MOVE;
     }
   }
-  
+
   return BadGuy::collision_player(player, hit);
 }
 
@@ -215,11 +209,6 @@ MrIceBlock::set_state(IceState state)
 {
   if(ice_state == state)
     return;
-  
-  if(state == ICESTATE_FLAT)
-    flags |= FLAG_PORTABLE;
-  else
-    flags &= ~FLAG_PORTABLE;
 
   switch(state) {
     case ICESTATE_NORMAL:
@@ -228,8 +217,8 @@ MrIceBlock::set_state(IceState state)
     case ICESTATE_FLAT:
       sound_manager->play("sounds/stomp.wav", get_pos());
       physic.set_velocity_x(0);
-      physic.set_velocity_y(0); 
-      
+      physic.set_velocity_y(0);
+
       sprite->set_action(dir == LEFT ? "flat-left" : "flat-right");
       flat_timer.start(4);
       break;
@@ -268,4 +257,10 @@ MrIceBlock::ungrab(MovingObject& , Direction dir)
   set_group(COLGROUP_MOVING);
 }
 
+bool
+MrIceBlock::is_portable() const
+{
+  return ice_state == ICESTATE_FLAT;
+}
+
 IMPLEMENT_FACTORY(MrIceBlock, "mriceblock")