Classic Computer Magazine Archive COMPUTE! ISSUE 26 / JULY 1982 / PAGE 84

Answer Selection With Joysticks

Stephen Levy
Bowie, MD

With versions for the VIC and Atari computers, this program illustrates how to make games and learning programs easy for preschoolers to use.

One of my major objectives in purchasing a computer was to create educational programs for my young son. Realizing that a preschool child might have difficulty using the keyboard, I decided that using the joystick to input responses was the answer. Not that learning to use the keyboard is not important, but if that is not the purpose of the program, it might get in the way and cause frustration.

Al Baker's two articles in COMPUTE!'s First Book Of Atari gave me ideas and the little extra push I needed.

The purpose of this educational program is to give a young child practice in deciding which of four words is different from the other three on the screen. The child uses the joystick to make his selection and is allowed as many tries as needed. Once the correct response is picked, a short explanation appears and the child can then decide whether to do another problem or to end the program. All this is done with the joystick.

The program is very straightforward. All data for problems are in lines 20 to 199, with even-numbered lines containing the words and explanations in the odd-numbered lines. I have included only four series of words (lines 20,22,24,26) so that the reader may add his own. You must adjust line 220 to equal the number of even-numbered data lines (total series of words); in my example there are only four.

example : 220 Q = INT(RND(0) * A) + 10 : RESTORE Q * 2 where A equals the number of problems.

Lines 210-215 randomly select the background colors.

Since my purpose is to demonstrate the use of the joystick in an educational program, I have not added any graphic displays, but I would suggest "dressing up" the program for use with young children in order to maintain their interest. Below is an explanation of the program by line.

Lines
5-10 Initialization
20-27 Data for questions.
28-199 To be used for additional data for questions. Data placed as follows:
Four choices, then joystick position of correct answer. In the order that they appear in data line. If the first answer is correct then the number should be, 14; second, 11; third, 7; fourth, 13.
200 Sets mode and turns off cursor.
210-215 Randomly selects background color and print.
220 Randomly selects data to be used. The number multiplied by RND(0) should be equal to the number of questions.
230-270 Reads data and positions words on screen.
300-350 Positions @ symbol in the direction of users answer.
360 Checks for correct answer.
385-390 Clerks @ from incorrect answer.
395 Gives user another try at the same question.
400-420 Reads and prints explanations on screen.
440-470 Gives user the option of another problem.

Program 1. Atari Version.

1 REM D : JOYSTICK
2 REM STEPHEN LEVY
3 REM 3511 MORLOCK LN, BOWIE, MD. 20715
4 REM 301-464-2052
5 DIM Q1$(20), Q2$(20), Q3$(20), Q4$(20), E$(40), B$(1), C$(1), CLEAR$(1)
10 B$ = " " : CLEAR$ = CHR$(125) : C$ = "@"
15 GOTO 200
20 DATA APPLE, PEAR, HAT, ORANGE, 7
21 DATA HAT IS NOT A FRUIT
22 DATA A, E, I, S, 13
23 DATA ‘S’ IS NOT A VOWEL
24 DATA BLUE, GREEN, RED, SAD, 13
25 DATA THESE WORDS ARE COLORS
26 DATA APE, APPLE, ATE, FUN, 13
27 DATA THESE WORDS BEGIN WITH ‘A’
200 GRAPHICS 2 : POKE 752, 1
210 C = RND(0) * 16 : SETCOLOR 1, 9, 2 : SETCOLOR 4, C, 8 : SETCOLOR 2, 11, 8
215 SETCOLOR 0, C, 1
220 Q = INT(RND(0) * 4) + 10 : RESTORE Q * 2
230 READ Q1$, Q2$, Q3$, Q4$, A
240 POSITION 10 - INT((LEN(Q1$))/2), 1 : PRINT #6; Q1$
250 POSITION 10 - INT((LEN(Q4))/2), 9 : PRINT #6 ; Q4$
260 POSITION 14, 5 : PRINT #6 ; Q3$
270 POSITION 7 - LEN(Q2$), 5 : PRINT #6 ; Q2$
280 PRINT : PRINT : PRINT "PUSH STICK IN THE DIRECTION OF"290 PRINT : PRINT" CORRECT ANSWER."
300 IF STICK(0) = 15 THEN POSITION 10, 5 : PRINT #6; C$ : GOTO 300
310 IF STICK(0)<> 15 THEN POSITION 10, 5 : PRINT #6; B$
315 SOUND 0, 90, 10,1 0 : FOR S1 = 1 TO 20 : NEXT S1
320 IF STICK(0) = 14 THEN POSITION 10, 3 : PRINT #6; C$
330 IF STICK(0) = 11 THEN POSITION 8, 5 : PRINT #6; C$
335 SOUND 0, 60, 10, 8 : FOR S1 = 1 TO 20 : NEXT S1
340 IF STICK(0) = 7 THEN POSITION 12, 5 : PRINT #6; C$
345 SOUND 0, 0, 0, 0
350 IF STICK (0) = 13 THEN POSITION 10, 7 : PRINT #6; C$
360 IF STICK (0) = A THEN GOTO 400
370 PRINT CLEAR$ : PRINT : PRINT "PLEASE TRY ANOTHER ANSWER"
372 FOR X = 1 TO 100 : NEXT X
375 FOR S1 = 1 TO 150 : SOUND 0, 200, 10, 8 : NEXT S1
380 FOR S1 = 1 TO 100: SOUND 0, 230, 10, 8 : NEXT S1
381 SOUND 0, 0, 0, 0
385 FOR X = 3 TO 7 STEP 4 : POSITION 10, X : PRINT #6; B$ : NEXT X
390 POSITION 8, 5 : PRINT #6; B$ : POSITION 12, 5 : PRINT #6; B$
395 GOTO 280
400 RESTORE (Q*2) + 1
410 READ E$
420 PRINT CLEAR$; "GOOD, "; E$
425 FOR S2 = 1 TO 70 : S3 = INT (RND(0)*50) + 50 : SOUND 0, S3, 10, 8 : FOR S1 = 1 TO 7 : NEXT S1
427 SOUND 0, 0, 0, 0 : NEXT S2
440 PRINT : PRINT "PRESS BUTTON FOR ANOTHER PROBLEM"
450 PRINT : PRINT " PUSH STICK TO END"
460 IF STRIG(0) = 0 THEN GOTO 200
470 IF STICK(0) = 15 THEN GOTO 460
480 PRINT : PRINT : PRINT " GAME OVER"
490 FOR X = 1 TO 1000 : NEXT X
500 GRAPHICS 0

