This site requires JavaScript, please enable it in your browser!
Greenfoot back
Duta
Duta wrote ...

2012/3/18

Drifting

Duta Duta

2012/3/18

#
This is for tallyaka about http://www.greenfoot.org/scenarios/4291 Instead of a movement method along the lines of:
public void act()
{
    if(Greenfoot.isKeyDown("up")) move(3);
}
you need something more like:
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));
}
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)
tallyaka tallyaka

2012/3/18

#
Ok thanks! I'm really rushing this as it's 11:34 PM and it's due tomorrow :P
Duta Duta

2012/3/18

#
You don't have to use it, its just a suggestion so that your thing is better! It shouldn't take long to implement anyway hopefully.
You need to login to post a reply.