Hi, in this code, i'm creating a list of monsters that are currently in the world, when i hit a monsters (code written in another class), the monster disappears. As long as it remains at least one monster in the world, the other monsters are auto-created, but when i succeed in destroying all monsters before others spawn, there're no more monsters created in the world... So what's going wrong in my code?^^
Thank you!
public void createMonsters() { List<Monsters> monsters = getWorld().getObjects(Monsters.class); Monsters monster = new Monsters(); int lengthOfList = monsters.size(); int randomNumber = Greenfoot.getRandomNumber(150); if((lengthOfList < 3 && randomNumber == 0) || monsters.isEmpty()) { getWorld().addObject(monster, getWorld().getWidth(), 100+Greenfoot.getRandomNumber(getWorld().getHeight()-200)); } }