For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
Download from Wow! eBook <www.wowebook.com>
Contents at a Glance
About the Authors .....................................................................................................xiii
About the Technical Reviewer...................................................................................xv
About the Cover Image Artist ...................................................................................xvi
Introduction ...............................................................................................................xvii
Chapter 1: The State of Open Web Games.................................................................1
Chapter 2: Complexity from Simplicity.....................................................................15
Chapter 3: How to Make Multi-Platform HTML5 Games from Scratch...................31
Chapter 4: Creating, Saving, and Loading Tracks...................................................61
Chapter 5: 3D CSS Tutorial........................................................................................93
Chapter 6: Particle Systems ....................................................................................107
Chapter 7: Beginning WebGL ..................................................................................133
Chapter 8: CycleBlob: A WebGL Lightcycle Game ...............................................175
Chapter 9: A Real-Time Multiplayer Game Using WebSockets............................213
Chapter 10: Hard-Pressed for a Choice of Technology ........................................239
Index ..........................................................................................................................257
INTRODUCTION
xvii
Introduction
HTML5 is a “game changer,” allowing web browsers on such diverse hardware as smartphones, tablets, and
personal computers to display the same games, interactive ads, and rich-media applications that were
previously only possible as long as the end-user had downloaded the appropriate third-party plug-ins, most
notably Flash. With the advent of HTML5, programmers are able to create cross-platform web applications.
The authors of this book are all real-world games programmers who have come together to share their
HTML5 expertise, tips, and tricks with you.
In the first chapter of the book, Rob Hawkes, a Mozilla evangelist, discusses the state of open web gaming
today. He explores the core technologies of HTML5 and JavaScript and the new APIs that have been
introduced.
In Chapter 2, Russell Goldenberg will walk you through the design implementation and coding of his game A
to B. This physics-based game involves a ball that must be manipulated by a series of modifiers, including
walls and speed boosters, from point A to point B. It was written in Processing.js, a tool with which
Goldenberg was very familiar, allowing him to quickly and easily create the game. For this project,
Goldenberg was not looking to create a scalable, multi-author game, but instead was looking for a “quick and
dirty” approach. The resulting game was a finalist in the Mozilla Game On 2010 competition.
In Chapter 3, Gaëtan Renaudeau shows us how to make multi-platform HTML games from scratch. He
introduces us to the use of CSS, JavaScript, the canvas element, and DOM within HTML5 applications as
demonstrated in a chess game that he has coded.
Chapter 4 is an in-depth walk-though of the use of the canvas element in HTML5. David Strauss and Mathias
Paumgarten show us some of the techniques behind their massively popular Marble Run game.
We see how to create a three-dimensional iPhone/iPad game using HTML5 and CSS in Chapter 5. Seb Lee-
Delisle of the BAFTA-winning Plug-in Media, will show you how to use CSS 3D transformations to move
HTML elements in three-dimensional space. The example game in this chapter involves puffer fish that are to
be exploded on touch.
Chapter 6, by Jonas Wagner, focuses on particle systems to create effects such as fire, rain, and smoke.
You’ll create a high-performance particle system that can deal with tens of thousands of particles, and find
many code examples that you can use in your own projects.
Chapters 7 and 8 introduce the reader to WebGL. In Chapter 7, Brian Danchilla uses the example of a darts
game to walk the reader through checking for WebGL support, understanding 3D coordinate systems,
drawing basic shapes, animating 3D objects, and adding textures.
Chapter 8 advances from the previous chapter and shows how Shy Shalom used WebGL to create a three-
dimensional, TRON-inspired, lightcycle game called CycleBlob.
in Chapter 9, learn how Jonathan Bergknoff used canvas, netcode, and WebSockets to create a real-time,
multiplayer, bumper cars game. Bergknoff demonstrates the complexities of the game logic needed to enable
his game to handle glancing collisions of several vehicles and their resulting trajectories in a multiplayer
environment.
Finally, we round off the book with Chapter 10, where Egor Kuryanovich introduces us to the decision-making
process when assessing which technologies to include in our HTML5 application. He outlines the benefits
INTRODUCTION
xviii
and disadvantages of the HTML5 canvas element, SVG, web sockets, server-sent events, and web fonts,
preparing us for understanding the implications of the choices made by the other authors in subsequent
chapters.