My Scenario
There is ABSOLUTELY no reason why the man can not move in all 4 directions.
if ("w".equals(Greenfoot.getKey())) {
setLocation(getX(), getY() - 1);
}
if ("s".equals(Greenfoot.getKey())) {
setLocation(getX(), getY() + 1);
}
if ("d".equals(Greenfoot.getKey())) {
setLocation(getX() + 1, getY());
}
if ("a".equals(Greenfoot.getKey())) {
setLocation(getX() - 1, getY());
}
List<String> enteredKeys = new ArrayList<String>(); // this is a list to hold the individually keystrokes in the order that they are entered
public String getKey()
{
if (enteredKeys.isEmpty()) return null; // if the list is empty, return a 'null' value
return enteredKeys.remove(0); // otherwise, remove and return the first element in the list
}