I'm currently making a defense game where enemies will spawn and attack the player's army. It's similar to a Tower Defense game, except there is only one level. The enemies will keep spawning until eventually the user dies or he amasses a large enough army that they wipe out any enemy that spawns instantly (hopefully it'll be challenging enough that this won't happen).
What I'm struggling with at the moment is how to make this game get progressively harder and the probability of an enemy spawning basically eventually reach 100%.
So far I've got something similar to the following
if(Math.random() < 1 - (1/elapsed_time) && spawnTimer <= 0 ){
spawnEnemy()
spawnTimer = rand(); // random number between 1 and 3
}
But it seems too uniform to begin with. At the moment I'm only spawning one type of enemy, the idea being that tougher enemies are spawned as time progresses as well.
I also think I need to randomise my spawnTimer
at bit more and make that get quicker as time progresses, but I just can't seen to get my head around what my logic should really look like for this whole section. Is anyone able to help with a rough idea of this kind of formula?
I'm currently using javascript to write the game, but obviously it's more about the concept.