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

2013/6/18

Random turns

eddietheboss27 eddietheboss27

2013/6/18

#
how do i make a character turn randomly between 1 and 10? thanks anyway
Zamoht Zamoht

2013/6/18

#
I don't know what you mean by turning between 1 and 10, but to get a number between 1 and 10 you can use: int number = Greenfoot.getRandonNumber(10) + 1; I hope you are able to use this for your random turn else let me know more about what you want to do exactly.
I don't know whether this will help, but this is code for making an actor turn between -45 and 45 degrees
        if (Greenfoot.getRandomNumber(100) < 10)
        {
            turn(Greenfoot.getRandomNumber(90) - 45);
just edit the code for your liking and voila! the actor will turn every 10 frames or so! The DoctorProfessor is out!
eddietheboss27 eddietheboss27

2013/6/25

#
Thsnk dude i will try it
eddietheboss27 eddietheboss27

2013/6/25

#
*Thanks
You need to login to post a reply.