How would I go about making this only allow a key being held down to register as 1 action?
Here's what I have:
public void move()
{
if(Greenfoot.isKeyDown("up")){
setLocation(getX(), getY() - 1);
}
if(Greenfoot.isKeyDown("down")){
setLocation(getX(), getY() + 1);
}
if(Greenfoot.isKeyDown("right")){
setLocation(getX() + 1, getY());
}
if(Greenfoot.isKeyDown("left")){
setLocation(getX() - 1, getY());
}
}
And from there I want to make it so that no matter what, even if the key is still down, it doesn't allow a held down key to count for more than action.
How would I do that?
