O'Reilly logo

HTML5 Game Development HOTSHOT by Makzan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Summoning the enemies

In this task, we spawn enemies on the board.

Prepare for lift off

We create one file for each type of enemy. They are enemy.js, enemy-dummy.js, enemy1.js, enemy2.js, enemy3.js, and boss.js. Let's create these files and put them inside the scripts/board-objects/enemies/ folder. Then, we include them in the game's HTML. The base enemy.js file comes first because all the other enemy types are based on enemy.js and need its reference:

<script src="scripts/board-objects/enemies/enemy.js"></script> <script src="scripts/board-objects/enemies/enemy-dummy.js"></script> <script src="scripts/board-objects/enemies/enemy1.js"></script> <script src="scripts/board-objects/enemies/enemy2.js"></script> <script src="scripts/board-objects/enemies/enemy3.js"></script> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required