Hi guys,
I am making a game where my speedboat object needs to 'slide' a bit after I've done a movement. It eventually needs to stop (offcourse). When I am moving now and stop pressing the keys, it just immediately stops, but I want it to slide a little after I stop pressing the buttons in the direction it was moving. Does anyone here has an idea of how I should do this or could someone send me a piece of code please? This is the movement code so far:
Thanks for the help already!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | public class SpeedBoat extends Actor { public void act() { if (Greenfoot.isKeyDown( "left" )) { turn(- 3 ); } if (Greenfoot.isKeyDown( "up" )) { move( 1 ); } if (Greenfoot.isKeyDown( "down" )) { move(- 1 ); } if (Greenfoot.isKeyDown( "right" )) { turn( 3 ); } } |