Your sprites should be animated, that is, they should cycle
through a predefined sequence of images and displacements. In the
Resources section below, we give you a couple of sample image
sequences that you may want to use. Feel free to get others or make
your own. In the code we provide you, we have a mechanism for parsing
simple specs of animation sequences (image frame number, number of
ticks for that frame, x offset, y offset). For example, the code
used on this page for the missile animation in the Checkpoint applet above is:
<APPLET codebase="Checkpoint" code="Checkpoint.class" width=400 height=300>
<param name="background" value="Checkpoint/clouds.jpg">
<param name="backgroundScrollX" value="5">
<param name="backgroundScrollY" value="-1">
<param name="defender" value="Checkpoint/missile.gif, 3, 0,1,0,0, 1,1,0,0, 2,1,0,-1">
</APPLET>
The "background" parameter is the file name for the background image
of the playfield. The "backgroundScrollX" and "backgroundScrollY"
values indicate the displacement that creates the motion effect. In
our implementation, these scroll offsets refer to a displacement of
the screen relative to the background image, thus, the background
image appears to be moving in the opposite direction, i.e. with the
negative of the specified offsets.
The "defender" sprite is specified by specifying an image file name, the
number of frames in the animation (see below), and then a sequence of
four-tuples (image frame, ticks, dx, dy) that specify the animation.
In your game, you will need to specify several animated sprites by
adding additional parameters. Here's the input to the Invaders game
at the top of this page:
<APPLET codebase="Invaders" code="Invaders.class" width=400 height=300>
<param name="background" value="Invaders/clouds.jpg">
<param name="backgroundScrollX" value="5">
<param name="backgroundScrollY" value="-1">
<param name="invader" value="Invaders/invader.gif, 7">
<param name="defender" value="Invaders/defender.gif, 1">
<param name="missile" value="Invaders/missile.gif, 3">
<param name="bomb" value="Invaders/bomb.gif, 1">
</APPLET>