EasyManua.ls Logo

Commodore VIC-20 - Page 205

Commodore VIC-20
404 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter
6:
Graphics 191
XS X Speed: the car's speed in the X dimension: negative
is
toward the left, positive toward the right
XT
X Time: the value of
TI
when it
is
time to move in the
X dimension
YS
Y Speed: the car's speed in the Y dimension: negative
is
up, positive
is
down
YT
Y Time: the value
of
TI when it
is
time to move in the
Y dimension.
Lines
1000
through 2000 are the main processing loop
of
the program.
The program runs continuously through the code, looking for something to
do. On each pass it checks the current time to see if it should move the car
(lines
1000
and 1100)
or
look
atthe
joystick (line 1600). If any ofthese things
need to be done, the timer value for the next occasion
is
also set.
In lines
1120
and
1140
the program checks to ensure
that
the car has not
gone off the screen. Lines
1300
and
1400
make sure
that
the car
is
not about
to collide with a wall.
If
either
of
these
is
true, the program goes to the
"crash" routine
at
line 4000.
Lines 1750 and 1850 make use
of
the VIC chip's ability to sound a
"tock" each time the program tests the joystick
..
(The VIC 20's sound
capabilities are discussed in Chapter 7.)
The "crash" routine (lines 4000 through 5500) brings the car back onto
the screen if it has gone off (lines 4000-4500), and makes it flash
at
a rate
of
about once per second (lines 5000-5300).
As
soon as the user presses any key,
line 5400 starts the game again.
Racetrack
is
both
an
example
of
graphics techniques and a base on
which
to
build your own experiments. You might want
to
try printing a
readout
of
the number
of
turns
or
seconds used in the infield, modifying the
course,
or
making sure
that
the car has really gone all the way around the
course, instead of doubling back
to
the finish line.
CUSTOM
CHARACTER
SETS
The VIC
20
can easily change the shapes
of
the characters
that
appear
on the screen. Most personal computers require hardware changes
to
use a
different set
of
characters,
but
the VIC allows you to create your own
characters, then switch over to your character set with a simple POKE. In
this section
we
will show how the character set
is
defined and how
to
design
your own characters and make them appear on the screen.

Other manuals for Commodore VIC-20

Related product manuals