This is for tallyaka about http://www.greenfoot.org/scenarios/4291
Instead of a movement method along the lines of:
you need something more like:
This is very basic though so you'll want to fiddle with it to make it work best (especially with the +/-= 0.3's, I just made those values up)
public void act()
{
if(Greenfoot.isKeyDown("up")) move(3);
}double speed = 0;
static final double MAX_SPEED = 5;
public void act()
{
if(Greenfoot.isKeyDown("up")) speed += 0.3;
else speed -= 0.3;
if(speed < 0) speed = 0;
if(speed > MAX_SPEED) speed = MAX_SPEED;
move((int)Math.round(speed));
}
