My game
I need help with this java exception. In Greenfoot the problem does not appear.
The link above shows my game which throws the error.
import greenfoot.*;
public class MyWorld extends World
{
public static Counter counter;
public static void addScore(int score)
{
counter.add(score);
}
public MyWorld()
{
super(600, 400, 1);
if (counter == null)
{
counter = new Counter();
}
addObject(counter, 521, 27);
counter.setValue(0);
addObject(new You(), 36, 374);
for (int i=0; i<10; i++) {
int randomX = 10 + Greenfoot.getRandomNumber(580);
int randomY = 1 + Greenfoot.getRandomNumber(320);
addObject(new PlasticBottle(), randomX, randomY);
}
}
}for (int i=0; i<10; i++)
{
addBottle();
}public void addBottle()
{
int randomX = 10 + Greenfoot.getRandomNumber(580);
int randomY = 1 + Greenfoot.getRandomNumber(320);
addObject(new PlasticBottle(), randomX, randomY);
}