- added butt-jump
[supertux.git] / src / player.cpp
index 3e8bde0..1288c66 100644 (file)
@@ -86,6 +86,7 @@ Player::init()
   dying   = DYING_NOT;
   jumping = false;
   can_jump = true;
+  butt_jump = false;
 
   frame_main = 0;
   frame_ = 0;
@@ -405,6 +406,22 @@ Player::handle_vertical_input()
       }
     }
 
+  if (input.down == DOWN && !on_ground() && !duck)
+    butt_jump = true;
+  else if (input.down == UP)
+    butt_jump = false;
+  if (input.down == DOWN && butt_jump && on_ground())
+  {
+    // FIXME: Currently only breaks the block if his middle is on top of it
+    if (isbrick(base.x + base.width/2, base.y + base.height))
+    {
+      World::current()->trybreakbrick(base.x + base.width/2, base.y + base.height, false);
+      bumpbrick(base.x, base.y);
+    }
+    butt_jump = false;
+  }
+
+
   if ( (issolid(base.x + base.width / 2, base.y + base.height + 64) ||
         issolid(base.x + 1, base.y + base.height + 64) ||
         issolid(base.x + base.width - 1, base.y + base.height + 64))