This site requires JavaScript, please enable it in your browser!
Greenfoot back
ALPH3A
ALPH3A wrote ...

2017/3/23

HELP

ALPH3A ALPH3A

2017/3/23

#
I'm new to greenfoot, i want to make a variable that chooses t between 1 and 4, and it turns depending on that number. any help or tips?
danpost danpost

2017/3/23

#
If you used 'Greenfoot.getRandomNumber(4)', you will get a number in the set { 0, 1, 2, 3 }. Adding one to the result will get you a number between 1 and 4. If you are turning by 't*90' degrees and a turn must be executed then you must remember that '4*90 = 360' and no turn will be exacted (the actor will look in the same direction as before)..
You need to login to post a reply.