Hi but could i have the code for placing objects into the world. There should be at least five of them spawning. My World class is The_House and my actors are Villian and The_Jail. It would be better if I could have seven of The_Jail.
int x = Greenfoot.getRandomNumber(getWidth()); int y = Greenfoot.getRandomNumber(getHeight());
public void addActor(Actor actor)
{
int x = Greenfoot.getRandomNumber(getWidth());
int y = Greenfoot.getRandomNumber(getHeight());
addObject(actor, x, y);
}addActor(new Villian());
for (int i=0; i<7; i++) addActor(new The_Jail());
public void addActor(Actor actor)
{
int x = Greenfoot.getRandomNumber(getWidth());
int y = Greenfoot,getRandomNumber(getHeight());
addObject(Villian,x,y)
}
for (int i=0; i<1+Greenfoot.getRandomNumber(7); i++) addActor(new The_Jail());
for (int i=1+Greenfoot.getRandomNumber(7); i>0; i--) addActor(new The_Jail());
int count = 1+Greenfoot.getRandomNumber(7); for (int i=0; i<count; i++) addActor(new The_Jail());
int x = Greenfoot.getRandomNumber(getWidth()); int y = Greenfoot.getRandomNumber(getHeight());
public void addActor(Actor actor)
{
int x = Greenfoot.getRandomNumber(getWidth());
int y = Greenfoot.getRandomNumber(getHeight());
addObject(actor, x, y);
}addActor(new Villian());
for (int i=0; i<7; i++) addActor(new The_Jail());