Radio Shack TRS-80 Model 100 Basic Manual page 154

Basic language lab
Hide thumbs Also See for TRS-80 Model 100:
Table of Contents

Advertisement

"
/
1/
A
/]
-
~
(
)
A
I
-
.,.
I
J
I
I
I
)
-
~
.J..J-I
-, ..
••
-<
-
-
,.
-9-
-
-
i"""""' I lI •
J
r'" ,.
0
l
•• tt-
I
I
I
I
,. J ,
A
I
' "
"",
.,.
The number of beats L is determined by the type of note:
quarter note
half
note
whole note
=
1 beat
=
i
beats
=
4 beats
You might like to experiment a little by replacing the DATA statements with your
own music. Just remember to terminate the music with a 0,0.
Experiment #4 Animated Character
Adding sound is not the only way to liven up a program. A display which shows
action is often more interesting than a static display. While there are no specific
animation statements, you can easily create movement using the PRINT@ statement.
The following program illustrates the technique.
Clear memory using the NEW command and enter:
1121 CLS
2121 FOR 1=12121 TO 158
3121 PRINT@ I, CHR$(1l17)j
4121 FOR J=l TO GI2I : NEXT J
5121 NEXT I
Execute this program and watch the stick figure race across the display. While this
program added action, it does not adequately simulate movement. You can erase the
trail behind the runner by printing a space in his previous position and simulate
movement more realistically.
Change line 30 to:
3121 PRINT@ I, "'''; CHR$( 147);
and execute the program to see a more realistic simulation of movement. This is
typical of animation on a computer display; you have to erase the last image and
create the new image for each frame in the sequence.
Line
10
As usual, the program begins by clearing the display.
Line 20 A FOR/NEXT loop varies the print position from 120 to 158. This
corresponds to the fourth line, from the left to the right borders.
148

Advertisement

Table of Contents
loading

Table of Contents