From 70dfc81498ab488051d4aec8739e3a1998f35829 Mon Sep 17 00:00:00 2001 From: Ricardo Cruz Date: Fri, 16 Apr 2004 16:24:54 +0000 Subject: [PATCH 1/1] =?utf8?q?This=20patch=20was=20send=20to=20the=20maili?= =?utf8?q?ng=20list=20by=20Ryan=20(aka=20sik0fewl).=20=EF=BF=BD=20I've=20m?= =?utf8?q?ade=20it=20so=20that=20sliding=20on=20ice=20works=20again=20(aft?= =?utf8?q?er=20the=20changes=20to=20the=20input=20handling=20functions--lo?= =?utf8?q?oks=20much=20nicer=20now,=20btw).?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- data/images/tilesets/supertux.stgt | 3 ++- src/player.cpp | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) 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); } -- 2.11.0