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

2013/2/26

how objects move at world edges?

dion.williams dion.williams

2013/2/26

#
hey guys I sort of new to all the green foot coding stuff and was just wondering how I can get an object to randomly move In any direction from a world edge please help?
Jonas234 Jonas234

2013/2/26

#
if you want it to move completly random you need a ranom number. Greenfoot has a method: Greenfoot.getRandomNumber(limit) Now you can do sth like:
if(Greenfoot.getRandomNumber(20)== 1)
{
       turn(Greenfoot.getRandomNumber(46)-23);
}
move(3)
Now there is a 5% chance that the object will turn around -23 and 23 degree. And it will move forward the whole time. If you want him to move more randomly just chance the numbers or add some more. Jonas
Gingervitis Gingervitis

2013/2/26

#
I actually got to to scale, but how can I get it to scale bigger as it moves across the screen?
Gingervitis Gingervitis

2013/2/26

#
I responded to the wrong discussion page...
dion.williams dion.williams

2013/2/26

#
thank you very much Jonas234 its now working.
You need to login to post a reply.