HTML and CSS Reference
Flying Before You Walk
What's in this chapter?
• Creating the HTML5 for a game
• Loading images and drawing on canvas
• Setting up your game's structure
• Creating an animated background
• Listening for user input
Wrox.com Code Downloads for this Chapter
The wrox.com code downloads for this chapter are found at www.wrox.com/rem-
title.cgi?isbn=9781118301326 on the Download Code tab. The code is in the chapter 01 download and indi-
vidually named according to the names throughout the chapter.
Games have long been a medium that pushes technology to its limits. This topic continues that proud tradition
their capabilities and performance. HTML5 as a game medium has come a long way capability-wise in a short
amount of time, and many people believe in-browser gaming will be one of the primary distribution mechan-
isms for games in the coming years.
Even though it's not an environment originally designed for creating games, HTML5 is actually a nice, high-
level environment for doing just that. So, in lieu of trying to abstract away all the boilerplate by building an
engine immediately, you can get right to the good stuff: a one-off game built from the ground up on HTML5—a
top-down 2-D space shooter called Alien Invasion .
Building a Complete Game in 500 Lines
To drive home the point of how easy it is to build games in HTML5, the final game you build in the first three
chapters contains fewer than 500 lines of code, all without using any libraries.