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

Defining levels

In this task, we define multiple levels that contain different combinations of obstacles.

Prepare for lift off

We have successfully put bodies in the physics world in the previous tasks. In this task, we would like to extract the body placement into an easier definition, so that we can massively define a series of levels.

In these levels, we define the position of the hoop and ball. We also define how obstacles are placed in each level.

We define the levels in a new file called level.js. Let's include it in HTML:

<script src="scripts/level.js"></script>

Engage thrusters

We will now work on the newly created level.js file:

  1. In the level.js file, we define the balls and levels data. Most of the data defines the physics properties:
    game.balls ...

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