O'Reilly logo

HTML5 Game Development For Dummies by Andy Harris

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

Chapter 6

Creating Game Elements

In This Chapter

arrow Creating your own sprite objects

arrow Adding properties and methods to custom objects

arrow Incorporating sound effects

arrow Detecting collisions between sprites

arrow Setting up a basic timer

Games have things moving around, crashing into each other, and making noise. Obviously, to have a game, you’ll need these elements. You can build objects with the Sprite element built into the simpleGame library (refer to Chapter 5 if you need a review of building simple games with this library).

Building Your Own Sprite Objects

To make very powerful games, you’ll want to be able to build your own sprites that do exactly what you want them to do.

In this chapter, you find out how to build your own new types of objects based on existing objects. After you make an object, you can give it characteristics and behavior.

Making a stock sprite object

To get started, take a look at this simple object:

<!DOCTYPE HTML>

<html lang=”en-US”>

<head>

    <meta charset=”UTF-8”>

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