this is my code so far but is set for it to decide to get a random direction from a whole 360degree angle.
But our professor just changed his mind, in specifically wanting it to either turn up, down, left, or right, randomly.
Thanks in advance for HELP.
1 2 3 4 5 6 7 8 9 10 11 12 | /** * keep count of how many times "act()" has been called. * If "act()" has been called 5 times, object with turn a random direction from 0 to 360 degrees. */ public void called() { if (actCounter == 5 ) { turn(Greenfoot.getRandomNumber( 360 )); //turns, by getting a random number (in degrees) from 0 to 360. actCounter = 0 ; } } |