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
About the Author
About the Reviewers

Managing the scenes

In this first task, we will prepare the scenes, which act as a container for all our game objects.

Prepare for lift off

Before creating the scene flow, we prepare the basic scenes definition.

The scene is set up in the same way as the previous project. However, this time we simplified it into two scenes only. Add the following code in the game.js file:

  var game = this.spaceRunner || (this.spaceRunner = {});

  // Main Game Flow
  game.flow = {
    startGame: function() {
    gameOver: function() {;

  // Entry Point
  var init = function() {
    console.log("Welcome to Space Runner Game.");
    game.isGameOver = true;

Then, we move to the scene.js file to define a scene object. This scene object has basic abilities such as showing and hiding itself. Moreover...