In this task, we add a leveling system to the game. We will use a dedicated object to manage different combinations of enemies and their spawning frequency.
In this task, we will create a new file for controlling the enemy waves. Let's call it waves.js
and include it in the HTML:
<script src="scripts/waves.js"></script>
Let's work on leveling:
Note
Note that we will show only three waves here. The three waves in the book are presented for demonstration purposes. In reality, we have much more waves that are declared. They are just different combinations with different amounts. So, we don't want to paste the whole waves' data here with duplicated content. Please check the code example for the full waves' data code.
First, we will work on the
waves.js
file. Thewaves
object is simply a literal object because we only want one instance to manage all of the leveling:// controlling waves ;(function(game, cjs){ game.waves = {}...