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

Defining the floor and tiles in the game


In this task, we would like to define an essential game object—tiles. We use tiles to construct the running floor, and the types of tiles include the runway terrain and obstacles.

Prepare for lift off

We will put our code in several places. Make sure that you have the following files ready before you start:

  • setting.js

  • tile.js

  • player.js

Engage thrusters

First, let's put the game objects inside the game scene in the HTML file. There is an element that represents the floor, an element that represents the player, and a few temporary elements that represent the tiles, these are given in more detail in the following steps:

  1. The tile elements come with an inline style for placement on the floor:

    <div id="game-scene" class="scene">
      <div id="floor" class="floor">
        <div id="player"></div>
        <!-- temporary code to be removed in next task -->
        <div class='tile tile-1'   style='transform: translate3d(100px,     0, 0)'&gt...