Book Image

HTML5 Game Development Hotshot

By : Seng Hin Mak, Makzan Makzan (Mak Seng Hin)
Book Image

HTML5 Game Development Hotshot

By: Seng Hin Mak, Makzan Makzan (Mak Seng Hin)

Overview of this book

Table of Contents (15 chapters)
HTML5 Game Development HOTSHOT
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Controlling enemy waves


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.

Prepare for lift off

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>

Engage thrusters

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.

  1. First, we will work on the waves.js file. The waves 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 = {}...