Fixed crashes at tiles that are not defined in supertux.stgt - throwing a warning...
[supertux.git] / src / player.cpp
index 9366cd5..ce98871 100644 (file)
@@ -39,6 +39,7 @@
 #define TILES_FOR_BUTTJUMP 3
 // animation times (in ms):
 #define SHOOTING_TIME 320
+#define STOMP_TIME 250
 // others stuff:
 #define AUTOSCROLL_DEAD_INTERVAL 300
 
@@ -115,7 +116,8 @@ Player::init()
   jumping = false;
   can_jump = true;
   butt_jump = false;
-
+  
+  stomp_pos = Vector(0,0);
   frame_main = 0;
   frame_ = 0;
 
@@ -287,7 +289,7 @@ Player::action(float elapsed_time)
           if (isbrick(base.x, base.y) ||
               isfullbox(base.x, base.y))
             {
-              Sector::current()->trygrabdistro(
+             Sector::current()->trygrabdistro(
                   Vector(base.x, base.y - 32), BOUNCE);
               Sector::current()->trybumpbadguy(Vector(base.x, base.y - 64));
 
@@ -301,7 +303,7 @@ Player::action(float elapsed_time)
           if (isbrick(base.x+ 31, base.y) ||
               isfullbox(base.x+ 31, base.y))
             {
-              Sector::current()->trygrabdistro(
+             Sector::current()->trygrabdistro(
                   Vector(base.x+ 31, base.y - 32), BOUNCE);
               Sector::current()->trybumpbadguy(Vector(base.x+ 31, base.y - 64));
 
@@ -507,6 +509,13 @@ Player::handle_vertical_input()
   // Do butt jump
   if (butt_jump && on_ground() && size == BIG)
   {
+    
+    if (duck) 
+      stomp_pos = Vector(base.x - 32, base.y);
+    else 
+      stomp_pos = Vector(base.x - 32, base.y + 32);    
+    stomp_timer.start(STOMP_TIME);
+    
     butt_jump = false;
 
     // Break bricks beneath Tux
@@ -649,7 +658,6 @@ Player::grabdistros()
     {
       Sector::current()->trygrabdistro(Vector(base.x, base.y), NO_BOUNCE);
       Sector::current()->trygrabdistro(Vector(base.x+ 31, base.y), NO_BOUNCE);
-
       Sector::current()->trygrabdistro(
           Vector(base.x, base.y + base.height), NO_BOUNCE);
       Sector::current()->trygrabdistro(
@@ -657,7 +665,7 @@ Player::grabdistros()
 
       if(size == BIG)
         {
-          Sector::current()->trygrabdistro(
+         Sector::current()->trygrabdistro(
               Vector(base.x, base.y + base.height / 2), NO_BOUNCE);
           Sector::current()->trygrabdistro(
               Vector(base.x+ 31, base.y + base.height / 2), NO_BOUNCE);
@@ -764,6 +772,10 @@ Player::draw(DrawingContext& context)
     else
       sprite->grab_left->draw(context, pos, LAYER_OBJECTS + 1);
   }
+  
+  // Draw stomp clouds when doing a butt jump
+  if (stomp_timer.check())
+      sprite->stomp->draw(context, stomp_pos, LAYER_OBJECTS + 1);
 
   // Draw blinking star overlay
   if (invincible_timer.started() &&