Chapter 6 Graphics
187
display by calling, in turn, subroutines that put the wipers in particular
positions by POKEing characters to the screen. Each subroutine erases the
wipers from the screen and puts them in a new position.
Two of the most important lines in the program are lines
90
and
140.
These FOR-NEXT loops slow down the program. Without such delay
loops, the display would change too quickly, reducing the movement to a
blur. Choosing the lengths
of
the delay loops
is
crucial
to
animation. This
is
especially true of programs that produce complex movements. When devel-
oping such programs, you can expect to spend much of your time fine-
tuning the delays to create a display that moves smoothly
at
the speed you
want. Try experimenting with our example program: The length of the delay
loops
is
controlled by the variable
DL
Y and the value
of
this variable
is
set in
line
10.
A lower value shortens the delay loops, making the display change
more quickly. Increasing the value lengthens the delay loops, slowing the
movement of the wipers.
It
is
difficult
to
do complex animation with the built-in character set
unless you are working with a very large player. In most cases you must
move
part
of
your player an entire character space to move it at all. This
makes the motion somewhat jerky unless the player takes up a large portion
of
the screen. To produce more subtle movements with small players, you
must design your own characters. Techniques for making and using your
own characters
will
be discussed later
in
this chapter.
Combining PRINTed
and
POKEd
Graphics
As
we
have seen, both the
PRINT
and the POKE methods have
strengths and weaknesses in building graphic displays.
For
those programs
that have players moving against a fixed background, a combination of
PRINT
and POKE often works best. Using
PRINT
statements to display
graphics
on
the screen in combination with POKEs that jump to any
location on the screen can make the development
of
a program much easier.
Racetrack
Game
Figure
6-5
is
a listing
of
a simple game called Racetrack, an adaptation
of
a common pencil-and-paper game. This program demonstrates some of
the techniques
we
have discussed so far in this chapter.