I want the program to create one of my four objects over and over again. The objects should be created randomly. So my question is: How can I make the variable i get a different random number after one object has been created? I also want to insert a delay after one object has been created.
I hope you guys can understand my english and here is the code:
int i = Greenfoot.getRandomNumber(4);
public void act()
{
if(i == 1)
{
getWorld().addObject(new objekt1(), 150, 10);
}
if(i == 2)
{
getWorld().addObject(new objekt2(), 150, 10);
}
if(i == 3)
{
getWorld().addObject(new objekt3(), 250, 10);
}
if(i == 4)
{
getWorld().addObject(new objekt4(), 150, 10);
}
// Add your action code here.
}