The object is jerking around when using the turn keys instead of a smooth movement.
I've tried moving around the two 4 and 6 keys (left and right) to else if and while statements inside and out of the main if statement.
move(4);
if(Greenfoot.isKeyDown("4"))
{
turn(-3);
}
if(Greenfoot.isKeyDown("6"))
{
turn(3);
}
if(Greenfoot.isKeyDown("8"))
{
move(4);
}
else if(Greenfoot.isKeyDown("5"))
{
move(2);
}
else if(Greenfoot.getRandomNumber(100) < 10)
{
turn(Greenfoot.getRandomNumber(90) - 45);
}
else if(getX() <= 5 || getX() >= getWorld().getWidth() -5)
{
turn(180);
}
else if(getY() <= 5 || getY() >= getWorld().getHeight() -5)
{
turn(180);
}
I need to keep the 8 keybing and everything below it so it has both multi and single player capabilities, but also need the turn keys to work smoothly without having to continuously having to hold either 8 or 5.