IM trying to get actor instances to spawn randomly (same actor but different instance of the actor in the world). I really need help with this.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Level2 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Level2 extends World
{
/**
* Constructor for objects of class Level2.
*
*/
public Level2()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(800, 600, 1);
prepare();
int a = Greenfoot.getRandomNumber(400);
int b = Greenfoot.getRandomNumber(300);
int c = Greenfoot.getRandomNumber(400);
int d = Greenfoot.getRandomNumber(300);
int e = Greenfoot.getRandomNumber(400);
int f = Greenfoot.getRandomNumber(300);
}
/**
* Prepare the world for the start of the program.
* That is: create the initial objects and add them to the world.
*/
private void prepare()
{
Strawberry strawberry = new Strawberry();
addObject(strawberry,511,373);
Strawberry strawberry2 = new Strawberry();
addObject(strawberry2,269,425);
Strawberry strawberry3 = new Strawberry();
addObject(strawberry3,335,244);
Strawberry strawberry4 = new Strawberry();
addObject(strawberry4,716,385);
Strawberry strawberry5 = new Strawberry();
addObject(strawberry5,715,20);
Strawberry strawberry6 = new Strawberry();
addObject(strawberry6,162,170);
Strawberry strawberry7 = new Strawberry();
addObject(strawberry7,98,487);
}
public void act()
{
}
}
