hey all,
I have make this code so I can drive an actor but what need I change in this code so that another actor (who i can't drive) would walk as the same as this code (but than automatic)
public void processKeys()
{
if(Greenfoot.isKeyDown ("left")) {
setLocation(getX() - 2, getY());
}
else {
setLocation(getX(),getY());
}
if(Greenfoot.isKeyDown ("down")) {
setLocation(getX(),getY() + 2);
}
else {
setLocation(getX(),getY());
}
if(Greenfoot.isKeyDown ("right")) {
setLocation(getX() + 2,getY());
}
else {
setLocation(getX(),getY());
}
if(Greenfoot.isKeyDown ("up")) {
setLocation(getX(),getY() - 2);
}
else {
setLocation(getX(),getY());
}
}