CHAPTER 4
Project: Moving Avatars
In Chapter 3, Project: Making an Avatar, on page 25, we covered how to build
a game avatar. An avatar that we cannot move is pretty dull. So in this
chapter you’ll learn how to make the avatar move in different directions. We’ll
also give it a little forest to move around in. It will end up looking something
like this:
4.1 Getting Started
This chapter builds on the work that we did in Project: Making an Avatar. If
you haven’t already done the exercises in that chapter, go back and do them
before proceeding. In particular, you need to go over the animate() exercise at
the end of that chapter.
Let’s make a copy of the previous chapter’s avatar project. That way, if we
ever want to go back to see our simple spinning and cartwheeling avatar, we
can. To make a copy of that project, click the menu button and choose Make
a Copy from the menu. (See Figure 3, Selecting Make a Copy, on page 36. Let’s
call this project My Avatar: Keyboard Controls, as shown in Figure 4, Naming the
Project, on page 36.
With that, we’re ready to add keyboard controls.
When you’re done with this chapter, you will
- Know how to move the avatar with your
keyboard - Begin to understand JavaScript events
- Be able to move the camera with an avatar
Prepared exclusively for Michael Powell report erratum • discuss