import greenfoot.*;
public class MyWorld extends World
{
public int a = 0;
private int threshold = 100; //increase to make the time until a random thing is added longer...
private int thresholdWave = 3; //increase to make the time until a random thing is added longer...
Counter counter = new Counter();
/**
* Creates a world with the size of 1100x500 cells, where every cell is just 1 pixel
*/
public MyWorld()
{
super(1100, 500,1);
addObject(counter, 50, 25);
}
public void act()
{
a++;
if(a == threshold)
{
RandomPlacement();
a = 0;
}
}
public void RandomPlacement()
{
int x = Greenfoot.getRandomNumber(getWidth());
int y = 10;
addObject (new Rock(counter),x,y);
}
{
if (Greenfoot.mouseClicked(this)){ // Hvis der er trykket med musen på objektet sker følgende
int x= Greenfoot.getRandomNumber (getWidth());//generer tilfældigt nummer
int y= Greenfoot.getRandomNumber (getHeight());//generer tilfældigt nummer
}
}
}