Wednesday, November 4, 2015

architecture - How do I write a wave-spawning system for a shoot-em-up?


I recently played Knightmare Tower and was amazed by the way how different monsters are beign spawned.


I'm aware of time-based and count-based spawing systems in shoot-em-ups. Count-based systems allow a certain number of enemies on screen and spawn more as they die. Time-based ones spawn more at given intervals.


How are these spawning mechanism built? Is there some pattern or theory to it?




Additionally, such games typically have increasingly resilient enemies of increasing numbers of types. How are these balanced?



I'm looking for a general answer, independent of any particular game or technology.



Answer



From playing Knightmare Tower from beginning to end, it seemed like the enemies were mostly predefined as opposed to being procedurally generated. There was some randomization, but from what I can remember it was very minor variance.


But to achieve something similar, I would do something along the lines of:



  • Have several collections of enemies to pull from, for each "floor", and replace the collection every time the player reaches a new floor.

  • Then have weights associated with the enemies based on difficulty to control how often they show up, and possibly have a maximum for each type of unit, so there is no way to get, say five of the wizard type mobs, that would be quite difficult for the floor to deal with.

  • Then to place them, you can just check and see where other enemies are, and place them decently far from the others.

  • As for timing, I would say pick a base enemy density, which increases as the player reaches new floors.



Spawning systems are so specific to a game, I'm not sure how applicable any general theorycrafting would be. I would just recommend hammering out a basic system for spawning, start playing the game, and refining it from there. For example, you could implement moving weights for enemy chance, say every time it spawns the weight goes down by 5%, to make it self correcting for some of the randomness, etc.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...