Hi,
I am having trouble placing five orbs in the world at random locations using a loop.
My instructions are to:
Within the OrbWorld constructor, use a loop to place at least five Orbs in the world whenever you run the program. Use conditions to ensure none of the Orb graphics will be cut off by the edge of the world. Assign each of the Orbs a random velocity.
This is what I have so far:
randomOrbs(5);
}
/**
* Creates five golden Orbs and places them at
* random locations within the world.
*/
public void randomOrbs(int number)
{
While(number > 5);
{
int x = Greenfoot.getRandomNumber(getWidth());
int y = Greenfoot.getRandomNumber(getHeight());
int xSpeed = Greenfoot.getRandomNumber(10);
int ySpeed = Greenfoot.getRandomNumber(10);
addObject (new Orb (new Velocity(int xSpeed, int ySpeed)),x, y);
number++;
}
}
}

