I keep getting this error message when I try to place 10 actors randomly around the world. I need help fixing this! I can post code if needed.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* The game world.
*
* @author Austin Prokopishin
* @version 1.0
*/
public class MyWorld extends World
{
GreenfootSound backgroundMusic = new GreenfootSound("8-Bit Dubstep IV.mp3");
/**
* Constructor for objects of class MyWorld.
*
*/
public MyWorld()
{
// Create a new world with 1600x770 cells with a cell size of 1x1 pixels.
super(1600, 770, 1);
populate();
backgroundMusic.playLoop();
}
public void populate(){
int x;
int y;
for(int i = 0; 1 < 5; i++) {
x = (int)(Math.random() * 1600);
y = (int)(Math.random() * 770);
addObject(new Asteroid1(), x, y);
addObject(new Asteroid2(), x, y);
}
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* The asteroids.
*
* @author Austin Prokopishin
* @version 1.0
*/
public class Asteroid1 extends Actor
{
/**
* Act - do whatever the Asteroid1 wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
GifImage gifImage = new GifImage("explosion.gif");
public void act()
{
// from modern-crab
if (isTouching(LazerBolt.class)) {
getWorld().addObject (new explosion(), getX(), getY());
removeTouching(LazerBolt.class);
getWorld().removeObject(this);
}
}
}