stop invincible music a bit earlier than invinciblility
authorMatthias Braun <matze@braunis.de>
Wed, 11 Jan 2006 13:03:15 +0000 (13:03 +0000)
committerMatthias Braun <matze@braunis.de>
Wed, 11 Jan 2006 13:03:15 +0000 (13:03 +0000)
SVN-Revision: 2981

src/game_session.cpp
src/object/player.cpp

index c1531de..12c0bd1 100644 (file)
@@ -579,7 +579,9 @@ GameSession::run()
     //frame_rate.update();
     
     /* Handle music: */
-    if (currentsector->player->invincible_timer.started() && !end_sequence)
+    if (currentsector->player->invincible_timer.started() && 
+            currentsector->player->invincible_timer.get_timeleft() 
+            > TUX_INVINCIBLE_TIME_WARNING && !end_sequence)
     {
       currentsector->play_music(HERRING_MUSIC);
     }
index 1a8feb6..157cff1 100644 (file)
@@ -42,6 +42,7 @@
 #include "trigger/trigger_base.hpp"
 #include "control/joystickkeyboardcontroller.hpp"
 #include "main.hpp"
+#include "badguy/badguy.hpp"
 #include "player_status.hpp"
 
 static const int TILES_FOR_BUTTJUMP = 3;
@@ -487,21 +488,20 @@ Player::handle_input()
     bbox.move(Vector(0, 32));
     bbox.set_height(31.8);
   } else if(!controller->hold(Controller::DOWN) && is_big() && duck) {
-    // try if we can really unduck
+    // if we have some velocity left then check if there is space for
+    // unducking
     bbox.move(Vector(0, -32));
     bbox.set_height(63.8);
-    duck = false;
-    // FIXME
-#if 0
-    // when unducking in air we need some space to do so
-    if(on_ground() || !collision_object_map(bbox)) {
+    if(Sector::current()->is_free_space(bbox) || (
+        physic.get_velocity_x() > -.01 && physic.get_velocity_x() < .01
+        && physic.get_velocity_y() > -.01 && physic.get_velocity_y() < .01))
+    {
       duck = false;
     } else {
       // undo the ducking changes
       bbox.move(Vector(0, 32));
-      bbox.set_height(31.8);
+      bbox.set_height(31.8); 
     }
-#endif
   }
 }
 
@@ -723,6 +723,11 @@ Player::collision(GameObject& other, const CollisionHit& hit)
     return FORCE_MOVE;
   }
 
+  BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
+  if(badguy != NULL)
+    return CONTINUE;
+
+#if 0
   MovingObject* moving_object = static_cast<MovingObject*> (&other);
   if(moving_object->get_group() == COLGROUP_TOUCHABLE)
     return FORCE_MOVE;
@@ -731,6 +736,8 @@ Player::collision(GameObject& other, const CollisionHit& hit)
     return FORCE_MOVE;
 
   return CONTINUE;
+#endif
+  return FORCE_MOVE;
 }
 
 void