70
FOR
T = 1
TO
30
80
SOUND
7000,1
80
A$=CHR$(145+3*RND(1»
1006$=CHR$(145+3*RND(1»
110
C$=CHR$(145+3*RND(1»
120
PRINT@
137,A$;
130
PRINT@
138,6$;
140
PRINl@
141,C$;
150
NEXT
T
180
IF
A$=B$
AND
6$=C$
GOTO
200
170
PRINT@
240,"Press
ENTER"
180
A$=INKEY$ :
IF
A$=""GOTO
180
180
PRINT@
240,
" " :
GOTO
20
200
FOR
J=l
TO
4
210
PRINT@
217,
"1-1
I
N";
220
FOR
1=1800
TO
800
STEP
-50
230
SOUND
1,2
:
NEXT
I
240
PR
I
NT@
217,
" " ;
250
FOR
K=l
TO
100
:
NEXT
K
280
NEXT
J : GOlO
170
Execute the program.
A slot machine will appear on the display with three characters appearing at random in
the windows. After a few seconds the characters will stop changing. A win occurs
if
all three characters are the same. The beeping sound
is
used
to
help simulate motion
in the slot machine. If you don't win, you can press
CEtITE:ID
to
play again. When a
win occurs a siren will sound and
"W
I
N"
will flash on the slot machine.
Line
18 The time is used
to
initialize the sequence
of
random numbers.
Line
28 This statement clears the display.
Line
38 The outline of the slot machine is drawn
as
a box using the LINE statement.
Lines
40-60 The three windows are drawn
as
boxes using the LINE statement.
Line
78 A FOR / NEXT loop
is
used
to
control the duration of the spinning of the
slot machine wheels. The upper limit of
30 was determined
by
trial and error. A larger
value would increase the duration and a smaller value decrease it.
Line
88 A brief tone is generated to suggest rotation
of
the wheel. Again the
parameters were chosen by trial and error to create a reasonable sound.
Lines
98-118 The characters with ASCII values, 145, 146 and
147
were chosen to be
the display characters because they have contiguous ASCII values and they look
interesting. These three characters are generated at random
with the CHR$ function
CHR$(145
+ 3 *
RND(l»
Since the argument of the CHR$
is
truncated to an integer value, this function will
return one of the three characters
152