Program 2: VIC Version

10 DD = 37154 : P1 = 37151 : P2 = 37152
15 GOTO 200
20 DATA APPLE, PEAR, HAT, ORANGE, 1
21 DATA HAT IS NOT A FRUIT
22 DATA A, E, I, S, 2
23 DATA ‘S’ IS NOT A VOWEL
24 DATA SAD, BLUE, GREEN, RED,-2
25 DATA THESE WORDS ARE COLORS
26 DATA APE, FUN, ATE, APPLE, -1
27 DATA THESE WORDS BEGIN WITH ‘A’
200 PRINT"{CLEAR}"
210 Q = INT (4*RND(1)+1)
220 RESTORE
230 FOR I = 1 TO Q
240 READ Q1$, Q2$, Q3$, Q4$, A, AN$
250 NEXT
260 PRINT"{RED}";TAB (11-LEN(Q1$)/2);Q1$;"{05 DOWN}"
270 PRINT"{GRN} "TAB (11-LEN(Q4$)/2);Q4$;"{04 UP}"
280 PRINTTAB (14);"{PUR}"Q3$
290 PRINT"{UP} {CYN}"TAB (7-LEN (Q2$)); Q2$; "{B BLU} "
300 PRINT "{04 DOWN} PUSH STICK IN" : PRINT "DIRECTION OF THE"
310 PRINT" CORRECT ANSWER
320 PRINT" {HOME} {04 DOWN}"; TAB (10); "Q"
330 GOSUB 500 : IF H = 0 AND V = 0 THEN 330
340 PRINT" {HOME} {04 DOWN}" TAB (10); " "
350 PRINT" {HOME} {03 DOWN}"; LEFT$ (" {02 DOWN} ", 1 + V); TAB (10 + H); "Q"
360 IF (V*2 + H) = A THEN 400
370 PRINT " {CLEAR} PLEASE TRY AGAIN"
380 GOTO 220
400 PRINT" {07 DOWN}" : PRINT" {REV} GOOD, "; AN$
410 PRINT : PRINT
415 GOSUB 500 : IF (V*2 + H) = ATHEN 415
420 PRINT" {DOWN} PUSH STICK FOR ANOTHERPROBLEM"
430 PRINT" PUSH {RED} BUTTON {BLU} TO END"
440 GOSUB 500 : IF (HORV) THEN 200
450 IF FB = 0 THEN 440
460 PRINT" {DOWN] GAME OVER"
499 END
500 REM JOYSTICK SUB
510 POKEDD, 127 : P = PEEK (P2) AND 128
520 H = -(P = 0)
530 POKEDD, 255 : P = PEEK (P1)
540 V = - ((PAND8) = 0)
550 H = - ((PAND16) = 0) +H
560 V = ((PAND4) = 0) + V
570 FB = -((PAND32) = 0)
580 RETURN