In This Chapter
Moving an object on the screen
Responding to keyboard input
Reading mouse input
Running code repeatedly
Bouncing off the walls
Preloading image files
Using external script files
Because this chapter is about animation, most of the pages feature motion. You really must see these pages in your browser to get the effect because a static screen shot can't really do any of these programs justice.
The general structure of this page provides a foundation for other kinds of animation:
The HTML is pretty simple. The page really doesn't require much HTML code. It's a couple of divs and some buttons.
The ball is in a special div called
sprite. Game developers call the little images that move around on the screen sprites, so I use the same term.
Figure 7.1. Click the buttons and the ball moves ...