So I'm trying to make a game where the character has to navigate a maze, but I'm pretty new to Greenfoot and I can't figure out how to keep him from going through walls. Is there a way other than the turn(180)?
int dx=0, dy=0;
if (Greenfoot.isKeyDown("up")) dy--;
if (Greenfoot.isKeyDown("down")) dy++;
if (Greenfoot.isKeyDown("right")) dx++;
if (Greenfoot.isKeyDown("left")) dx--;
if (dx != 0 || dy != 0) setLocation(getX()+dx, getY()+dy);