For Loop & Number of Enemys
Posted: Fri Mar 10, 2017 11:37 am
Hi, i try to make a simple Tower Defense Game. A main feature is that you can run multiple waves at the same time. If a wave is running it should spawn 1 enemy each 2 seconds. If 2 waves are running it should spawn 2 enemys each 2 seconds.
But my for loop only spawn 1 enemy from the first launched wave and if the first wave is finished it starts spawning from the second wave.
And I have a second question. If i have around 1.000+ enemys spawned (they just move from left to right) is begins to stutter :-( how I can stop this?! I mean my enemys are just tiny balls and in other games there are far more than 10.000 things moving at the same time without stutter.
But my for loop only spawn 1 enemy from the first launched wave and if the first wave is finished it starts spawning from the second wave.
spawnWaiting1 = 0,1
spawnWaiting2 = 0,1
spawnWaiting3 = 2
spawnWaiting4 = 2
function spawnController(dt)
spawnWaiting1 = spawnWaiting1 - dt
spawnWaiting3 = spawnWaiting3 - dt
if spawnWaiting3 < 0 then
for i=1, #wave do
if wave > 0 and spawnWaiting1 < 0 then
wave = wave - 1
spawnEnemy(dt)
spawnWaiting1 = spawnWaiting2
end
spawnWaiting3 = spawnWaiting4
end
end
end
And I have a second question. If i have around 1.000+ enemys spawned (they just move from left to right) is begins to stutter :-( how I can stop this?! I mean my enemys are just tiny balls and in other games there are far more than 10.000 things moving at the same time without stutter.