Chapter 6
Creating Game Elements
In This Chapter
Creating your own sprite objects
Adding properties and methods to custom objects
Incorporating sound effects
Detecting collisions between sprites
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”>
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access