Show a message when more than one bad guys is killed in a row.
[supertux.git] / src / player.cpp
index 533e761..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)
@@ -628,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);
+          }
       }
     }
   }