I am making a game where the player is faced against a horde of zombies. I am trying to get it so that the zombies spawn at a quick pace into the world to make the game difficult. My current code is this:
time = 50;
i = 0;
Right now the game starts out with the some zombies already in the world and it will immediately spawn 2 more usually. Then the problem begins and it takes forever for new ones to appear. Any help would be great!
public void addZombie() { if(i==time) { i =0; if(time>1) time-=5; int spawn = Greenfoot.getRandomNumber(3); if(spawn == 1 || spawn == 2 || spawn == 0 ) { getWorld().addObject(new Zombie(), 550, Greenfoot.getRandomNumber(450) + 100); } } else i++; }