Updated addon repository URL and improved debug output on download
[supertux.git] / src / trigger / climbable.cpp
index dd8d944..42b8f60 100644 (file)
@@ -26,7 +26,7 @@ namespace {
 const float GRACE_DX = 8; // how far off may the player's bounding-box be x-wise
 const float GRACE_DY = 8; // how far off may the player's bounding-box be y-wise
 const float ACTIVATE_TRY_FOR = 1; // how long to try correcting mis-alignment of player and climbable before giving up
-const float POSITION_FIX_AX = 50; // x-wise acceleration applied to player when trying to align player and Climbable
+const float POSITION_FIX_AX = 30; // x-wise acceleration applied to player when trying to align player and Climbable
 const float POSITION_FIX_AY = 50; // y-wise acceleration applied to player when trying to align player and Climbable
 }
 
@@ -42,7 +42,7 @@ Climbable::Climbable(const Reader& reader) :
   bbox.set_size(w, h);
 }
 
-Climbable::Climbable(const Rect& area) :
+Climbable::Climbable(const Rectf& area) :
   climbed_by(0),
   activate_try_timer()
 {
@@ -57,7 +57,7 @@ Climbable::~Climbable()
   }
 }
 
-void 
+void
 Climbable::update(float /*elapsed_time*/)
 {
   if (!climbed_by) return;
@@ -75,7 +75,7 @@ Climbable::draw(DrawingContext& context)
     context.push_transform();
     context.set_translation(Vector(0, 0));
     Vector pos = Vector(0, SCREEN_HEIGHT/2 - Resources::normal_font->get_height()/2);
-    context.draw_center_text(Resources::normal_font, _("Up we go..."), pos, LAYER_GUI, Climbable::text_color);
+    context.draw_center_text(Resources::normal_font, _("Up we go..."), pos, LAYER_HUD, Climbable::text_color);
     context.pop_transform();
   }
 }
@@ -91,8 +91,9 @@ Climbable::event(Player& player, EventType type)
         activate_try_timer.stop();
       } else {
         if (type == EVENT_ACTIVATE) activate_try_timer.start(ACTIVATE_TRY_FOR);
-        if (player.get_bbox().p1.x < get_bbox().p1.x - GRACE_DX) player.add_velocity(Vector(POSITION_FIX_AX,0));
-        if (player.get_bbox().p2.x > get_bbox().p2.x + GRACE_DX) player.add_velocity(Vector(-POSITION_FIX_AX,0));
+        // the "-13" to y velocity prevents Tux from walking in place on the ground for horizonal adjustments
+        if (player.get_bbox().p1.x < get_bbox().p1.x - GRACE_DX) player.add_velocity(Vector(POSITION_FIX_AX,-13));
+        if (player.get_bbox().p2.x > get_bbox().p2.x + GRACE_DX) player.add_velocity(Vector(-POSITION_FIX_AX,-13));
         if (player.get_bbox().p1.y < get_bbox().p1.y - GRACE_DY) player.add_velocity(Vector(0,POSITION_FIX_AY));
         if (player.get_bbox().p2.y > get_bbox().p2.y + GRACE_DY) player.add_velocity(Vector(0,-POSITION_FIX_AY));
       }
@@ -105,7 +106,7 @@ Climbable::event(Player& player, EventType type)
 }
 
 bool
-Climbable::may_climb(Player& player) 
+Climbable::may_climb(Player& player)
 {
   if (player.get_bbox().p1.x < get_bbox().p1.x - GRACE_DX) return false;
   if (player.get_bbox().p2.x > get_bbox().p2.x + GRACE_DX) return false;