Show a message when more than one bad guys is killed in a row.
[supertux.git] / src / player.cpp
index 8e42906..75f622c 100644 (file)
@@ -21,8 +21,8 @@
 #include <iostream>
 #include <cassert>
 
-#include "gameloop.h"
 #include "app/globals.h"
+#include "app/gettext.h"
 #include "player.h"
 #include "defines.h"
 #include "scene.h"
@@ -36,6 +36,7 @@
 #include "interactive_object.h"
 #include "video/screen.h"
 #include "statistics.h"
+#include "gameloop.h"
 
 // behavior definitions:
 #define TILES_FOR_BUTTJUMP 3
@@ -334,7 +335,15 @@ Player::action(float elapsed_time)
           physic.enable_gravity(false);
           /* Reset score multiplier (for multi-hits): */
           if (!invincible_timer.started())
+            {
+            if(player_status.score_multiplier > 2)
+              {  // show a message
+              char str[124];
+              sprintf(str, _("%d bad guys in a row!"), player_status.score_multiplier-1);
+              Sector::current()->add_floating_text(base, str);
+              }
             player_status.score_multiplier = 1;
+            }
         }
 
       if(jumped_in_solid)
@@ -563,7 +572,10 @@ Player::handle_vertical_input()
    // Flapping
    if (input.up == DOWN && can_flap)
      {
-         if (!flapping_timer.started()) {flapping_timer.start(TUX_FLAPPING_TIME);}
+         if (!flapping_timer.started())
+            {
+               flapping_timer.start(TUX_FLAPPING_TIME);
+            }
          if (!flapping_timer.check()) 
             {
                can_flap = false;
@@ -625,12 +637,16 @@ Player::handle_vertical_input()
       BadGuy* badguy = dynamic_cast<BadGuy*> (*i);
       if(badguy)
       {
-        
-       if (fabsf(base.x - badguy->base.x) < 150 &&
-            fabsf(base.y - badguy->base.y) < 60 &&
-            (issolid(badguy->base.x + 1, badguy->base.y + badguy->base.height) ||
-              issolid(badguy->base.x + badguy->base.width - 1, badguy->base.y + badguy->base.height)))
-          badguy->kill_me(25);
+        // don't kill when badguys are already dying or in a certain mode
+        if(badguy->dying == DYING_NOT && badguy->mode != BadGuy::BOMB_TICKING &&
+           badguy->mode != BadGuy::BOMB_EXPLODE)
+          {
+            if (fabsf(base.x - badguy->base.x) < 150 &&
+              fabsf(base.y - badguy->base.y) < 60 &&
+              (issolid(badguy->base.x + 1, badguy->base.y + badguy->base.height) ||
+               issolid(badguy->base.x + badguy->base.width - 1, badguy->base.y + badguy->base.height)))
+              badguy->kill_me(25);
+          }
       }
     }
   }
@@ -651,6 +667,7 @@ Player::handle_vertical_input()
       jumping = false;
       flapping = false;
       falling_from_flap = false;
+      if (flapping_timer.started()) {flapping_timer.stop();}
     }
 
   input.old_up = input.up;
@@ -1149,6 +1166,10 @@ Player::check_bounds(Camera* camera)
 void
 Player::bounce(BadGuy* badguy)
 {
+  //Make sure we stopped flapping
+  flapping = false;
+  falling_from_flap = false;
+
   if (input.up)
     physic.set_velocity_y(5.2);
   else