3D Game Programming

(C. Jardin) #1
goal, and play the guitar when we reach the goal. Add the following just below
your avatar.addEventListener() and before moveGoal():

avatar.addEventListener('collision',function(object) {
if(object.isGoal) Sounds.guitar.play();
elseSounds.click.play();
});

Don’t forget to add the Sounds.js library at the top if you want sound:


<script src="http://gamingJS.com/Sounds.js"></script>

There are all sorts of things that you can do to make this game as special as
possible for players. Get creative!

19.4 The Code So Far


If you would like to double-check the code in this chapter, compare yours
with the code in Section A1.19, Code: Multilevel Game, on page 259.

20.7 What’s Next


Most of the action in this game took place in two dimensions. To be sure, we
used some impressive programming skills (and even a little 3D programming)
to make this game. Still, let’s get back to 3D programming in our next game.
We’ll use all of our skills in the next chapter, so let’s go!

Chapter 19. Project: Multilevel Game • 184


Prepared exclusively for Michael Powell report erratum • discuss

Free download pdf