X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fplayer.cpp;h=0cf24388cea69d0f98c855d62a0de8aa72df460e;hb=70dfc81498ab488051d4aec8739e3a1998f35829;hp=ddb81044ae5a1dbfd1f4d9a502da49d62928fa89;hpb=391beb6068732770d58c4d5876926ddf9ec11355;p=supertux.git 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); }