From 8385faa306eca6d96ab11ed7dae293d85e9c4e4f Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Thu, 25 Nov 2004 18:57:26 +0000 Subject: [PATCH] shrink tux bounding box to make him not fail on 1 or 2 tiles heigh places, also extend/shrink his bounding box when walking/running SVN-Revision: 2197 --- src/player.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/player.cpp b/src/player.cpp index 3f5bb9338..5e3c3efed 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -131,7 +131,7 @@ Player::init() { holding_something = false; - bbox.set_size(32, 32); + bbox.set_size(31.8, 31.8); size = SMALL; got_power = NONE_POWER; @@ -388,6 +388,14 @@ Player::handle_horizontal_input() } #endif + // extend/shrink tux collision rectangle so that we fall through/walk over 1 + // tile holes + if(vx > MAX_WALK_XM) { + bbox.set_width(33); + } else { + bbox.set_width(31.8); + } + physic.set_velocity(vx, vy); physic.set_acceleration(ax, ay); } @@ -660,13 +668,13 @@ Player::handle_input() { duck = true; bbox.move(Vector(0, 32)); - bbox.set_height(32); + bbox.set_height(31.8); } else if(input.down == UP && size == BIG && duck) { // try if we can really unduck bbox.move(Vector(0, -32)); - bbox.set_height(64); + bbox.set_height(63.8); duck = false; // FIXME #if 0 @@ -676,7 +684,7 @@ Player::handle_input() } else { // undo the ducking changes bbox.move(Vector(0, 32)); - bbox.set_height(32); + bbox.set_height(31.8); } #endif } @@ -689,7 +697,7 @@ Player::grow(bool animate) return; size = BIG; - bbox.set_height(64); + bbox.set_height(63.8); bbox.move(Vector(0, -32)); if(animate) @@ -916,7 +924,7 @@ Player::kill(HurtMode mode) growing_timer.start(GROWING_TIME); safe_timer.start(TUX_SAFE_TIME + GROWING_TIME); size = SMALL; - bbox.set_height(32); + bbox.set_height(31.8); duck = false; } } @@ -938,7 +946,7 @@ Player::remove_powerups() { got_power = NONE_POWER; size = SMALL; - bbox.set_height(32); + bbox.set_height(31.8); } void -- 2.11.0