This morning I’ve been building the enemy spawning system.
Enemies come in 2 forms; basic and shielded. A basic enemy is assigned a colour and will die when struck by a bullet of the same colour. A shielded enemy spawns with a shield, which is broken when struck by a bullet of the same color. This is easy peasy stuff.
The tricky/time-consuming part is building the framework to spawn all combinations of basic and shielded enemies (7 base colors, 7 shield colors) as well as where the enemies spawn from and the time delay between each one. How I’ve done this is by storing all that data like frames in an animation timeline.
Every time an enemy spawns, the timeline is advanced by 1… then the next enemy to spawn is generated by reading the appropriate position on the timeline. Each tick adds 1, which corresponds to the next enemy in the queue.
In the screenshot above (left side), the number ’12’ corresponds to a RED enemy with an ORANGE shield. 11 is RED with RED, 13 is RED with YELLOW.
When an enemy is ready to be spawned, it will look at the enemy list (on the right side) and read the number assigned to it. This will then spawn an enemy that has the correct colors. For example, the 3rd enemy to be spawned is Red with RED (11) , the 4th is YELLOW with a BLUE shield (35), the 5th is INDIGO with an INDIGO shield (66) etc.
When the enemy is spawned, the delay for the next enemy is read in the spawns[#,#] section and the horizontal spawn position is read in the spawnpoint[#,#] section.
Now this is built, the core gameplay is done! What’s left is to add some sounds, some scoring/progression system and finally make sure the content is fun. I’ve got the system to spawn the enemies but the actual data inside that system is will make it fun or not.