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

2012/10/19

Crab scenario question

mncomic mncomic

2012/10/19

#
One of the excercises in the Greenfoot book refers to adding random behavior to worms place on world how does one add random behavior to stationary objects? addObject(new Worm(), 20, 500); addObject(new Worm(), 30, 200); addObject(new Worm(), 60, 90); addObject(new Worm(), 80, 310); addObject(new Worm(), 150, 50); addObject(new Worm(), 210, 410); addObject(new Worm(), 220, 520); addObject(new Worm(), 380, 330); addObject(new Worm(), 410, 270); addObject(new Worm(), 530, 30);
davmac davmac

2012/10/19

#
I think the point is to add them into a world at a random location. You don't need to change the behavior of the Worms themselves.
mncomic mncomic

2012/10/20

#
Thanks...I get that part...how do I write the method for each? getRandom?
Upupzealot Upupzealot

2012/10/20

#
@see the method Greenfoot.getRandomNumber(int limit) Greenfoot has a very good API andit could help U a lot. Double click "Actor" or "Would" in the class bar of Greenfoot to open it in your browser
mncomic mncomic

2012/10/20

#
Thanks
Upupzealot Upupzealot

2012/10/20

#
XD you are welcome
You need to login to post a reply.