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

Using a game loop

In the previous section, we placed the tiles in HTML directly, and then moved the temporary code for the creation of tiles from HTML to JavaScript.

Although the tiles are created programmatically, it is a one-time creation only. The tiles do not move. No new tiles are created after the initialization.

What we will do in this task is continuously create tiles based on a predefined pattern, and keep moving the existing tiles down.

Prepare for lift off

In this task, we are going to create tiles based on the data provided by the user instead of having the tile patterns hardcoded.

Before we start, let's remove the temporary code that creates testing tiles in JavaScript. The startOver function is reverted to the following state:

gameScene.startOver ...

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