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

2013/10/10

Randomly turn

skyhighh skyhighh

2013/10/10

#
hello could any one help me. I like to make a monster randomly turn into left,right,up or down.
skyhighh skyhighh

2013/10/10

#
the problem lies with making the monster turn randomly in the right degrees (0,90,180,270)
SPower SPower

2013/10/10

#
Calculate the amount of degrees by doing this:
int number = Greenfoot.getRandomNumber(4);
// 0 will give 0 degrees, 1 will give 90 degrees, 2 will give 180, etc:
int angle = number *90;
skyhighh skyhighh

2013/10/10

#
thank you very much
You need to login to post a reply.