-optimized and cleaned up collision_object_map
[supertux.git] / src / player.cpp
index ec3e899..afc4eb5 100644 (file)
@@ -92,6 +92,7 @@ Player::init()
   skidding_timer.init(true);
   safe_timer.init(true);
   frame_timer.init(true);
+  kick_timer.init(true);
 
   physic.reset();
 }
@@ -264,6 +265,7 @@ Player::action(double frame_ratio)
   skidding_timer.check();
   invincible_timer.check();
   safe_timer.check();
+  kick_timer.check();
 }
 
 bool
@@ -369,7 +371,7 @@ Player::handle_horizontal_input()
 void
 Player::handle_vertical_input()
 {
-  if(input.up == DOWN)
+  if(input.up == DOWN && input.old_up == UP)
     {
       if (on_ground())
         {
@@ -408,6 +410,7 @@ Player::handle_input()
     {
       handle_vertical_input();
     }
+  input.old_up = input.up;
 
   /* Shoot! */
 
@@ -453,11 +456,25 @@ Player::handle_input()
       duck = false;
       base.y -= 32;
       base.height = 64;
-      old_base = previous_base = base;
+      // changing base size confuses collision otherwise
+      old_base = previous_base = base;                        
     }
 }
 
 void
+Player::grow()
+{
+  if(size == BIG)
+    return;
+  
+  size = BIG;
+  base.height = 64;
+  base.y -= 32;
+
+  old_base = previous_base = base;
+}
+
+void
 Player::grabdistros()
 {
   /* Grab distros: */
@@ -508,13 +525,13 @@ Player::draw()
           else
             sprite = &largetux;
           
-          if (duck)
+          if (duck && size != SMALL)
             {
               if (dir == RIGHT)
                 sprite->duck_right->draw(base.x - scroll_x, base.y);
               else 
                 sprite->duck_left->draw(base.x - scroll_x, base.y);
-            }                    
+            }
           else if (skidding_timer.started())
             {
               if (dir == RIGHT)
@@ -522,6 +539,13 @@ Player::draw()
               else
                 sprite->skid_left->draw(base.x - scroll_x, base.y); 
             }
+          else if (kick_timer.started())
+            {
+              if (dir == RIGHT)
+                sprite->kick_right->draw(base.x - scroll_x, base.y);
+              else
+                sprite->kick_left->draw(base.x - scroll_x, base.y); 
+            }
           else if (physic.get_velocity_y() != 0)
             {
               if (dir == RIGHT)
@@ -587,7 +611,8 @@ Player::collision(void* p_c_object, int c_object)
           !safe_timer.started() &&
           pbad_c->mode != BadGuy::HELD)
         {
-          if (pbad_c->mode == BadGuy::FLAT && input.fire == DOWN)
+          if (pbad_c->mode == BadGuy::FLAT && input.fire == DOWN
+               && !holding_something)
             {
               holding_something = true;
               pbad_c->mode = BadGuy::HELD;
@@ -621,7 +646,7 @@ Player::collision(void* p_c_object, int c_object)
                 }
               else
                 {
-                  pbad_c->kill_me();
+                  pbad_c->kill_me(25);
                 }
             }
           player_status.score_multiplier++;