Skip to content

Instantly share code, notes, and snippets.

@tomaes
Last active March 25, 2021 08:21
Show Gist options
  • Save tomaes/5cb1e51b56cc9292713c8e8c227c02f6 to your computer and use it in GitHub Desktop.
Save tomaes/5cb1e51b56cc9292713c8e8c227c02f6 to your computer and use it in GitHub Desktop.
BBC micro test game; random 2nd grader arithmetic at devilish velocity.
AUTO 10, 10
REM MICRO GAME FOR THE BBC MICRO
MODE 7
PRINT CHR$(141); CHR$(134); "MATH HASTE": REM 2X HEIGHT (top), cyan
PRINT CHR$(141); CHR$(130); "METH HESTE": REM 2X HEIGHT (bottom), green
DIM Q(6): DIM Q$(6): D = 2: R = 0
Q$(1) = "A=B": Q$(2) = "A<>B"
Q$(3) = "A>B": Q$(4) = "B>A"
Q$(5) = "A<B": Q$(6) = "B<A"
A = RND(11)-6
B = RND(11)-6
PRINT "A="; A; ", B="; B
PRINT "BE READY IN 3 SECONDS!"
REM C-F-G-A JINGLE
SOUND 1,-9, 53, 4
SOUND 1,-9, 73, 3
SOUND 1,-9, 81, 4
SOUND 1,-9, 89, 8
A$ = INKEY$(300)
REPEAT
IF RND(10)<D THEN PRINT "A=A+B": A = A+B
IF RND(10)<D THEN PRINT "A=A-B": A = A-B
IF RND(10)<D THEN PRINT "B=A+B": B = A+B
IF RND(10)<D THEN PRINT "B=A-B": B = A-B
IF RND(10)<D THEN PRINT "B=A": B = A
IF RND(10)<D THEN PRINT "A=B": A = B
IF RND(10)<D THEN PRINT "B=-A": B = -A
IF RND(10)<D THEN PRINT "A=-B": A = -B
IF RND(10)<D THEN PRINT "A=-A": A = -A
IF RND(10)<D THEN PRINT "B=-B": B = -B
IF RND(10)<D THEN C = RND(11)-6: A = A+C: PRINT "A=A+"; C
IF RND(10)<D THEN C = RND(11)-6: A = A-C: PRINT "A=A-"; C
Q(1) = (A=B): Q(2) = (A<>B)
Q(3) = (A>B): Q(4) = (B>A)
Q(5) = (A<B): Q(6) = (B<A)
P = RND(6)
R = R+1
SOUND 1,-9, 21, 1
PRINT CHR$(93); "IS "; Q$(P); "? (Y/N) ";
T = TIME
REPEAT
A$ = INKEY$(0)
TNO = ((TIME-T)>(1000-R*5))
UNTIL A$<>"" OR TNO
PRINT A$; " ";
NIN = (A$<>"Y" AND A$<>"N")
BRK = NOT(Q(P) AND A$= "Y") AND NOT((NOT Q(P)) AND A$="N")
PRINT ">";
BL$ = CHR$(136): REM BLINKING CHARS
IF NOT BRK THEN PRINT " OK!": SOUND 1,-9, 100, 2
IF A$="" THEN PRINT BL$; "TIMEOUT"
IF NIN AND A$<>"" THEN PRINT BL$; "WRONG KEY"
IF BRK AND (NOT NIN) AND (NOT TNO) THEN PRINT BL$; "MISTAKE!"
UNTIL BRK
SOUND 1,-9, 41, 8
SOUND 1,-9, 5, 8
PRINT "A="; A; ", B="; B
PRINT "ROUNDS:"; R
PRINT "RATING:";
RAT = (R DIV 2) AND 3
FOR I=1 TO RAT: PRINT "*";: NEXT
PRINT
PRINT "GAME OVER!"
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment