This site requires JavaScript, please enable it in your browser!
Greenfoot
Username
Password
Remember Me?
Sign Up, Lost Password
Activity
About
Documentation
Download
Discuss
Scenarios
xixEmilyxix
wrote ...
2021/8/5
Random movement
xixEmilyxix
2021/8/5
#
Does anyone know how to make an object just randomly move by itself? I've taken a look at the book scenarios and it's not quite what I wanted. I wanted the bee object to just move randomly around the screen. no target or anything to go to.
Gbasire
2021/8/5
#
you can try this, the object will move at the same speed (2 for example) but at a random direction :
public void act() { move(2); turn(Greenfoot.getRandomNumber(11) - 5); }
You need to login to post a reply.
X