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”>

Get HTML5 Game Development For Dummies now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.