Tweaked the backflip timer so that Tux cannot cancel backflip after an arbitrarily...
authorLMH <lmh.0013@gmail.com>
Mon, 2 Sep 2013 08:10:35 +0000 (22:10 -1000)
committerLMH <lmh.0013@gmail.com>
Mon, 2 Sep 2013 08:10:35 +0000 (22:10 -1000)
src/object/player.cpp
src/object/player.hpp

index 61b6bc1..0fc1053 100644 (file)
@@ -384,7 +384,7 @@ Player::update(float elapsed_time)
   // check if we landed
   if(on_ground()) {
     jumping = false;
-    if (backflipping && (!backflip_timer.started())) {
+    if (backflipping && (backflip_timer.get_timegone() > 0.15f)) {
       backflipping = false;
       backflip_direction = 0;
 
@@ -636,7 +636,7 @@ Player::do_backflip() {
   backflipping = true;
   do_jump(-580);
   sound_manager->play("sounds/flip.wav");
-  backflip_timer.start(0.15f);
+  backflip_timer.start(TUX_BACKFLIP_TIME);
 }
 
 void
@@ -831,7 +831,7 @@ Player::handle_input()
   }
 
   /* stop backflipping at will */
-  if( backflipping && ( !controller->hold(Controller::JUMP) ) ){
+  if( backflipping && ( !controller->hold(Controller::JUMP) && !backflip_timer.started()) ){
     backflipping = false;
     backflip_direction = 0;
   }
index b54a294..2e702d5 100644 (file)
@@ -40,6 +40,7 @@ static const float TUX_INVINCIBLE_TIME = 14.0f;
 static const float TUX_INVINCIBLE_TIME_WARNING = 2.0f;
 static const float GROWING_TIME = 0.35f;
 static const int GROWING_FRAMES = 7;
+static const float TUX_BACKFLIP_TIME = 2.1f; // minimum air time that backflip results in a loss of control
 
 class Camera;
 class PlayerStatus;