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

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>
<script src="scripts/board-objects/enemies/boss.js"></script>

We need one more helper function. The removeItem function finds the given target in the given...