From: Ricardo Cruz Date: Fri, 16 Apr 2004 16:24:54 +0000 (+0000) Subject: This patch was send to the mailing list by Ryan (aka sik0fewl). X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=70dfc81498ab488051d4aec8739e3a1998f35829;hp=391beb6068732770d58c4d5876926ddf9ec11355;p=supertux.git This patch was send to the mailing list by Ryan (aka sik0fewl). � I've made it so that sliding on ice works again (after the changes to the input handling functions--looks much nicer now, btw). I also changed supertux.stgt to make snow5.png ice. You can try out sliding around on ice in the second level. I wasn't really sure what would be a good sliding rate so people should try fiddling with different values. Right now the accel/decel rate is the direct inverse of the velocity.. this inverse can be increased or decreased. Also, the smalltux animation doesn't "slide", he walks to a stop.. haven't really looked into where to fix this, but I'm sure others could find it and fix it before I could. � SVN-Revision: 532 --- diff --git a/data/images/tilesets/supertux.stgt b/data/images/tilesets/supertux.stgt index 19304ad22..ad64872b0 100644 --- a/data/images/tilesets/supertux.stgt +++ b/data/images/tilesets/supertux.stgt @@ -30,7 +30,8 @@ (solid #t)) (tile (id 11) (images "snow5.png") - (solid #t)) + (solid #t) + (ice #t)) (tile (id 12) (images "snow6.png") (solid #t)) diff --git a/src/player.cpp b/src/player.cpp index ddb81044a..0cf24388c 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -379,7 +379,20 @@ Player::handle_horizontal_input() ax = WALK_ACCELERATION_X * -1.5; } } - + + // if we're on ice slow down acceleration or deceleration + if (isice(base.x, base.y + base.height)) + { + /* the acceleration/deceleration rate on ice is inversely proportional to + * the current velocity. + */ + + // increasing 1 will increase acceleration/deceleration rate + // decreasing 1 will decrease acceleration/deceleration rate + // must stay above zero, though + if (ax != 0) ax *= 1 / fabs(vx); + } + physic.set_velocity(vx, vy); physic.set_acceleration(ax, ay); }