Rockets: the original code

Written in QBasic in 1995 by Graeme and his son Chris, aged 8, and typed up from the printouts. This is the first version, with adding only. (The exact number of spaces in a few lines is our best guess.) Play Rocketsor download rockets.bas.

REM ************************************************************************
REM                                 ROCKETS
REM ************************************************************************
REM
REM     This is a maths programme.  Maths questions rise up the screen
REM     and the player has to answer them before they hit the top.
REM     As the game procededs the questions rise faster.  The game ends when
REM     the player answers 10 questions incorrectly.
REM
REM ************************************************************************
REM
REM     VARIABLES
REM
REM     n       A temporary variable
REM     q1      First random number used in question
REM     q2      Second random number used in question
REM     a       Correct answer
REM     a10     Correct answer (tens)
REM     a1      Correct answer (units)
REM     a$      Player's answer
REM     name$   Player's name
REM     bn      Biggest number in question
REM     speed   The speed at which questions rise
REM     score   Player's score
REM     lives   Player's lives (starts with 10)
REM     moves   Distance question has travelled up the screen
REM     correct Number of correct answers since last speed change
REM     wrong   An array containing details of wrong answers
REM
REM ************************************************************************
REM
REM     INITIATE PROGRAMME
REM     Dimension arrays, and set screen type.
DIM wrong(3, 10) AS INTEGER
SCREEN 0
REM
REM ************************************************************************
REM
10      REM     INITIATE PLAYER
REM     Print title screen, and obtain player details.
CLS
CLEAR
PRINT "                             WELCOME TO ROCKETS"
PRINT
PRINT
PRINT
INPUT "What is your name"; name$
PRINT
PRINT "Hello "; name$; ".  "
PRINT
INPUT "What is the biggest number you want to add (2-9)"; bn
bn = INT(bn)
IF bn < 2 THEN bn = 9
IF bn > 9 THEN bn = 9
REM
REM ************************************************************************
REM
20      REM     INITIATE GAME
REM     Getting ready to start a new game.
score = 0
lives = 10
correct = 0
ERASE wrong
PRINT
INPUT "At what speed do you want to start"; speed
speed = INT(speed)
IF speed < 1 THEN speed = 1
IF speed > 10 THEN speed = 10
CLS
PRINT "Press any key to start the game."
DO
LOOP UNTIL INKEY$ <> ""
CLS
REM
REM ************************************************************************
REM
30      REM     ASK A QUESTION
REM     Choose two random numbers and print the question on the screen.
CLS
moves = 0
q1 = INT(RND * (bn + 1))
q2 = INT(RND * (bn + 1))
a = q1 + q2
a10 = INT(a / 10)
a1 = a - (a10 * 10)
FOR n = 1 TO 22
PRINT
NEXT n
PRINT speed; "  ";
FOR n = 1 TO lives
PRINT CHR$(3);
NEXT n
FOR n = (lives + 1) TO 10
PRINT CHR$(46);
NEXT n
PRINT "                                                  score: "; score
PRINT
PRINT
PRINT "                                    "; q1; " + "; q2; " ="
REM
REM ************************************************************************
REM
40      REM     WAIT FOR AN ANSWER
REM     The question rises up the screen as the computer waits for
REM     an answer.
moves = moves + 1
IF moves = 21 THEN GOTO 60
FOR n = 1 TO (100 + 200 * (10 - speed))
a$ = INKEY$
IF a$ <> "" THEN GOSUB 42
NEXT n
IF speed = 10 GOTO 41
PRINT
GOTO 40
41 PRINT "                                    "; q1; " + "; q2; " ="
GOTO 40
42 IF a10 = 0 THEN GOTO 43
IF a$ <> CHR$(a10 + 48) THEN GOTO 60
a10 = 0
RETURN
43 IF a$ <> CHR$(a1 + 48) THEN GOTO 60
GOTO 50
REM
REM ************************************************************************
REM
50      REM     CORRECT ANSWER
REM     The player's answer is correct.
REM     Increase the score.
REM     If there have been 10 correct answers, increase the speed.
BEEP
score = score + (speed * (bn + 1))
correct = correct + 1
IF correct < 10 THEN GOTO 30
correct = 0
IF speed = 10 THEN GOTO 30
speed = speed + 1
BEEP
BEEP
BEEP
BEEP
BEEP
GOTO 30
REM
REM ************************************************************************
REM
60      REM     WRONG ANSWER
REM     The player's answer is wrong.
REM     If there have been 10 incorrect answers, end the game.
CLS
wrong(1, 11 - lives) = q1
wrong(2, 11 - lives) = q2
wrong(3, 11 - lives) = speed
FOR n = 1 TO 2000
NEXT n
a$ = INKEY$
a$ = INKEY$
lives = lives - 1
IF lives = 0 THEN GOTO 70
GOTO 30
REM
REM ************************************************************************
REM
70      REM     END OF GAME
CLS
FOR n = 1 TO 4000
NEXT n
a$ = INKEY$
a$ = INKEY$
PRINT "Well done "; name$; "."
PRINT
PRINT "Your final score was "; score
PRINT
PRINT "**********************************************"
PRINT
PRINT "You added numbers up to "; bn
PRINT
PRINT "You got the following questions wrong:"
PRINT
FOR n = 1 TO 10
PRINT wrong(1, n); " + "; wrong(2, n); "     at speed "; wrong(3, n)
NEXT n
PRINT
PRINT
INPUT "Do you want to print a certificate (Y/N)"; a$
IF a$ = "Y" OR a$ = "y" THEN GOTO 80
GOTO 90
REM
REM ************************************************************************
REM
80      REM     PRINT CERTIFICATE
REM
LPRINT "Well done "; name$; "."
LPRINT
LPRINT "Your final score was "; score
LPRINT
LPRINT "**********************************************"
LPRINT
LPRINT "You added numbers up to "; bn
LPRINT
LPRINT "You got the following questions wrong:"
LPRINT
FOR n = 1 TO 10
LPRINT wrong(1, n); " + "; wrong(2, n); "     at speed "; wrong(3, n)
NEXT n
LPRINT
LPRINT
REM
REM ************************************************************************
REM
90      REM     ANOTHER GAME?
CLS
INPUT "Do you want another game (Y/N)"; a$
IF a$ = "Y" OR a$ = "y" THEN GOTO 20
PRINT
INPUT "Does another player want to play (Y/N)"; a$
IF a$ = "Y" OR a$ = "y" THEN GOTO 10
CHAIN "jac_menu.bas"