I want to have my world add 50 enemies in one wave but have two enemies spawn every 2 seconds and once they are killed have the new wave start. can anyone help me?
public void newWave()
{
for (int i=0; i<50; i++)
{
addObject(new Enemy(), /*x-position*/, /*y-position*/);
}
}private int enemySpawnTimer = -1;
public void act()
{
if (++enemySpawnTimer == 55*2)
{
enemySpawnTimer = 0;
for (int i=0; i<2; i++) addObject(new Enemy(), /*x-position*/, /*y-position*/);
}
}private int enemySpawnTimer = 0;
private int spawnEnemies = 0;
public void act()
{
if (spawnEnemies > 0)
{
if (++enemySpawnTimer == 55*2)
{
enemySpawnTimer = 0;
spawnEnemies -= 2;
for (int i=0; i<2; i++) addObject(new Enemy(), /*x-position*/, /*y-position*/);
}
}
else //no enemies will spawn in this wave anymore
{
if (getObject(Enemy.class).isEmpty()) //no enemies in the world
{
spawnEnemies = 2*25;
}
}
}