Challenge: Better Acrobatics Controls
If you’re up for a challenge, let’s aim for better acrobatics controls.
Since we have code to listen for keydown and keyup events, try to make
the cartwheels and flips start when the C or F key is pressed and
stop when the C or F key is let go. Do you think the controls are
better this way? If so, leave them in there—it’s your game!
10.3 The Code So Far
If you would like to double-check the code in this chapter, turn to Section
A1.6, Code: Moving Hands and Feet, on page 223.
6.6 What’s Next
We now have a new way to bring our avatars to life. Back in Chapter 4, Project:
Moving Avatars, on page 35, we were able to move the avatar around the scene
and perform flips and cartwheels. In this chapter we were able to make parts
of the avatar move—making the avatar seem much more alive.
The big concept in this chapter was not a JavaScript thing or even a 3D thing.
It was a math thing: sine. Even if you’ve learned about those in math class, I
bet that you didn’t learn to use them like we did here!
One thing that our avatar still lacks is the ability to turn. Even when the
avatar moves to the left or right, it continues to face forward. That’s a bit odd,
right? In Chapter 8, Project: Turning Our Avatar, on page 79, we’ll cover how
to rotate the entire avatar.
But first it’s time for a quick break to look a little more closely at JavaScript.
Chapter 6. Project: Moving Hands and Feet • 66
Prepared exclusively for Michael Powell report erratum • discuss