hey guys, I have been trying to get the world to spawn 2 enemies when one is killed, my code states that there are no error but it somehow doesnt work.
any solutions?
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class MyWorld extends World
{
public MyWorld()
{
super(1000, 600, 1);
prepare();
}
public void act()
{
int max = 5;
int randomwidth = Greenfoot.getRandomNumber(200);
int randomheight = Greenfoot.getRandomNumber(500);
if (getObjects(Enemy.class).size()<max)
{
addObject(new Enemy(),randomwidth,randomheight);
}
if (getObjects(Enemy.class).size()<max-1){
max++;
}
}
/**
* Prepare the world for the start of the program.
* That is: create the initial objects and add them to the world.
*/
private void prepare()
{
player player = new player();
addObject(player,469,241);
player.setLocation(936,566);
player.setLocation(943,919);
player.setLocation(479,273);
}
}
