I'm trying to get a random coordinates for my worms, but I can't seem to get it right.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | import greenfoot.*; // (Actor, World, Greenfoot, GreenfootImage) /** * This class defines the crab world. */ public class CrabWorld extends World { /** * Crab world constructor (the beach). * Note: Our world has a size of 560x560 cells, where every cell is just 1 pixel. */ public CrabWorld() { super ( 560 , 560 , 1 ); addObject( new Crab(), 150 , 100 ); addObject( new Worm( 10 ), Greenfoot.getRandomNumber( 580 , 580 ) ); addObject( new Lobster(), 20 , 480 ); addObject( new Lobster(), 480 , 10 ); addObject( new Lobster(), 290 , 290 ); addObject( new Person(), 290 , 480 ); prepare(); } /** * Prepare the world for the start of the program. That is: create the initial * objects and add them to the world. */ private void prepare() { } } |