Ok, im trying to work out how to not come in the same direction you came in e.g. the actor is walking right.. when obstacle occurs dont go left aka dont go back to the same direction you came in.
Currently i have
Where getDirection determines the direction you're going
1 2 3 4 | public static final int goUp = 0 ; public static final int goDown = 1 ; public static final int goLeft = 2 ; public static final int goRight = 3 ; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | void optionsOfDirection() { getDirection(); int chooseADirection = Greenfoot.getRandomNumber( 4 ); switch (chooseADirection) { case goUp: setDirection( "up" ); break ; case goDown: setDirection( "down" ); break ; case goLeft: setDirection( "left" ); break ; case goRight: setDirection( "right" ); break ; } } |