[go: up one dir, main page]

100% found this document useful (1 vote)
141 views132 pages

Computer Games To Play and Write

- Dan Isaaman wrote two books of computer games while studying for his A-levels in maths, physics, chemistry, and further maths. - He then took a year off between school and university to write software for several large computer firms. - The document appears to be from a book authored by Dan Isaaman containing 17 computer games designed to be played on various home computers from the 1980s, including the ZX Spectrum, BBC, Electron, VIC, and Dragon. The book provides instructions on how to type in and play the games.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
141 views132 pages

Computer Games To Play and Write

- Dan Isaaman wrote two books of computer games while studying for his A-levels in maths, physics, chemistry, and further maths. - He then took a year off between school and university to write software for several large computer firms. - The document appears to be from a book authored by Dan Isaaman containing 17 computer games designed to be played on various home computers from the 1980s, including the ZX Spectrum, BBC, Electron, VIC, and Dragon. The book provides instructions on how to type in and play the games.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 132

COMPUTER GAMES

to play and write


Dan Isaaman is currently studying Computer
Engineering at Manchester University. He attended
University College School in Hampstead and has been
involved with computers ever since he was given a kit
to build one at the age of fourteen.
While studying for 'A' levels in Maths, Further Maths,
Physics and Chemistry, he wrote two books of computer
gar:nes for Usborne. In his year off between school and
university he wrote software for several large computer
firms.
-------------. . .

DAN ISAAMAN

t pl e
for use with ZJ(-Spectrum, BBC, Electron, VIC
and Dragon computers
A Sparrow Book
Published by Arrow Books Limited
17-2 1 Conway Street . Londo n WIP 6JD

An imprir1fof the Hutchinson Publishing G ro up

Londo n Melbourne Sydney Auckldnd


Johannesburg a nd agencies througho ut the wo rld

Fi rs t pu blished 1983
Re printcd 1984
© Dan 1saama n 1983
Illustratio ns © Sparrow Books 1983
This book is sold subject to the cond it ion thai it :;hall
no t. by way o f trade or othe rwise. be lent resold .
hired o ut , or o th e rwi se circulat ed with o ut the
publisher's prior consent in any form of binding or
cover other than that in which it is published and
without a similar conditio n including thi ~ cOl1dition
being imposed on the suOseque nt purchaser

Designed by Roger WalkerfPaul Rogers

Sct in Compugraphie Congress


by Angus Graham A s~ociates Ltd

Made and printed in G reat Britain


by the Guernsey Press Co Ltd
Gue rnsey. c. 1.

ISB N 0 09 33330 9
I would like to thank Eleanor Nabney, without whom
the programs in this book would not have been tested
so thoroughly, and many would not e~en exist. I would
also like to thank my trusty EPSON QX·' a computer,
on which most of this book was written and printed,
and my mother, who had to put up with the computers
all over the house. Thanks are also due to Sinclair
Research and Dragon Data for the loan of their
computers.
To Eleanor
with love
CONTENTS

Foreword 9
Notes for using the book 11
Summary of instructions 15
Game 1: Christmas Time 17
Game 2: Red Alert! 21
Game 3: Spy Codes 24
Game 4: Ring-a-Ring O'Robot 30
Game 5: Nim 33
Game 6: From the Depths of Time 37
Game 7: Galaxy Hitch-hike 41
Game 8: planet Lander 44
Game 9: Animal 49
Game 10: Silo Raid 53
Game 11: Haunted House 58
Game 12: Escape 62
Game 13: Space Dogfight 66
Game 14: Death Raid 70
Game 15: Cowboys and Indians (ZX-Spectrum) 75
Game 16: Cowboys and Indians (VIC) 80
Game 17: Cowboys and Indians (BBC/Electron) 85
Game 18: Cowboys and Indians (Dragon) 91
How to write your own program: Sabotage 96
BASIC and its commands 105
Glossary 112
Appendix 126
FOREWORD 9

I had great fun creating the games in this book. Some are games of
skill, such as Haunted House and Planet Lander; others are mind·
stretchers, such as Christmas Time and Nim; all, I hope, will provide
you with hours of entertainment as you pit your wits against your
computer. The games are designed to be used on five different
computers, but at the end of the book you will find a supergame
created especially for your machine.
Having played all the games in this book you may feel tempted
to write some games yourself- Throughout the text I have put in
tips and explanations on the computers and programs. There are
also full explanations of what the program is doing line by line, and
suggestions for ways in which you can change and adapt the
games.
I do hope this book manages to fire your imagination and induce
lots of midnight sessions at the computer, and I hope everyone
ends up creating games that are at least as good as the ones in this
book.
Happy computing'

Dan Isaaman
r
NOTES FOR USING THE BOOK ,,
The purpose of this book is to provide you with exciting games to
play on your computer. In the course of playing the games you will
find that your skills and knowledge of programming increase. I
hope that you may be inspired to write your own games.
The book is designed for use with five computers:
BBC
Dragon
Electron
VIC
zx·Spectrum
There are slight differences in the way the BASIC language inside
each of these computers works. Because of this, the programs have
changes in some lines depending on which computer you are using.
There are two areas of change:
1. At the end of each program you will see that there is a section
written specially for your computer. When you get to this
section, pick out the box that holds the lines for your computer
and type only these lines into your computer.
2. Lines in the earlier part of the program sometimes need
changing too. When this happens the lines are printed in green.
A letter in the left-hand margin indicates which line you should
type in. The letters are as follows:
b BBC and Electron
5 ZX-Spectrum
d Dragon
v VI C
When you see these letters in the margin, type in only the line that
has the letter corresponding to your computer against it. For
instance, suppose you see the lines:
~d 90 IF H$(Q)()" THEN GOTO 80
5 90 IF HS Q,1l0 THEN GOTO SO
If you own a ZX-Spectrum, then you should type in line 90 as:
90 IF H'(Q,l)()' , THEN aOTO 80
12 NOTES FOR USING THE BOOK
If you own a BBC, Dragon, Electron, or VIC you should type line 90
in as:
90 IF H$(Q)<>" THEN GOTO 80
The programs in this book are written in BASIC. A section at the
back of the book explains how this language works. Once you
know this language you can use it to write simple programs and
games. The game Sabotage shows you how you can create a
game.
To type in and playa game, the first thing you must do is get
your computer ready. Plug the computer and the television or
monitor screen into the mains and connect them using the cable
provided with your computer. Switch them on.
You are now ready to type in a program. The computer knows
that you are typing in a program when each line that you type
begins with a number. The computer sorts the individual lines into
a program, with the lines appearing in numerical order. If you look
at the programs in this book you will see that the line numbers
usually go up in steps of ten. Programs are written in this way so
that if there are any extra instructions to be added this can be done
using the line numbers that are still available between those
already used.
When you are typing in the program, be very careful to get it
exactly right. Type in each line one by one, starting with the line
number and finishing by pressing the RETURN or ENTER key. Make
sure that the commas, semicolons, spaces and confusing letters
and numbers such as a and 0 are typed in exactly as they are in
the book.
If you have a tape recorder or disc drive connected to your
computer, you can store the game program on tape or disc. If you
do this, you will of course only need to type in a game program
once, and you can load it back from tape or disc whenever you
want. Look up the commands SAVE and LOAD in the manual for all
the computers except Dragon. For Dragon look up CSAVE and
CLOAD. This section will tell you how to give the program a name
NOTES FOR USING THE BOOK 13

on disc or tape so that you can load it back into the computer at
any time.
Note that with some tape recorders it may take a little time to
adjust the recorder and the computer to achieve accurate program
storage. Your computer manual should provide full details.
Once you have typed in the program, read the scenario above
the game that tells you what you must do once the game has
started. Then type the command RUN into the computer. This is a
direct command to the computer so it does not need a line number.
Then press the RETURN or ENTER key and the computer will start
the game.
The game should now work perfectly. If it does not, the computer
will usually tell you immediately by stopping the program and
displaying an error such as:
SYNTAX ERROR IN LINE 120
Alternatively, it may be that the computer just does not behave as
you expect. In either case you will have caused a bug (error) in the
program by typing in an instruction incorrectly. You must go
through the program checking every single line against every single
line of the program listed in this book. To get the program
displayed on the screen you use the UST command.
For example for the BBC and Electron,
LIST 10,200
will list lines 10 to 200.
For Dragon and VIC,
LIST 10-200
will list lines 10 to 200.
For ZX·Spectrum,
LIST 10
will list the program to the bottom of the screen.
r

14 NOTES FOR USING THE BOOK


The question Scroll? then appears. If you type in Y the listing will
continue. If you type in N it will stop.
When you have found the mistake, type in your correction. The
simplest way to change a line is to retype it, beginning with the line
number. This automatically wipes out the previous version of the
line. If you want to delete a line, type the line number immediately
followed by the RETURN or ENTER key. You can use LIST at any
time to check your corrections.
Once you have corrected your mistake, type RUN to start the
game as before. Remember - if you have already saved the
program on casette or disc you must now replace it with the
corrected version.
At the end of each game I have suggested changes that you
might like to put into the program. To make these changes to the
games, type in the new lines just as you did the old. If you type in a
line with a line number that is already in the program, the
computer will simply replace the old line with your new one. If you
wish to delete a line in the program, then, as before, just type in its
line number immediately followed by the RETURN or ENTER key.
Read how to edit your program in the computer manual, so that
you can make the changes quickly.
SUMMARY OF INSIRUCTIONS 15

When typing in the games, you should always remember the


following things:
1. Type each line exactly as it is printed in this book. Start with the
line number and press the RETURN or ENTER key at the end of
the line.
2. Make sure you type in the correct lines for your particular
computer where there is a chOice. when two or more lines are in
green, with letters against them in the margin, you must type in
only one. The indicator symbols and the corresponding
computers are as follows:
b BBC and Electron
5 IX-S pectrum
d Drago n
v VIC
3. At the end of the program, type in the lines from the ruled box
applicable to your computer.
4. Once you have typed in the program, you can store it if you
have a tape recorder or disc drive. Then type RUN to start the
game.
5. If the program does not work properly, LIST it and go through it,
checking it against the listing in this book. Check every line for
typing mistakes. Usually you will find that things like commas,
semicolons, spaces and confusing letters and numbers such as
o and 0 have been typed wrongly.
- - - - - - - - - - - --

1 : CHRISTMAS TIME 17

You are Father Christmas and you're in trouble. It is Christmas Eve


and you have a large bag of wonderful presents to deliver to the
children living in Muddlesome Street. But each parcel is only
labelled with the family surname and not with their address.
There are ten houses in the street and ten presents in the bag.
When you bring out a parcel you must choose which chimney to go
down. Once you're down the chimney you're able to find out whose
house it is and, if it is the wrong one, how far away the right house
is. You must memorize this information. Dawn is approaching and
if you can't sort the muddle out by then, you will surely tum into a
reindeer.
10 60SUB 1000 : 60SUB 2000
20 PRINT "CHRISTMAS TIME"
30 PRINT
40 LET N;10 : LET L;O
vbd 5 0 ~ll'l H$ ( N )
5 SO DI I'I H$ (N,1 0)
60 FOR I; 1 TO N . .- #
70 READ P$ ra
80 LET Q=FNR(N)
vbd 90 IF Hf(Ql THEN GO TO 80
II "

90 IF Hf(Q , I! THEN 60TO 80 ~


5
100 LET Ht(Q);P$
110 NEXT I
e-
120 FOR 6=1 TO N*2 . .- #
130 LET Q;FNR(N) ra
~d l4u IF hIIQ);"" THEN GOT" 1~
5 141i IF HfIQ,ll=" " THEN GOTO 13(1
150 PRINT "THE LABEL SAYS: ";H$(Q)
160 PRINT "HOUSE NUMBER " ;
vbd 1 70 INPUT Z
s 1""71 INF'U ,• : PRI - L
T

18 0 IF Z<l OR Z>N THEN GOTO 160


vbd I" L E~
DELl.EREO 0 l ENE GOTe 25

111111111111111111111
18 CHRISTMAS TIME
5 19, IF 1$11,11=" TMEN pOIF fDU ALREADY
DELI 'ERED 0 ~E ERE": 60-0 250
200 IF Z<> Q THEN GOTo 230
210 PRINT "PRESENT DELIVERED"
220 LET L=L+l : LET H$IQ)="" : GoTO 250
230 PRINT "THIS HOUSE BELONGS TO ";HIIZ)
240 PRINT "THE PERSON YOU WANT IS "; ABS IZ-O);
" DOORS AWAY."
250 IF L=N THEN GOTO 290
260 NEXT G
270 PRINT "YOUR TIME RAN OUT. YOU TURNED INTO
A REINDEER!"
280 GOTO 4000
290 PRINT "YOU DELIVERED THEM ALL IN ";G;
" GOES, WELL DONE"
300 GoTO 4000
310 DATA "SMITH","JONES","BLOGGS","WILSON"
320 DATA "MILLER","ENGLAND","EDWARDS" •
330 DATA "O ' BRIEN", "CLARKE", "GROT" ....
For the different computers
-----=--------~

1000 DEF FNRIX)=RNDIX) 1000 DEF FNRIX)=RNDIX)


1010 RETURN I
1010 RETURN
2000 CLS : RETURN 2000 CLS : RETURN
3000 LET I$=INKEY$II) 3000 LET I$=INKEY$
3010 RETURN 3010 RETURN
4000 END , ~ END
::::........:===--==:::; ~r.:'!'I
1000 DEF FNR(x) 1000 DEF FNRIXI
=INTIRNDII)*X+I) =INTIRND*X+I)
10 I I) RETURN 1010 RETURN
2000 PRINT CHR$(147); 2000 CLS : RETURN
: RETURN 3000 LET I$=INKEH
3000 GET It 3010 RETURN
O STOP
30 10 RETURN
4000 END
L
CHRISTMAS TIME 19

How the program works:


Lines 10-30 clear the screen and print out the
title.
Line 40 sets t he number of houses to 10 (in N),
the number of presents delivered to zero ( in
U.
Lin. 50 sets up an arra y for the names of the
famil y in each hou s e.
Lin •• 60-110 randoml y put all the famil y names
(in lines 31 0- 330) i nto the arra y H$.
Lin. 120 is the start of the loop giving you 20
goes ( with 10 houses in the road ) .
Lin.. 130-140 choose a random name for the
parcel, and chec k that it hasn · t already been
dellvered.
Lin. 150 prints a message telling you which name
is on the parcel.
Lin.. 160-180 get your chosen house number and
check that it is allowed.
Line 190 chec ks if there is alread y a present
there.
Line. 200-220 chec k If you got the house number
right, and if so, tell YOu; increase your
score and delete the family name to show that
the present has been delivered.
Lines 230-240 tell you whose house you have
chosen and how far away the right one is.
Line 250 checks whether all the presents have
been delivered, and if 50, goes to 290.
Line 260 is the end of the loop giVIng you 20
goes .
• Lin •• 270-280 print a message if you didn · t
deliver all the presents in time, and stop the
program.
Lin. 290-300 print a message if you managed to
deliver all the presents in time, and stop the
program.
20 CHRISfMAS TIME
Lines 310-330 hold the names of the families in
the street.
Lin •• 1000-4000 contain the standard routines.

Changes you can make:


1) To make the game a bit harder, you can
get the computer to clear the screen after
each go, so that you can ' t look back over
your last few goes. To do this, add a new
line at 125 to clear the screen:

125 BOSU8 2000

and add a delay (so that you can read the


details about the house before they
disappear) at line 255:

255 FOR lot TO 2000 I NEXT

2) You can change the people ' s names by


changing the strings in lines 310-330, and
if you want to add more, add an extra DATA
line after 330, with your extra names in
quotes, sepatated by commas, and increase
the number in line 40 from 10 to however
many people you have.
2: RED ALERT! 21

The alarm in an underground atomic centre full of top security


weapons has been set off aCCidentally. You have to discover the
code to the lock on a door to get in to switch off the alarm system.
If the alarm is not turned off quickly the whole complex with all its
scientists and valuable eqUipment will be automatically sealed
underground forever. You have only time for ten attempts at the
two·digit code before the auto-sealing device is activated.
On each go you may move the combination lock a certain
number of positions to the left or right. The dial has ten numbers on
either side of the central zero_ Your equipment can detect whether
you have moved the dial past the correct number, because a louder
click will be heard. Good luck!
10 GOSUE 1000 : GOSUE 2000
20 PRINT "RED ALERT"
30 PRINT
40 LET G-O : LET GI-IO
50 FOR I-I TO 2
60 LET P-FNR(21)-11
70 LET Pl-Q
80 PRINT "NO. TO TURN ILEFT IS -,RIGHT IS +) "
90 INPUT T
100 IF AESIT+PI l> IO OR T-O THEN GOTO 90
110 FOR J-I TO ASSIT)
120 PRINT "CLICK ... "; : NEXT J : PRINT
130 LET PI-PI+T
140 IF P-PI THEN GOTD 200
150 IF SGNIPI-P-T)-SGNIPI-PI THEN GoTO 170
160 PRINT "I THINK ONE CLICK WAS LOUDER"
170 LET G-8+1 : IF G( GI THEN GoTO 80
180 PRINT "YOU HAVE BEEN BLOWN UP"
190 GOTO 4000
200 PRINT "CLUNK ... YOU GOT IT'"
210 NEXT I
220 PRINT "WELL DONE. YOU CRACKED
IT IN TI ME ' "
230 GoTo 4000
22 RED ALERT!
For the different computers
r---~==~----------
, rag
1000 DEF FNR(X)=RND(x) 1000 DEF FNR(X)=RND(X)
10 I 0 RETURN 1010 RETURN
2000 CLS : RETURN 2000 CLS : RETURN
3000 LET U=INKEYS(I) 3000 LET 1$= I NKEY$
3010 RETURN 3010 RETURN
4000 END 4000 END

1000 DEF FNRiX)


=INT(RND(U*X+I) =INT(RND*X+I)
10 I 0 RETURN 1010 RETURN
2000 PRINT CHR$ (1471; 2000 CLS : RETURN
: RETURN 3000 LET I$=INKEY$
3000 GET l$ 3010 RETURN
3010 RETURN 4000 STOP
4000 END

How the program works:


Lin •• 10-30 clear the screen and print the title
of the game.
Line 40 sets G (your current number of tries) to
zero, and GI (the maximum number of tries) to
ten.
Line ~O sets up the loop giving you two
positions on the dial to solve.
Lin. 60 chooses a random position from -10 to
10 and saves it in P.
Lin. 70 sets your current position (in PI) to
zero (ie the centre of the dial).
Lines 80-90 ask the player how much he wants to
turn the dial, and gets the answer in T.
Line 100 if this is out of range, then asks
again.
Lines 110-120 print out 'CLICK ••. ' that many
number of times.
RED ALERT! 23

Lin& 130 sets your new position in Pl.


Line 140 checks whether you have got the right
position and if 50, goes to 200, which prints
a message and repeats the loop.
Lines 150-160 check whether you passed the
correct position while turning, and if so
print a message.
Line 170 increases the count of the number of
goes that you have had, and if you haven't
finished, goes back for another try.
Lines 180-190 print a message if you ran out of
tries, and stop the program.
Lines 200-210 print a message and loop back to
give you the next position on the dial.
Lines 220-230 print a message if you managed to
crack the combination, and stop then program.
Lines 1000-4000 contain the standard routines.

Changes you can make:

I) At the moment, the combination lock has


a two-digit combination number, and for each
digit, you always start at position zero
(the centre of the dial). You can add more
digits to the number by changing the number
2 in line 50 to a higher number, and if you
need to, changing the number of goes allowed
in line 40.

2) You can try leaving the dial in the


same position when you get one digit,
instead of moving it back to the centre
(line 70 does this each time). If you delete
line 70, and put instead a new line 45 LET
PI=O , then the centre position will only be
set on the first digit.
You are at the centre of an international spy ring. It is crucial that
you get your messages out of a foreign country undetected. You
decide to do this via a coding program. The coding program will
turn your secret messages into unreadable rubbish. The agent at
home will receive these messages on his computer which will
decode them.
Type every word of your message into the computer separately.
The computer will turn each word into code and flash it up onto the
screen. You must then remember the coded word - agent's
instructions forbid you to write down any coded message. When
the screen clears, type the coded word back into the computer and
it will be transmitted to the agent at home. Then move on to the
next word in your message.
When the whole message is typed in in this way, type an * to
indicate 'message complete'. You will then see whether you have
been successful in getting the vital information through.

10 GOSUB 1000 : GOSUB 2000


20 PRINT uSpy CODES"
30 PRINT
40 LET C=FNR(25)
50 LET M$::;I : LET N$;;;1I11
II

60 PRINT "TYPE IN A WORD (UPPER CASE ONLY,

70
• TO END) : "
INPUT W$
80 IF ~j$="iu THEN GOTO 210
90 LET M$=M$+W$+ "
100 GOSUB 500
110 GOSUB 2000
120 PRINT "CODED WORD IS: J(

130 PRINT xt

.-. • • • • • • . ' e !J.. .. ~ -~ .;~' • ". • • V~ .-.. -; •


sdsyoc·yocpessd·suocs
•• • ••••• • •• ••• •• • •• • • ••
SPY CODES 25

140 FOR 1=1 TO LENIW$)*200 : NEXT I


150 GOSUB 2000
160 PRINT "T YPE CODE TO TRANSMIT:"
170 INPUT Wt
180 GOSUB 500
190 LET N$=N$+X$+"
2(1) GO TO 60
210 PRINT "YOU SENT THE MESSAGE:"
220 PRINT Nt
230 PRINT "THE CORRECT ONE WAS:"
240 PRINT Mt
250 IF MI=NS THEN PRINT "WELL DONE!" GOTO
4000
260 IF LENIMt) ( )LENINI) THEN GOTO 320
270 LET N=O
280 FOR 1=1 TO LENIMti
vbd 19'0 IF ~[[$IM$,.r,.tI "I'IIIH;I/t$.,.I,tI fHiili LET
N;N+L
5 Zq:O IF 1'1$( [) <"Nt( II TitE~ LET N~N+L
300 NEXT I
31 0 PRINT "YOU MADE ";N;" MISTAkES"
320 PRINT "YOUR AGENT [S TOTALLY CONFUSED"
330 GOTO 4000
500 LET X$="u
510 FOR [=1 TO LEN(WS)
vbd 520 LET X=ASC(MID$(W$,[,liJ+C
5 :'i20 LET X=CODEiW$(li I+C
:'i30 [ F X>90 THEN LET X=I-26
:'i40 [F 1<65 THEN LET 1=1+26
550 LET X$=X$+CHR$IX)
560 NEXT [
570 LET C=-C
580 RETURN

• • ' ~ • • • • • • •~ . - . '~ ~ • • . • • • • ~ e ' ••

ep·p' e sdsyoc·ocesdyps·
. . . . . . . . . .. .. . . .. . . . '. . ~
26 SPY CODES
For the different computers
ERe Electron Oragon ,,
1000 DEF FNR IXI=R ND IXI 1000 DEF FNRIXI=RNDIXI
1010 RETURN 1010 RETURN
2000 CLS : RETURN 2000 CLS : RETURN
3000 LET U=INKEY$(\I 3000 LET U=INKEH
3010 RETURN 3010 RETURN
4000 END 4000 END

,;~"., , p5p~~ L ~

1000 DEF FNR (X I 1000 DEF FNR (X I


=INT(RNDIII'X+II =INTIRND'X+II
1010 RETURN 1010 RETURN
2000 PRINT CHRS(147); 2000 CLS : RETURN
: RETURN 3000 LET l$=INKEY$
3000 GET II 3010 RETURN
30 10 RETURN 4000 STOP
4000 END

How the program works:


Lines 10-30 clear the screen and display the
title of the game .
Line 40 chooses the secret code number for this
game.
Line SO makes the strings that Hill hold the
message that you typed in IMSI and the final
decoded message INti blank.
Lines 60-70 get a Hord from you, into WI .
Line 80 checks if you want to finish, and if so,
the computer goes to line 210 .
SPY CODES 27

Line 90 adds this word onto the message, with a


space after it.
Line 100 calls the subroutine that converts this
message to code.
Linel 110-130 clear the screen and display the
coded word on the screen.
Lines 140-150 wait for a time, depending on the
length of the word, and then clear the screen
again.
Lines 160-170 get the code word from you to
transmIt.
Lines 180-190 call the subroutine that will
decode the word, and adds the decoded word
onto the final message in N$, along with a
space.

' ..
Line 200 repeats the process by going back to
line 60, where you will enter a new word (or a
) .
Lines 210-240 display the final decoded message,
and the original message that you wanted to
send.
Lin. 250 checks whether you got it all right. If
s o, it displays a message and stops the
program.
Line 260 checks if the length of the two
messages is the same or not. If not, the
computer will go to line 320 and print a
suitable message.
Lines 270-300 go through the two strings,
checking each letter. Each time a letter is
wrong, the variable N is increased by one
(starting at zero), so it will contain a count
of the number of your mistakes.
28 SPY CODES
Line 3 10 displays a message telling you how much
you got ~irong .
Lines 320-3 30 display a suitable message, and
stop the program.
Lines 500 - 580 contain the subroutine to code and
decode a word. Th e first time it is used, it
will code the string in W$ and put the result
in XS. The next time, it will decode the
string in WI and put the result in XS . It does
this by changing the sign of the secret cod e
number, C, in line 570. If effect, each letter
is moved through the alphabet C times to get
i t s coded version.
Lines 1000-400 0 contain the standard routines .

Changes you can make:


1) The length of tim e that the code d
word
appears an t he screen is controlled in line
140. If you want to make it faster, make the
number 200 smaller . If you want to make it
slower, increase the number .

2) You could make the computer produce the


message on its own. You could put the
message in a DATA statement at the end of
the program, with Gach word in quotation
marks, and the last word being a *. You
CQuid eVEn have several messages in stored
this way, and could select randomly from
SPY CODES 29

them. Here is one way you could do this,

42 LET M=FNR (3)


44 FOR 1=1 TO M
46 READ W$ : 1F W$ (>u III THEN GOTO 46
48 NEXT 1
60 READ W$
delete line 70

600 DATA "f","THE","AN5WER I', "IS","FORTY",


':rwo lI ,lIt n
610 DATA "OPERATION","PINEAPPLE","TO","GO",
IIAHEADII,"f n
620 DATA "WHAT","IS'·,"FOR","LUNCH","'"

Linn 42-48 choose a random message fro" the


three available, and read through the words
until the start of that message (ie . if M is
one, it .ill rea d the first * only, if M is
two, it will read up to the second *, so
that the program .ill start with the second
message) .

Line 60 gets the word of the message from


the DATA statements .

Lines 600-620 contain the three messages.


You can change these or add your own, but
re.ember to change the number 3 in line 42
to the total number of "essages.

p·pe·idsuoc·:oce·idUps:~
......... ....... ....... ~.
30 4 : RING-A-RING O'ROBOT
Androids surround you. They have stolen the time key without
which you cannot leave their planet. They are teasing you, passing
the time key around the circle between themselves, constantly
changing the direction it goes in. They've told you that if you can
touch the android who holds the key, you can have it back. Each
android is represented on the screen by a letter.
From the glimpses you get of the key as it goes round, try to
touch the person holding it by typing in his letter as quickly as
possible. If you aren't able to touch the android holding the key
after a certain time, you'll just have to accept you'll never see the
planet Earth again.

10 GOS US 100 0 : GOSUS 2000


20 PRINT "RING-A-RING O' ROBOT"
30 PRINT
b
d
vs
b w

d
vs
60 FOR N=O TO 11
70 LET P$=CHR$(65+N ) : GOSUS 210
80 NEX T N
90 LET N=FNR ( 12)-1
100 LET D=1
11 (I IF FNR ( 10 » 4 THEN GOTO 170
120 LET P$;;U4 : GOSUB 210
U

130 LET J $::::


!I II
: FOR 1=1 TO 100 GOSUB 3000
RING-A-RING O'ROBOT 31

140 LET J$.J$tl$ NEXT


vbd 15· T F . Sr 1 65· T':EN "BUll "SOT IT'"
: 5C 4\."ll
5 l~O JF CDDE'rt" ")-o5'N TME~ PRINT "SOT IT"
! SOTo 4
160 LET P$'CHRS(65tN) : GOSUB 210
170 LET N·NtD : IF FNR(IO)'I THEN LET D'-D
180 IF N(O THEN LET N'NtI2
190 IF N>II THEN LET N'N - 12
200 GOTO 110
210 LET X'CltINT(SIN(N/6*3.142)*OI)
220 LET Y·C2-INT(CoS(N/6*3.142)*D2)
b P!;'J T - '1) P
s ~'RJiIIT hi " ... 1 •
d fRINT @(Y"~:.y) ."S;
V 'R: - - ". QI;: F R "-I TO ¥ ; Pili""
E T PRINT -ABII):P$;
240 RETURN

For the different computers

1000 DEF FNR(X)'RND (X) 1000 DEF FNR(X)'RND(X)


1010 RETURN 101 0 RETURN
2000 CLS : RETURN 2000 CLS : RETURN
3000 LET 1$'INKEY$(I) 3000 LET I$=IN KEY$
30 I 0 RETURN 3010 RETURN
400 0 END 4000 END

1000 OEF FNRO) 1000 OEF FNR( x)


• I NT (RND (I) * Xt I ) ·INT(RND*Xtl)
10lQ RETURN 1010 RETURN
2000 PRINT CHR$ (1 47) : 2000 CLS : RETURN
: RETURN 3000 LET 1$= I NKEY$
3000 GET 1$ 3010 RETURN
30 10 RETURN 4000 STOP
4000 END
32 RIN
How the program works:
Lines 10 -3 0 clear the screen and prInt the
Utle .
Lines 40- 50 set up the variables that contro l
the size of the screen. Cl and C2 hold the
coordinates of the centre of the ring, while
D1 and D2 hold the size.
Lines 60-8 0 display the ring of 12 letters on
the screen.
Line 90 chooses the starting point for the time
key.
Line 10 0 sets the direction of the movement in
D to clockwise (anticlack wise is -1) .
Line 11 0 decides whether the time key should be
shown on the screen . I f nat, the computer goes
to line 170 .
Line 12 0 displays a , at the current position in
the ring .
Lines 130-140 check if the pl ayer is pr essing a
key .
Line 150 checks if you got t he right letter . If
so, displays the mess ag e 'GOT IT ' and stops .
Line 160 re-displays the letter in the ring,
Line 170 moves the position of t he time ke y.
Somet i mes, the di r ection of movement is
changed .
Lines 180-19 0 checks if the position has gone
out of range . If so, it is re-calculated.
Line 200 goes back to repeat the loop.
Lines 210-220 work out the position on the
screen, given the number that the key 15 at .
Lines 230-24 0 disp l ay the character at that
position, and return to the main program.
Lines 1000-4 000 contain the standard routines.
5:NIM 33

This game is of Chinese origin and is one of the world's oldest


number games. It's a game for two people and you can play it
against your computer.
It has very simple rules. The computer sets up several piles of
matches. Each pile has a random number of matches in it. You and
the computer take alternate turns. On each turn the player can take
any number of matches from anyone pile. The winner is the player
who is able to remove the last pile from the table in his turn.
As this is a game of numbers and logic, and computers are best
at these things, you will find the computer is VERY good at playing.
But there are ways to win ... Good luck!

..

10 GOSUS 1000 : GOSUS 2000


20 PRINT "NIM"
30 PRINT
40 LET N=FNR(41+2
50 DIM P (NI
60 FOR 1=1 TO N : LET P(II=FNR(71
70 NEXT I : GOSUS 400
80 PRINT "DO YOU WANT TO START (Y OR NI?"
90 GOSUB 3000 : IF 1$="" THEN GOTO 90
100 IF I$="Y" OR I.="y· THEN GOTO 210
110 LET C=O
120 FOR A=1 TO N : IF P(AI=O THEN GOTO 160
130 FOR B=1 TO P(AI : GOSUS 500
140 IF C=1 THEN GO TO 190
150 NEXT B
160 NEXT A
34 NIM
170 LET A;FNR(N) : IF P(A);O THEN GOTO 170
180 LET B;FNR(P(A))
190 LET P(A);P(A)-B : GOSUB 400
200 IF T;O THEN PRINT" I WIN .... " GOTO 4000
210 PRINT "WHICH PILE"
220 I NPUT A
230 IF A<1 OR A>N THEN GOTO 220
240 IF P(A);O THEN GO TO 220
250 PRINT "HOW MANY"
260 INPUT B
270 IF B<1 OR B) P (A) THEN GOTO 260
28 0 LET P(A);P(A)-B : GOSUB 400
290 IF T;O THEN PRINT "YOU WIN ... "
GO TO 4000
300 GOTo 110
400 GOSUB 2000 : PRINT "PILE NO. " , "MATCHES"
410 LET T;O : FOR 1;1 TO N PRINT I,P(I)
420 LET T;T+P ( I ) : NEXT I
430 RETURN
500 LET P(A);P(A)-B
5\0 LET Q;O : LET R;O : LET 5;0
520 FOR 1;\ TO N : IF P(I);O THEN GOTO 550
530 RESTORE FOR J;\ TO PCI) : READ X,Y,Z
NEXT J
540 LET Q;Q+X : LET R;R+Y : LET S;S+Z
550 NEXT I
560 LET PCA);P(A)+B
570 IF Q/ 2;INT(Q / 2) AND R/ 2;INTCR / 2) AND S/ 2;
INTCS/2) THEN LET C;\
580 RETURN
600 DATA 0,0, \ ,0, 1 ,0,0, 1, \,1,0,0,1,0,1, \,1,0,
1, 1, 1

..
NIM 35

For the different computers

1000 DEF FNR(X)=RND(X) 1000 DEF FNR(X)=RND(X)


1010 RETURN 1010 RETURN
2000 CLS : RETURN 2000 CLS : RETURN
3000 LET I$=INKEY$(l) 3000 LET 1$= I NKEH
3010 RETURN 3010 RETURN
4000 END 4000 END

\:l ~

1000 DEF FNR<X) 1000 DEF FNR(X)


=INT(RND(l»X+l) =INT(RNDH+l)
1010 RETURN 1010 RETURN
2000 PRINT CHR$ (1471; 2000 CLS : RETURN
: RETURN 3000 LET I$=INKEY$
3000 GET If 3010 RETURN
3010 RETURN 4000 STOP
4000 END

How the program works:


Lines 10-30 clear the screen and print the
title.
Lines 40-50 choose the number of piles, and make
an array variable to hold them.
Lines 60-70 fill each pile with a random number
of matches and display the piles on the screen
Lines 80-100 ask whether you wish to start, and
if you do, the program goes to 210.
Lines 110-160 control the computer ' s turn. If i t
finds a good move, it goes to line 190,
otherwise ...
Lines 170-180 pick a random move for the
computer.
Line 190 takes the matches away from the right
pile, and displays the piles.
Lin. 200 checks whether the computer has won (jf
all the matches have gone).
36 NIM
Lines 210-270 get the player's move and make
sure it is valid.
Line 280 takes the matches away from the right
pile, and displays the piles,
Line 290 checks whether the player has won,
Line 300 loops back for the computer's next go,
Linel 400-430 display the piles on the screen,
Line. ~OO-bOO contain the program to work out
the computer ' s move.
Lines 1000-4000 contain the standard routines,

Changes you can make:


11 You can change the number 01 piles
allowed ill Ilne 40. At the roome nt l there can
be an y number between 3 and 6. The ma Ximum
number of matches in each pile can be
changed by changing the number 7 in line 60,

2) You could change the routine that


displays the piles of matches (lines 400-
430 1 so that it prints a row of , ' s for each
pile, where each star represents a match.
One way to do this would be:

410 LET T=O FOR 1= ! TO N : PRINT I ,


415 FOR J =! TO P ( I I : PRINT "*" ; : NEXT J
420 PRINT : LET T=T+PII! : NEXT I
430 RETURN

If yo u are interested in maths, see if


you can work out how the computer plays,
from the program at lines 500 onwards. Hint
- the DATA statement contains 3-digit binary
numbers irom 1 to 7. Other"i se, watch how it
plays and see if you can learn from it - the
computer is a very good player!
6: FROM THE DEPTHS OF TIME 37

You have been sent back in time on a mission of exploration. You


have a crew of four scientists aboard. Suddenly you find that your
time machine is being attacked by dreadful prehistoric monsters.
Your only chance of survival is to send the crew out one by one
against the monsters. Each member of the crew is equipped with
various methods of defence. But the monsters attack so quickly
that you only have time to order the man to use one method of
defence, before he is completely overwhelmed by the ferocious
beast. Decide how the man is to defend himself by pressing the
appropriate number key each time a monster attacks ... and
discover whether you will survive.
10
20
GOSUE 1000 : GOSUB 2000
PRINT 'THE DEPTHS OF TIME'
~
30 LET K=O : LET Kl=10 : LET P=FNR(3)
40 FOR M=1 TO 4
50 RESTORE: READ N LET W=FNR (N)
60 FOR 1=[ TO W
70 READ M$ : NEXT LET W=W+P
80 IF W>3 THEN LET W=(,-3 : GOTO 80
90 FOR 1=1 TO 1000 : NEXT I : GOSUS 2000
100 PRINT 'Y OU ARE BEING ATTACKED BY A'
110 PRINT M$
120 PRINT '[) FIRE POISON DART'
130 PRINT '2) FIRE HARPOON '
140 PRINT '3) ATTACK WITH KNIFE"
150 PRINT '4) RUN BACK TO SHIP '
160 PRINT "C HOOSE OPTION".,,"
170 FOR 1=1 TO 150 : GOSUB 3000
180 IF 1$ )"0" AND I$ (" S" THEN
LET I=IS0
190 NEXT I : LET D=VAL('O'+IS)
200 IF D=4 AND
FNR ( 10) <S THEN
PRINT ' PHEW!':
GOTO SO
210 IF DO W THEN
GO TO 260
38 FROM THE DEPTHS OF TIME
220 PRINT "YOU KILL ED IT" : LET K=K+I
230 IF K(K I THEN GOTD 50
240 PRINT "WELL DONE,YOU DID IT'"
250 GOTD 29 0
260 PRI NT "THE MONSTER KILLED ON E OF YOUR CREW'
270 NEXT M
280 PRINT "OH DEAR,YOU HAVE ALL BEEN KILLED"
290 PRINT "YOU MANAG EO TO KILL " ; K;" MONST ERS "
300 GOTO 4000
500 DATA 5
510 DATA "TYRANNOSAURUS REX",
"BRONTOSAURUS"
520 DA TA "DI PLODOCU S" ,
"STEGOSAURUS","A LIOSAURUS"

For the different computers

1000 oEF FNR (X)=RNo(X) 1000 oEF FNR( X)=RNo(X )


1010 RETURN 101 0 RETURN
2000 CLS : RETURN 2000 CLS : RETURN
3000 LET U= I NKEH ( 1) 3000 LET U= I NKEH
301 0 RETURN 30 10 RETURN
4000 END 40 00 END

.' ZX Spectrum ':


1000 oEF FNR( X) 1000 DEF FNR (X)
=INT(RNo(l ) fX+l) =INT (RNof X+l )
1010 RETURN 1010 RETURN
2000 PRINT CHR$ ( 14 71 ; 2000 CLS : RET UR N
: RETURN 3000 LET I$=IN KEY$
3000 SET 1$ 30 10 RETURN
30 10 RETURN 4000 STOP
4000 EN D
FROM THE DEPTHS OF TIME 39

How the program works:


Lines 10-20 c l ear the screen and print the
titl e of t he ga me .
Line 30 sets th e number of monsters killed so
far to zero (in Kl and the total numbe r of
monsters that are going to attack you t o 10
(in Kil. It also sets P to a ran do m number
between I and 3. This is used to decide which
weapon will kill which monster.
Line 40 is the start of the loop g1Ying you four
I i YES (one for each of your menl.
Line 50 restores the pointer to the beginning of
the data in lines 500 to 520, reads the number
of different monster names into N, and picks a
random monste r in W.
Lines 60-70 read that name into M$ from the data
in lines 510-520, and also add P to the chosen
monster number, to decide which weapon will
k ill the monster.
Lin. 80 If W is greater than three, the computer
takes away three until it is small enough .
Lines 90 - 160 delay a while, clear the screen and
print out a message telling you that you are
being attacked by the monster and asking you
what to do .
Lines 170-190 get a decision from the pl ayer, if
he is quick enough. He is only allow e d to type
the keys I to 4 . Line 190 works out which key
was pressed, and puts the number in D.
Line 200 lets you run away, sometimes'
Line 210 checks if you got the r i ght weapon or
not. If not, you los e a life .
Lines 220-230 t e ll you that you killed the
monster, increases the count of monsters
~illed, an d if there are any mor e l e ft, go e s
back for a nother .
Lines 240-250 print a mes s age when you kill all
the monsters, and then goes to line 290, which
40 FROM THE DEPTHS OF TIME
prints how many monsters you kllled, and
stops.
Lines 26 0- 270 tell you that one of your men •• s
killed, and then loops back for the next man,
until all four men are dead ...
Lines 28 0-3 00 tell you when all yuur men .re
dead, and how many monsters you managed to
kill. The program then stops.
Line SOO holds the number Df monster names ln
the fullo"lng data statements.
Lines 51 0-5 20 hold the dlfferent mDnster names.
Lines 1000 -4 000 cDntain the
standard rDutines .

Changes you can make:


1) You can make the program easier or
harder by changing the number of monsters
that attack YDU (the number 10 in line 30)
and the number of men in your crew (the
number 4 in line 40).

2) You can easily add more monster types~


by addIng extra lines aft e r line 520,
beginning with DATA and "lth the names ln
quotes. Remember to change the number in
line 500 to the total number of monster
names (it is 5 at the moment) .
7: GALAXY HITCH-HIKE 41

You have been abandoned in the far reaches of the galaxy, and you
have vital information about an underground organization
planning to overthrow Galactic High Command. You must return to
Earth in time to warn them of this plot. Your only hope of getting
back is to hitch lifts from passing trade spaceships.
There are many passing ships, but can you manage to plan your
way back to Earth in time to save the Empire. You have a limited
amount of money with which you can try to bribe the captain of a
ship to take you nearer to Earth, but you may just have to rely on
luck and intuition ..
10 GOSUS 1000 : GOSUB 2000
20 PRINT 'GALAXY HITCH-HIKE'
30 PRINT
vbd 4
5 urI
50 LET M=2 : LET T=O
60 FOR 1=1 TO 10 READ S$(I)
70 NEXT I
80 LET S=8+FNR(2)
90 FOR 1=1 TO 1000 : NEXT I :
GOSUB 2000 : GOSUB 500
100 PRINT 'YOU ARE ON ';S$(S)
110 LET T=T+I
121) LET P=FNR (S)+FNR(10-S)'(FNR(2)- I)
130 IF P=S THEN GO TO 110
140 PRINT 'THERE IS A SHIP GOING TO'
150 PRINT S$(P)
160 PRINT "00 YOU WANT TO TAKE IT"
170 FOR 1=1 TO 500 : GOSUB 3000 : IF I$ ()"
THEN LET 1=500
180 NEXT I : IF 1$=" THEN PRINT 'IT LEFT"
GOTO 90
190 IF I$='Y' OR II=' y' THEN LET S=P
200 IF S=1 THEN GOTO 300
210 IF M= O THEN GOTO 90
2 GALPJrf HITCH-HIKE
220 PRINT "DO YOU WANT TO TRY TO BRIBE
THE CAPTAIN?"
230 FOR 1'1 TO 500 : GOSUB 3000 : IF I$ () ""
THEN LET 1=500
240 NEXT I : IF 11= "" THEN PRINT "TOO LATE'"
GOTO 90
250 IF I. () "Y" AND I. ()"y" THEN GO TO 90
260 IF FNR (10 1( 7 THEN PRINT "DIDN ' T HELP! "
GOTO 90
270 LET 5=5-1 : LET M=M-I
2BO PRINT "YOU ARE NOW GOING TO"
290 PRINT 5$(51 : IF SO l THEN GOTO
300 PRINT "YOU MADE IT TO EARTH !"
310 IF T) 12 THEN PRINT "BUT THE
REVOLUTION HAS STARTED"
320 IF T<=12 THEN PRINT
"YOU GOT THERE IN TIME'"
330 PRINT "YOUR JOURNEY TOOK" j Tj" WEEKS"
340 GOTO 4000
500 PRINT' '";TAB(201;"'"
510 PRINT "CENTRUS ' " jTAB(161;"DELTAR"
520 PRINT TAB(BI; "V EGA"
530 PRINT "1 ";TAB(15);"* "
540 PRINT "TRALIN";TAB(131;"SIRTEP'
550 PRINT TAB(IOI;"+"
560 PRINT TAB(9); "EARTH ."
570 PRINT TAB(4)j"'"jTAB(16);"FROP"
5BO PRINT" GRAPLOR"; TAB (131; "."
590 PRINT TAB(12); "DORF ."
600 PRINT TAB (17) ; "PLOT"
610 RETURN
700 DATA "EARTH","SIRTEP","FROP " ,"GRAPLOR'
710 DATA "VEGA", "TRAUN", "DORF" ,"DELTAR"
720 DATA "CENTRUS","PLOT"
GAlAXY HITCH-HIKE 43

For the different computers


BBC / Electron Dragon
1000 DEF FNR(XI=RND(XI 1000 DEF FNR(XI=RND(XI
1010 RETURN 1010 RETURN
2000 CLS : RETURN 2000 CLS : RETURN
3000 LET I$=INKEU(11 3000 LET 1$= I NKEY$
3010 RETURN 3010 RETURN
4000 END 4000 END

ZX Spectrum
1000 DEF FNR(XI 1000 DEF FNR(XI
=INT(RND(1)*X+ll =INT(RND*X+ll
1010 RETURN 1010 RETURN
2000 PRINT CHR$(147l; 2000 CLS : RETURN
: RETURN 3000 LET 1$= I NKEH
3000 GET U 3010 RETURN
3010 RETURN 4000 STOP
4000 END
44 8: PLANET LANDER
You are on a secret mission for High Command in a prototype
spaceship. After a live·month joumey, you have come into orbit
around the planet that is your destination. You must now try to
land on it. Your instruments give you readings about the planet,
telling you how strong the gravity is and what the atmosphere is
like. You must land safely on the surface.
At each stage of the descent you type in how much you want
your engines to thrust, in order to slow you down. As you get closer
to the planet beware of going too fast. To land safely you need to
go very slowly. But if you thrust too much you will start going
upwards, towards sure execution by Higr' Command who will not
tolerate the failure of missions.
You only have a limited amount of fuel. You are able to burn from
o to 40 units of fuel on each go.

10 GOSUB 10 00 : GOSUB 2000


20 PRINT 'PLANET LANDER'
30 PRINT
40 READ N : LET P=FNR(Nl
50 FOR 1=1 TO P : READ P$,G,A : NE XT I
60 PRINT 'YOU ARE COMING DOWN ONTO ';P$
70 PRINT 'GRAVITY IS ';G
BO PRINT 'AND AIR RESISTANCE IS ';
90 IF A<4 THEN PRINT 'LOW '
100 IF A)3 AND A( 7 THEN PRINT 'MEDIUM'
110 IF A)6 THEN PRINT 'HIGH '
120 LET T=O : LET H=250
130 LET V=30 : LET F=100
5 140 FOR 1=1 TO I..)I)\' NEXT
~d 140 FOR 1=1 TO '"\5 II : tilE": T

150 GOSUB 2000


160 PRINT 'TIME ';T,'HEIGHT ';H
170 PRINT 'SPEED ';V,'FUEL ';F
180 IF F=O THEN GOTO 220
190 PR(NT : PRINT 'FUEL TO USE'
200 INPUT Fl
PLANET LANDER 45

210 IF FI ( O OR FI ) 40 THEN PRINT 'CHEAT"


GOTO 200
220 IF Fl ) F THEN LET FI=F
230 LET Vl=V-FI+G : LET F=F-FI
240 LET D= (V I+V) / 2
250 IF D) =H THEN GOTO 310
260 LET H=H-D
270 LET V= Vl : LET T=T+I
280 LET Q=INT(V4V / 1800)4A
290 IF Q) 10 THEN GOTO 360
300 GOTO 150
310 LET Vl=V+(G-FI)4H / V
320 IF VI >7 THEN PRINT 'YOU MADE
A BIG CRATER! BAD LUCK'
330 IF Vl >2 AND VI ( =7 THEN PRINT
'YOU BROKE YOUR LEG"
340 IF Vl ( =2 THEN PRINT
'GOOD ENOUGH LANDING"
350 GOTO 4000
360 PRINT 'YOU ARE GOING SO FAST,
YOU WILL SOON BURN UP ... •
370 LET A=A+10
380 IF Q( 20 THEN SOTO 140
390 PRINT 'SIZZLE ..... SIZZLE
...... BOOOOMMM!·
400 PRINT 'YOU HAVE TURNED
INTO A FALLING STAR"
410 GOTO 4000
500 DATA 8
510 DATA 'VEGA',4,5
520 DATA 'SNURG',B,8
530 DATA 'GLIRP',2,1
540 DATA 'DORTON',9,4
550 DATA 'SPROG',6,6
560 DATA 'FLORP',1,3
570 DATA 'PLURG',7,9
5BO DATA 'RITAL',9,2
46 PLANET LANDER
For the different computers

DEF FNRIX)=RNDIX) 1000 DEF FNRIX)=RNDIX)


RETURN 1010 RETURN
CLS : RETURN 2000 CLS : RETURN
LET U=INKEHll) 3000 LET I$=[NKEY$
3010 RETURN
4000 END

1000 DEF FNR I X)


=INTIRNDll)>X+l) =INTIRND-X+l)
1010 RETURN 1010 RETURN
2000 PRINT CHR$11471; 2000 CLS : RETURN
: RETURN 3000 LET [$= [NKEY$
3000 GET [$ 3010 RETURN
3010 RETURN STOP
I [ 4000
I 4000 END
How the program works:
lines 10-30 Clears the screen and prints the
title.
line 40 Reads the number of planets available
and selects a random number between 1 and that
number.
line SO Gets details of the selected planet by
reading through the data P times. At the end
of the loop, P$ will contain the selected
planet ' s name, G its gravity and A the air
resistance.
lin.s 60-BO These lines print out the
description of the planet for the player.
iines 90-110 Print LOW, MEDIUM or HIGH for the
air resistance depending on its value.
PLANET LANDER 47

1 i nn 120-130 Set up the variables for the


game. T is time,H is height above the surface,
V is speed and F is the amount of fuel you
have.
lines 140-170 Delay a while, clear the screen
and print out the values of T,H,V and F. This
is where the computer starts each go.
line 180 If you have run out of fuel, the
program skips past the INPUT of fuel.
lines 190-200 Get amount of fuel to use from
the player.
line 210 Checks that he ' s not using a minus
amount, or too much.
line 220 Checks that he ' s not using .ore than he
has, and if so, use only what there is left.
lines 230-240 Calculate th e new speed, new fuel,
and distance moved (in 01.
line 250 This checks whether the player has
landed. If so, GOTO 310.
line. 260-270 Wor k out new height, put new speed
into V and increase time by one.
line 280 Works out air resistance factor.
line 290 Is it critical' If so, GOTD 360.
line 300 Go back for ne xt turn.
line 310 Works out speed when landed.
lines 320-340 Print a message depending on your
final speed.
line 350 Stops the game.
line 360 Prints a warning .essage because you
are heating up from air resistance.
line 370 Increases air resistance so that ne xt
time, Q will be much larger.
line 380 Go back for ne xt go only if Q( 20.
line. 390-400 You have burnt up !
lin. 410 Stops the game.
48 PLANET LANDER
lines SOO DATA statements with the names and
detai Is of each planet. The fIrst data
statement has the numbe r of planets in the
program.
Lines 1000 -40 00 contain the standard routines.

Changes you can make:


1) L,nes 10-130, and line 500 onwards, set
up all the different factors about the game.
Most of these you can change yourself lf you
wish. In line 120, chan ge the value of H if
you want to start at a different height .
Change V i n 130 for a different starting
speed, and F for a different amount of fuel
( ,f you find It difficult to win, gI ve
yourself lots of f uel tor practise until you
get better, but remember, you ' re
CHEATIN G"!)
2) You can change or add planets in the
game. Each line after line 500 has the
planet name in quotes, followed by the
gravit y number, and then the air resIstance
number. If you want to add more planets, put
them startlng at line 590, and increase the
number In line 500 (,t starts at 8 since
there are 8 planets in the list) .
9:ANIMAL 49

In this game the computer will try to guess what animal you are
thinking of. The fun of the game is teaching the computer to ask
more and more questions about different animals.
On each go, you are asked to think of an animal but not to tell
the computer what it is. Then it will ask questions about the animal
to which you must answer 'Yes' or 'No'. After a few questions, it will
take a guess at the animal. If it is right, you will be glad you have
such a clever machine. If it is wrong, you must teach it how to
recognize the animal you were thinking of, so that next time it may
be able to guess it correctly.

1 (l G05UB iOt)!) : GOSUB 2000


20 PRINT uANIMAL "
30 PRINT
d .,..~
C,EAE s ,.
vbd 4 (I D ~' [;:t 5 \ N ( 5 C, ) \ H.f 5 (I )
s 40 DIN 0$1.50,25.! : DIM N(50 DIM AS(51J,15)
50 READ NI , N2
60 FOR 1=1 TO Nl
70 READ Q$ ( I ) ,N(I)
80 NEXT I
90 FOR 1=1 TO N2
100 READ AS ( I) NEXT I
110 GOSUB 20 0 0 : PRINT "THINK OF AN ANIMAL"
120 LET P=1
130 PRINT Qt(P)
140 GOSUB 800
150 IF IS="Y " OR IS= "y" THEN LET
INT (N(P )! IOO)*IOO
16 0 IF It=" N" OR It="n" THEN LET P=INT (N(P ) (
10 0 )
vbd l70 IF LEFH{Q$(F).IJ '." THEN GOTO 13C'
5 170 IF ['$' F·. 1 ;. " . ' THEN GOTO 1'(.

~. 11; ill:1:;ll ';;r : :;::' I~


210 IF I$= "N" OR I$="n" THEN GOTO 240 -+-'-
220 PRINT "WHY NOT TRY A DIFFERENT ANIMAL?"
230 GOTO 120
240 PRINT "THE ANIMAL YOU WERE THINKING OF
WAS A"
250 INPUT U
260 PRINT "TYPE IN A QUESTION THAT WOULD"
270 PRINT "TELL A ";T$;" FROM A " ;A$ IA)
280 INPUT SI
290 PRINT "FOR A ";1$;" THE ANSWER WOULD BE"
300 GOSUB 800 : LET Z=O : IF I$="N" OR I$="n"
THEN LET Z=I
310 LET Q$INI+I)=Q$IP)
320 LET Q$INI+2)=", "+STR $IN2+11
330 LET Q$IPI=S$
340 LET NIPI=NI*101+l.99+I02
350 LET NI=NI+2
360 LET A$IN2+11=T$
370 LET N2=N2+1
380 GOTD 120
800 PRINT "? II;
810 GOSUB 3000
820 IF I.C)"Y" AND I' C> "N" AND I. C)"y" AND
I$ C)'n' THEN GOTO 810
830 PRINT 1$
840 RETURN
900 DATA 3,2
910 DATA "DOES IT SWIM",302
920 DATA 11.1 ,0,11.2",0
11

930 DATA 'PIKE', "CROW'

. ~•. ~ .
ANIMAL 51

For the different computers


BBCI Electron Dragon
1000 DEF FNR(X)oRND(X) 1000 DEF FNR (X)oRND(X)
1010 RETURN 1010 RETURN
2000 CLS : RETURN 2000 CLS : RETURN
3000 LET I$oINKEV$ (ll 3000 LET 1$0 I NKEY$
3010 RETURN 3010 RETURN
4000 END 4000 END

ZX-Spectrum '
1000 DEF FNR(X) 1000 DEF FNR(X)
oINT(RND(I)*X+l) °INT(RND*X+l)
1010 RETURN 1010 RETURN
2000 PRINT CHR$(147); 2000 CLS : RETURN
: RETURN 3000 LET !$o!NKEY$
3000 GET It 3010 RETURN
3010 RETURN 4000 STOP
4000 END
How the program works:
Lines 10-30 clear the screen and display the
title of the game
Line 40 sets up three array variables, Q$ holds
the questions, N holds the references to the
next question each time, and a$ holds the
different animal types,
Line ~O reads in the number of items in the
question array, and the number of animals
( into Nl and N2 respectively)
Lines 60-100 read in all the data in line 900
onwards into their respective arrays.
Line 110 clears the screen and prints the
message: ' THINK OF AN ANIMAL ' ,

tt I1
-1
I
52 ANIMAL
Line 120 sets the current question to number 1.
Line 130 prints the question
Line 140 gets an answer from you - either ' Y' or
'N' •
Lines 150-160 calculate the position of the next
question or solution, from your answer and
from the value stored in the array N,
Line 170 checks to see if there is a solution
(ie the computer has run out of questions. If
not, the computer will go back to print the
next question.
Lines 180-190 gets the animal number and print
' ISlTA .... '
Line 200 gets your reply, either 'Y' or 'N '
Line 210-230 checks if if you answered ' N', and
if not, prints a message and goes back for
another game.
Lines 240-250 ask you to input the animal you
were thinking of, and store it in TS,
Lines 260-280 ask for a question that would
distinguish the two animals, and stores it in
5$
Lines 290-300 ask you whether the answer to your
question would be yes or no. If it is yes,
then Z is set to (I, if no, Z is set to 1-
Lines 310-370 update the arrays and counters, so
that the new animal is learned by the
computer.
Lines 380-390 tells you that the computer has
learnt the animal, and is ready to play again,
which it does by going back to line 120.
Lines 800-830 accept a single key input from
you, ~~hi[h can either be ' Y ' or ' N' , and print
it on the screen.
Lines 900-930 contain the starting data for the
program.
Lines 1000-4000 contain the standard routines.
1 0 : SILO RAID 53

You are sailing over enemy waters and you have been ordered to
bomb and destroy all the underwater silos containing the enemy's
newest and most dangerous weapons. Your ship contains twelve
guided depth charges which will land on the sea bed at the spot
you choose by giving co·ordinates.
You also have the use of a sonar but, unfortunately, it is not
functioning correctly. The picture it gives is muddled and slightly
incorrect. Can you make some sense from the display it gives to
help you find the exact location of the silos you must destroy?
3 4 5 7

5
I- +
6

7
+
8

10 GOSUS 10 00 GOSUS 2000

,,
20 DIM 8(8,8)
30 LET N=6
40 LET H=i)
v
" T .

,
bds c TO

60 FOR 1=1 TO N
70 LET X=FNR(S) : LET Y= FNR(S )
80 IF B<X,Y)OO THEN GOTO 70
54 SILO RAID
90 LET SIX,Y ) =-I : NEXT
100 LET Q$="SILO RAID"
110 FOR G=I TO N*2
120 GOSUS 2000
130 PRINT Q$
140 PRINT "YOUR MAP";TABIT);"SONAR "
150 LET F=FNR(7)
160 FOR Y=I TO 8
170 LET Z=O : GOSUB 400 : PRINT TAB IT) ;
180 LET Z=I : IF Y+F >8 THEN LET F=F-8
19 0 GOSUB 400 : PRINT
200 NEXT Y
210 PRINT "X-POSITION" INPUT X
220 PRINT "V-POSITION" INPUT Y
230 IF X( I OR Y( I OR X) 8 OR Y) 8 THEN GOTO 21 0
240 IF BIX, Y) =9 THEN GO TO 210
250 IF BI X,Y ) =O THEN LET BIX,Y)=9 : LET
Q$="MISS"
260 IF BI X,Y ) =-I THEN LET BIX,Y)=I : LET
H=H+I : LET O$="HIT"
270 IF H=N THEN PRINT "ALL SILOS DESTROYED!"
GOTO 4000
280 NEXT G
290 PRINT QS
300 PRINT "YOU RAN OUT OF DEPTH CHARGES"
310 PRINT "YOU HIT ";H;" SILOS"
320 GO i O 4000
400 FOR 1=1 TO 8
410 LE T V=BIX,Y+FIZ )
420 IF '1=0 OR IV =-I AND Z=O) THEN LET PI=", "
430 IF V=I OR IV=-I AND Z=I ) THEN LET P$= "S"
440 IF V=9 THEN LET P$=","
450 IF Z=I AND FNRIIO)4 THEN LET PI= ","
460 PRINT P$,
470 NEXT X
480 RETURN
SILO RAID 55

For the different computers


BBCI Electron Dragon
1000 DEF FNR(X)=RND(X) 1000 DEF FNR(X)=RND(X)
1010 RETURN 1010 RETURN
2000 CLS : RETURN 2000 CLS : RETURN
3000 LET U=INKEH(IJ 3000 LET 1$= INKEY$
3010 RETURN 3010 RETURN
4000 END 4000 END
ZX-Spectrum
1000 DEF FNR(X) 1000 DEF FNR(X)
=I NT (RND (I) * X+1 ) =INT(RND*X+l)
1010 RETURN 1010 RETURN
2000 PRINT CHR$(147); 2000 CLS : RETURN
: RETURN 3000 LET 1$= I NKEY$
3000 GET 1$ 3010 RETURN
3010 RETURN 4000 STOP
4000 END

,,
, ,
56 SILO RAID
How the program works:
Line 10 clears the screen and sets up the random
number generator.
Lines 20-50 set up the various variables In the
program. The map is held in an array called B,
which is a grid, eight by eight in size. N
holds the total number of silos, H the numb er
you have hit, and T and S$ are used for
printing out the map on your screen.
Lin.s 60-90 put the silos in random positions on
the map.
Line 100 puts the title of the game into OS,
which is printed in line 130. Q$ is then used
to print the HIT and MISS messages.
Line 110 is the start of the loop giving you a
number of goes equal to twice the number of
silos you have to bomb.
Lin.. 120-140 clear the screen, prints the
message in Qt (s ee line 100 and lines 250-260)
and prints the heading for the two maps.
Line. 1~0-200 control the priRiing of the two
maps on the screen, al ong with the subroutine
at line 300. F is used to muddle up the sonar
map.
Lines 210-230 get the coordinates of your bombin ,
position and check whether it is valid.
Line 240 checks whether there already is a bomb
there, In which case you have to try somewhere
else.
Lines 250-260 check if It is a mIss or a hit,
and change the numbers stored in the map array
accordingl y . If It is a hit, the count in H IS
increased. Q$ is set to a message that wlll be
printed out ne xt go! in line 130.
Line 270 checks if all the ships are hit, and jf
so tells you and stops the game.
SILO RAID 57

Lin e 280 is the end uf the loop, which goes back


to print thE new maps and gives you another
go, unti I you have used all your bombs :
Lin@9 290- 320 print a message when you have used
up all your bombs, tell you how many silas you
hit, and stop the game.
Lin es 40 0-48 0 are a subroutine that prints aut
one section of one of the maps on the screen.
EIght characters are printed out, de pending on
that raw of the map stored in B, and depending
on the variables Z and F which are us ed to
muddle the sona r picture .
Line s 100 0-4 000 [ontain the standard routines .

Changes you can make:

1) You could change the number of si los by


changing the number 6 in line 30.

2) Once YOLl get better a t the gam e, you


can make the sonar pi cture less useful by
changIng thE nLlmber 4 in line 450 to a
smaller number. If the game is too
difficult, however, increase this numbe r to
5 or 6 .

See if you can work out how the computer


muddles the sonar pIcture, and try working
out a different way to muddle it.
58 11 : HAUNTED HOUSE
Can you banish the notorious ghosts from Shodthom Manor? Its
owners, who have been driven out by the ghosts, have employed
you to get rid of all the ghosts in the Manor's ten spacious rooms.
Fortunately, you met an old woman in the nearby village, who
recited a spell to you that causes one ghost to vanish for ever every
time the spell is said. But it had to be said only once for each ghost.
If you say the spell too many times in a room a new ghost will be
created, destined to haunt the house for ever. If you don't say it
enough times, some of the old ghosts will remain.
Each time you enter a room, there will be a number of ghosts
displayed all over the screen. You only have seconds to press a
number key to tell the computer how many times you want to say
the magiC spell. You must try to say the spell the exact number of
times as the number of ghosts in the room. Can you banish all the
ghosts, or will there be some left haunting the house, for the next
person to cope with? That next person could be you ...

10 GOSUB 100(1 : GOSUB 2000


20 PRIN T "HAUNTED HOUSE"
30 PRINT
40 LET [=0
50 FOR R=1 TO 1(I
60 GOSUB 2000
70 PRINT "ROOM NUMBER II ; R
BO LET N=FNR (8 i
90 FOR G= 1 TO N
100 LET X=FNR ( 19 ) LET Y=FNR( 15)
b ... F _ T ~I , ~

5
"
1 (, NT
i: ..... 1

PRINT
H
@
, ..
. . · ::1'"C .
u u
Ij
;
d J. .. ..) 0
y 110 PRINT CHR$(19 ) ; :FOR 1=1
TO Y:PRINT:NEXT I :
PRINT TAB ( X) : "0 0'" ,
120 NEXT G
b .. :(, Pc I IT CHF:$130' :
FR , HT ..
5
d 1'
y
1::0

-. )
.J f' h,
',lilT
.j

~T
T

;~ l.

C~~S{l:f
.. ':
HAUNTED HOUSE 59

140 FOR 1=1 TO 300 : GOSue 3000


150 IF I$ () "" THEN LET 1=9999
160 NEXT I
170 LET K=VA LI"O "+I$)
180 IF K( N THEN PRINT
"THER E ARE" , N-K , " GHOSTS LEFT"
19 0 IF K) N THEN PRINT
"YOU CREATED ";K-N;' GHOSTS"
200 LET T=T+ABSIN-K )
210 FOR 1=1 TO 1000 : NEXT
220 NEXT R
230 PRHJT "THERE ARE "; T; " GHOSTS"
240 PRINT "LEFT IN TH E HOUSE , "
250 IF T=O THEN PRINT "~IELL DONE I "
: GOTO 4000
260 PRINT "YOU ' LL JUST HAVE TO TRY AGAIN!"
270 FOR 1=1 TO 1000 : NEXT I
280 GOTO 40

For the different computers

BBCI Electron Dragon


1000 DEF FNR IX) =RND (X) 1000 DEF FNR IX )=RND IX)
1010 RETURN 101 0 RETURN
2000 CLS : RETURN 2000 CLS : RETURN
3000 LET I$=IN KEY$ I I ) 3000 LET I$=IN KEY$
30 10 RETURN 3010 RETURN
4000 END 40 00 END

zx Spectrum
1000 DEF FNRI X) 100 0 DEF FNRIX )
=INTIRNDII ) *X+I ) =INT IRND*X+1)
1010 RETURN 1010 RETURN
2000 PRINT CHR$(147 ) ; 2000 CLS : RETURN
: RETURN 3000 LET I $= I NKEY$
3000 GET It 3010 RETURN
3010 RETURN 40 00 STOP
4000 END
60 HAUNTED HOUSE
How the program works:
Lines 10-3 0 clear the screen and print the title
of the game.
Line 40 sets the count of the number of ghosts
that are not banished forever to zero (in T).
Line SO 15 the start of the loop giving you ten
roams .
Lines 60-70 clear the screen and display the
current room that you are in .
Lines 80-12 0 choose a random number of ghosts
far this room (beb~een one and eight), and
displa y this number of ghost·s eyes on the
screen at random posItions.
Line 130 sets the cursor to the top left hand
corner of the screen again .
lines 140-17 0 glve you a certaIn time to press a
key, and, if it is a number key, put its value
into K .
Lines 180-190 display messages if you got the
number wrong ( ei ther too small or too l arge i.
Line 200 add the number of ghosts left in the
room to the total count of ghosts left in T.
Lines 210-220 delay a wnlle, and then rep.at the
loop for the next room.
Lines 230-240 dlsplay a message telling you how
man y ghosts were left in the house after you
ha ve gone through all ten rooms.
Line 250 check It vou banIshed all the ghosts,
and if so diplays a suitable message and ~tops
the program.
Lines 260-280 tell vou that you 11 have to try
again, since you didn ' t get all the ghosts,
delays a whilE, and restarts th~ program from
line 40.
HAUNTED HOUSE 61

Changes you can make:


1) You can change the speed of the game by
changing the number in line 140. If you make
the number smaller, you will not get as much
time to try to count the number of ghosts.
If you make it larger, you will get more
time.

2) You could give each of the ten rooms a


name instead of just a number. To do this,
put each roam name, in quotation mar~s, in
DATA statements at the end of the program,
such as

500 DATA "KITCHEN", "BATHROOM","L1VING ROOM"


510 DATA "MAIN BEDROOM", "GU EST ROOM"
etc .

Then, instead of line 70, which prints the


roam number on the screen, put a line that
READs in the next room name, and prints it
on the screen, for example,

70 READ R$ PRINT "YOU ARE IN THE " ;R$

Finally, you need a RESTORE instruction at


the beginning of the game, so that if it is
re-run , the DATA can be read again:

45 RESTORE
62 12 :ESCAPE
You have been taken to a high-security prison for crimes you did
not commit. You are determined to get out and put the real culprit
behind bars. You plan to escape by digging a tunnel out of the
prison. A fellow prisoner draws you a map of the prison and its
surroundings. From where your cell is positioned you must decide
in what direction you want to dig your tunnel and how long it
should be. Your cell is marked by a # sign. If you dig too far you
will collapse from exhaustion and be discovered. If your tunnel is
too short you will come up inside the prison. And of course there
may be problems when you get out. _..

10 GOSUB 1000 : GOSUS 2000


20 PR I NT "ESC APE"
30 PRINT
40 LET L=F NRI 40) ' 15
50 -L ET X=FNRI4)
60 LET Y=FNR 16)
70 PRINT "THE ENCLOSURE IS ";L ; " FEE T SQ UARE "
SO FOR 1=1 TO 2000 : NEXT I
90 GOSUB 2000 : BOSUE 700
100 GOSUS 280 : GOSU B 260
110 PRINT "HOW FAR TO DIG" ;
120 I NPUT F
130 GOSUS 260 : G05US 900
140 GOSUB 2000
150 IF Fe IL1100) *170+FNR 12'») I THEN GOTO 170
160 PRI NT "YOU COLLAPSE D FROM EXH AUS TI ON"
GOTO 4000
170 LET Xl=X / 5*L : LET Yl=Y / 7*L
180 LET Xl=Xl+X9 *F : LET Yl=Y l +Y9*F
190 IF Yl(O TH EN GOlD 300
200 IF Yl>L THEN GOlD 400
.,..••
21 0 IF 11( 0 THEN GO TO 500
220 IF Xl >L TH EN GO TO 600
230 PR I NT "YOU CAM E UP INS I DE TH E ENCL OSUR E"
240 PF:I NT "SAD LUCK'"
250 GO TO 4000
ESCAPE 63

b 26\ PRINT CHP$1311


5 261. PRI~T AT ,.. ,,):
d 26;' rr-:~IT @
V 26 1 " )
T '04D$\l9
Op! ;
270 RETURN
b 28 ' 1 r'RI fiB X"lf.l..+4,i+4);Utt';
5 28 11 PRI~'T AT Y+4,X"2+4; "ij';
d 28'1 PRINT @ ' +32+~":+1~ • '#";
v 2e PRIN- CH",fl¥ ::~~p Q-l TO Y+4.PRINT:NEXT
":PPINT -Af" •• '.'~:
290 RETURN
300 PRINT "YOU ARE IN THE FOREST"
310 LET X-FNR(3)-2 : LET Y-FNR(3)-2
320 LET A$-"COMPLETELY" : FOR I-I TO 6
...••
330 PRINT "YOU ARE ";At;" LOST ... "
340 GOSUS 900 : LET X-X+X9 : LET Y-Y+Y9
350 IF 1-0 AND Y-O THEN GOTo 390
360 LET At-"VERY"
370 IF 1-0 OR Y-O THEN LET A$-"SLIGHTLY"
380 NEXT I : PRINT "THE DOGS FOUND YOU'
BAD LUCK" : GO TO 4000
390 PRINT "YOU ESCAPED"!" WOW"" : GO TO 4000
400 PRINT "YOU ARE BY A ROAD"
410 IF X-lOR X-4 OR FNR(10)6 THEN GOTO 450
420 PRINT "THE GATE HOUSE COLLAPSED"
430 PRINT "ON TOP OF YOU! BAD LUCK'"
440 GOTO 4000
450 LET AI-"CAR"
460 GO TO 620
500 PRINT "YOU ARE IN A MINEFIELD"
510 PRINT "THERE ARE MINES ALL AROUND"
520 GoTO 310
600 PRINT "YOU ARE BY A RAILWAY"
610 LET At-"TRAIN" ,:
620 FOR I-I TO FNR(600)+200 : NEIT
630 LET C-FNR (2 6) : GoSUS 2000
640 PRINT "PRESS THE ":CHR$(64+C);" KEY TO
CATCH A ";AS
64 ESCAPE
vbd 6o . -or -~
s b5 1r =1
660 GOSUS 3000 : IF If-"" THEN NEXT I
670 IF l$-CHR$ (64+C) OR I$-CHR$ (96+C) THEN
GOTO 690
680 PRINT "YOU HAVE SEEN SPOTTED . 8AD LUCK'"
GOTO 4000
690 PRINT "YOU ESCAPED!!!! I PHEW!! II :
GOTO 4000
',1 fall' -.
710 PRINT TAB(5);"' • FOREST
720 PRINT TAB(7) ; 'I.'1
." ~.
730 PRINT TAB(4) ; "I--------I I-I"
740 PRINT "0 0 I I I-I R"
750 PRINT" 0 I I I-I A"
760 PRINT "M I I-I I "
770 PRINT "I 0 I I I-I L"
780 PRINT "N 0 I I I-I W"
790 P"' INT "E I I-I A" .~
801) PRINT "S 1----1 I I-I Y"
810 PRINT" 0 I-IGATEI-I I-I"
820 PRINT TAB(16);"I-I"
830 PRINT ----- --- --------------
840 PRINT - ROAD -

mm~~<~:~:~~::-~:~:~~~:~~--" IIII!
910 LET 19-(1 : LET Y9-0
;
920 INPUT Df
930 IF O$;;IIN OR 0$;;110" THEN LET Y9--!
U

94(, IF D$="5" OR D$:;1I5 THEN LET Y9-1


11

950 IF D$= ~J OR D$;::IIW" THEN LET X9--1


II II

960 IF D$="EII 0": D:t="e THEN LET 19-1


tl

970 IF X9~(' AND Y9=0 THEN GOTO 920


980 RETURN
ESCAPE 6S

For the different computers

BBC / Electron Dragon


1000 DEF FNRIX);RNDIX ) 1000 DEF FNRIX);RND IX)
1010 RETURN 1010 RETURN
2000 CLS : RETURN 2000 CLS : RETURN
3000 LET 1$;INKEY$ II) 3000 LET l$; I NKEY$
3010 RETURN 3010 RETURN
4000 END 40 00 END

zx Spectrum
1000 DEF FNRI X) 1000 DEF FNRIX)
;INTIRNDII)*X+I) ;INTIRND*X+I)
1010 RETURN 1010 RETURN
2000 PRINT CHR$11471; 2000 CLS : RETURN
: RETURN 3000 LET 1$;INKEY$
3000 GET 1$ 3010 RETURN
3010 RETURN 4000 STOP
4000 END

Changes you can make:


1) If your computer has a clock, you could
Incorporate this in the program to tell you
how long you tOOk to escape . Read your
computer manual about using the claCK , and
then add lines so that the tIme is set to
zero right at the start of the program, and
is then printed out at the end.

2 } You can change the speed of the reaction


testing part of the program that IS used if
your tunnel is near the road or the raIlway .
To make the game more dIffIcult, change the
number in line 650 to d smaller number.
66 · 13: SPACE DOGFIGHT
On the edge of the great space battle between your fleet and the
space fighters of Xaaxon, you have just engaged an enemy fighter
in a space dogfight above a deserted moon. You creep up behind
the ship, and have to try to decide what action to take at each
point in the game.
While the game is running, press the letter keys that correspond
to the actions you want to take. Note also that at most times you
can press 'F' for fire, even when, for instance, you are overtaking
the enemy ship.

10 GOSUe 1000 : GOSUe 2000


20 PRI NT 'SPAC E DOGFIGHT"
30 PRI NT
40 lE T D= 5
5 0 LET H::;5
60 PRINT "PRESS A KEY TO START";
70 GOSUB 3000 : IF IS="" THEN GOTO 70
80 FOR 1=1 TO 1500 : NEXT I : GOSUS 2000
90 IF 0)0 THEN PRINT "YOU ARE BEHIND HIM"
100 IF 0(0 THEN PRINT "HE IS BEHIND YOU"
110 IF 0=0 THEN PRINT "YOU ARE lEVEL"
120 FOR 1=1 TO 100 : GOSue 3000 : IF 11="
" TH EN NEXl
130 IF IS<)" F" AN D II()"I" THEN GOTO 200
140 IF 0=0 AND FNR(lOI\3 TH EN PRIN T "YOU HIT
HI M~II : GOTO 4000
15 0 IF 0) 0 AND 0(3 AND FNR(101(3 THE N PRINT
"HE lOST SP EED " : lET 0=0 -1
160 IF 0) 2 THE N PRIN T "TOO FAR AW AY"
170 IF 0<0 THEN PR I NT "YOU CAN T SH OOT BEH IND "
200 PRINT ny oU CAN: E- CLl MB"
21 0 PRINT A-A eCEl . "
220 PRINT D-DE CEl. "
230 PRINT X- DIVE "
SPACE DOGFIGHT 67

250 GOSUS 3000: IF 1$="11 THE,.. GOlD 250


260 IF I$="Au DR It=·a THEN LET 0=0-1
GOTO 800
270 IF I$=IIDII DR I$:lId" THEN LET 0=0+1
GOTO 800
280 IF Ij;=IIX DR I$="x THEN GOJO 400
Ii ll

290 IF I $; E" DR I$=lIe ll THEN GOlD 500


II

300 IF ABS(O»B THEN PRINT "YOU HAVE LOST SIGHT


OF HIM. " : GOTO 4000
310 GOTO 250
400 "GOSUB 2000
410 PRINT "YOU ARE DIVING .... "
420 LET H=H-i
425 IF H=O THEN PRINT "TOO LOW'" : GOTO 480
430 PRINT "YOU CAN: E-PULL OUT"
440 PRINT" X-LOOP UNOER"
450 FOR 1=1 TO 200 : GOSUS 3000 : IF 1$='" THEN
N~XT I
460 IF I$="E " OR 1$="." THEN LET 0=0-2 :
GOTO 800
470 IF (I$="X" OR It="x') AND FNR([0) <6 THEN
LET 0=0+2 : SOlO BOO
480 PRINT "YOU CRASHED INTO THE MOON!! '"
490 GOTO 4000
500 GOSUS 2000
510 PRINT "YOU ARE CLIMBING .... "
520 LET H=H+ 1
68 SPACE DOGRGHT
525 IF H=8 THEN PRINT 11100 HIGH! If: GO TO 580
530 PRINT "YOU CAN: E-LOOP OVER"
540 PRINT " X-PULL DUT il
550 FOR I =I TO 200 : GOSUB 3000 : IF I $= THEN
II II

NEXT I
560 IF I$="X" OR I$="x" THEN LET 0=D-2 : GOTO
800
570 IF (1$="E" DR l$="e") AND FNR(10) ( 8
THEN LET 0=0+2 : GOTO 800
580 PRINT "YOU LOST THE ATMOSPHERE' '"
590 GOTO 4000
800 FOR 1=1 TO 100 : GOSUS 3000 : IF IS="" THEN
NEXT I
810 IF ( l$ ="F" DR H ="f") AN D (0=0 OR 0=1) THE N
PRINT "HE'S DESTROY ED!" : GO TO 4000
820 IF 0) 0 DR FNR(10) ( 5 THEN GOTO 860
830 PRINT "HE FIRES , ","
840 IF FNR(10) ( 4 THEN PRINT "AND HITS YOU"!!"
GOTO 4000
850 PRINT" " , BUT MISS ES,"
860 IF Deo OR D)3 THEN GOTO 900
870 IF FNR(IO) ( 4 TH EN PRINT "HE DIVES AND LOOPS
UNDER" : LET 0=-0
900 GOTO 80
SPACE DOGFIGHT 69

For the different computers


, BBe/ Electron , Dragon
1000 DEF FNR(X)'RND(X) 1000 DEF FNR(X)'RND(X)
1010 RETURN 1010 RETURN
2000 CLS : RETURN 2000 CLS : RETURN
3000 LET I$=INKEY$ (1) 3000 LET I $. I NKEY$
3010 RETURN 3010 RETURN
4000 END I 4000 END
ZX-Spectrum
1000 DEF FNR(X) 1000 DEF FNR(X)
'INT(RND(I)*X+l) ·INT(RND*X+l)
1010 RETURN 1010 RETURN
2000 PRINT CHR$(147); 2000 CLS : RETURN
: RETURN 3000 LET I$'INKEY$
3000 GET 1$ 3010 RETURN
3010 RETURN 4000 STOP
4000 END
70 14:DEATH RAID
You are flying towards the distant location of the largest space war
in history. Your side is winning and you are going to support them .
Suddenly, fleeing enemy ships appear on your front scanner, as
they come out of hyperspace to refuel. You must try to locate their
position and speedily use your laser guns to shoot them down
before they can return to the safety of hyperspace.
The ships appear on a 7 by 7 grid on your screen. You must type
in the horizontal followed by the vertical position on the grid for
your laser to fire at. lust type in the two digits - there is no need to
press the 'return' or 'enter' key. Type as quickly as you can before
the enemy has a chance to get away.

2 3 4 5 6 7
r
T

2
~
3

4
t
5
1'"
6
T

10 G05 UB 1000 : G05U B 2000


20 PRIN T "DEATH RA I D"
30 PRIN T
40 LET 5; 0
50 FOR Y=I TO 7
~I
60 LET L$::II ___ " G05U B 300
70 LET l$="1 " GOSUB 300
80 NE XT Y
90 LET L $ ;;;II ___ " GO SUB 300
100 FOR G;1 TO 10
11 0 LET X=F NR(7)
DEATH RAID 71

120 LET Y=FNR(7)


130 LET P$:;tlSIf BOSUS 400
140 LET J$::!lll
150 FOR I =1 TO 300
160 GOSUS 3000
170 LET H=J$+ 1$
s 1 75 FOP ,= 1 TO 20 : NO T I-
180 IF LEN(J')(>2 THEN NEXT : GO TO 230
vbd 190 IF AL,LEFU(H,I' X OR ',AL IGHU
(Jt,l) \ THEN BOTO 23(1
s 190 IF VAL<H(I):OI OR VAL(H(2»), y
THEN GOTO 230
200 LET P$='.' : GOSUS 400
210 LET 5=5+1
220 FOR 1=1 TO 500 : NEXT I
230 LET P.=" , : G05US 400
240 NEXT G
250 G05UB 2000
260 PRINT 'YOU HIT ",S;" SPACESHIPS"
270 GO TO 4000
300 FOR 1=1 TO 7
bds 310 PRINT Lt,
v 310 PRINT LEFU(Lt,2I,
320 NEXT X
vbd 330 PRINT LEFH(U.l,
s 33(.PRINTL$d)
340 RETURN
b 400 PRINT 'AS(X13-2,Yf2 :);P$P~;
5 4Ul. AT ~.2+1,X.~-2:P$;F'$;
PRlt~,
d 4)0 PRIN] @'Y>04+Xf3-34).Pf,P$,
v 4(1" PRiNT CHIl'lI9);:FOR 0=1 TO v.2+I:PRINT:
_EiT Q:PRINT TAB X+2-1 ,Pf,
41 0 RE TU RN
72 DEATH RAID
For the different computers
SSe / Electron Dragon
1000 OEF FNR (X) =RNO (X) 1000 OEF FNR (X) =RNO (X)
10 10 RETURN 10 10 RETURN
200 0 CL5 : RETURN 2000 CLS : RETURN
3000 LET U = INKEY$ ( 1) 300 0 LET I$=INKEH
30 10 RETURN 301 0 RET URN
4000 END 40 00 END

zx Spectrum
100 0 OEF FNR (X ) 1000 OEF FNR (X)
=INT(RND(I)fX+I ) =INT ( RNO fX +I)
101 0 RETURN 101 0 RETURN
2000 PRINT CHR$ ( 14 7) ; 2000 CLS : RETURN
: RETURN 3000 LET 1$= I NKEY$
3000 GET 1$ 3010 RETURN
30 10 RETURN 4000 STOP
400 0 END

How the program works:


Lines 10-30 clear the screen and display tne
title of the gane .
Line 4 0 Sl?ts y our s c ore to zero (in 5) .
Lines 50-90 d.splay a grid on the screen, using
the subrout.ne at lines 300-340.
Line 100 is the start of a loop giving you ten
ships to hit.
Lines 11 0-12 0 choose the random position of the
enemy ship on your gr.d .
Line 13 0 marks this position with an ' 5 ' . The
subroutine at 400 displays the string at X,Y
on the grId.
Line 140 makes the input string empty .
Line IS O is the start of the loop giving you a
certain time to type in the two numbers.
DEATH RAID 73

Line 160 gets a character from the keyboard (if


there! and adds It to the end of the s tring
(if nothing IS pressed, then nothIng wi ll be
addedl .
Line 170 delays a while.
Line 180 checks if you hove pressed two ke ys,
and if not, repeats the loop , and then goes on
to 1 in e 230.
Lin. 190 checks if you got the two numb e rs
con ect. If nat, the computer wi i 1 go to 1 i ne
230 .
Line 200 displays a ',' where th e s h ip was, to
tell you that you hit it.
Line 210 increases your score by one .
Line 220 delays a whil e to let you see that you
hit the ship
Line 230 clears the ship to a space on th e
screen.
Line 240 is the end of the loop, giving you
another go, unless you have had ten .
Lines 250-270 clear the screen, tel; vou how
many ships you hit, and stop the pr ogram.
Lin.s 300-340 are a subroutine tha t pr i nts a
repeated row of the string LS, ending .ith th e
single character that begins L$ Ito make t he
picture tidyl .
Lin •• 400-410 print the string PI at th e co rre ct
position on the screen, dep e nding on X an d Y.
For s ome computers , P$ is print ed twic e t o
make it easier to s e e.
Lines 1000-4000 con t ain th e st and ard rou tine s .
74 DEATH RAID

Changes you can make:

1) You can change the number in line 100


to give you a greater or smaller number of
enemy shIps . If you chang e the t e n to
t welve,you will get twelve ships attacking.

2) You can make the game more of less


difficult by changing the value in line 150.
This controls the length of tIme allowed for
you to type in the two digits . If you
decrease the number to 150, the game will
get faster, and it will be more difficult to
fire at the enemy in time .

3) See if you can work out how to change


the scoring system , so that you get a
different score depending on how long you
took to shoot the enemy ship . You will need
to change line 210, and also the message In
line 260, since the score will no longer be
a count of the number of ships hit . Hint
use the va l ue of the variable in the loop
t hat gives you a certain time t o ent e r th e
h o digits .
15: COWBOYS AND INDIANS 75

ZX-Spectrum

A whole village depends on you. You, Wild Bill, are the only
person left who can defend the village from a group of advancing
Indians. You have got your trusty six-shooter, and you use it to kill
the Indians hiding behind the cacti, shooting one bullet at a time.
But you have to keep pausing to reload every six shots, in which
time the enemy will creep forwards and dead Indians will be
replaced with live ones.
The Indians will only come out of hiding for a few seconds - so
be quick! If you do not shoot, they will once again come closer. Let
them creep too close and you will be overwhelmed.
To move up and down press the A and Z keys respectively. To
fire, press the RETURN or ENTER key.

10 REM COWBOYS AND INDIANS


20 REM FOR THE lX-SPECTRUM
50 GOSUB 1000
60 GOSUB 1100
70 GOSUe 1200
80 GOSUB 1500
90 GOSU B 1600
100 GOSUB 2700
110 I F K=1 THEN LET S=S+l : LET K=O:GOSUB 2700
120 I F CM=O THEN GOTO 160
130 LET C=7:GCSUB 1700
140 LET :;Y =CY+CM : LET CM =O
150 LET C=S : GOSUB 1700
160 IF BE=O THEN GO TO 270
170 LET C=7:GOSUB 1900
180 LET BX=BXd
190 IF BX)30 THEN LET 8E=0:GOTO ~70
:00 LET P=ATTRIBY,8XI-56
210 IF P=? THEN LET C=2:
GOSUS 1900:60TO :70
220 IF P=4 THEN G05UB
2000:LET BE=O:
GOTO 270
76 COWBOYS AND INDIANS
230 FOR J=l TO 3
240 IF BY 'iiJ)-3 AND BY'.YiJH: THEN LET I(JJ=O:
LET MiJ)=l: LET 1'=1
250 NEXT J
260 LET BE=O
270 FOR J=I TO 3
280 IF MiJ)=O THEN GO TO 340
290 LET C=7:GOSUB 1800
300 LET HiJI=l-H(J):LET M(J)=I)
310 IF I(J)=O THEN GOSUS 2400:GOTO 340
320 GOSUB 2300
330 LET C=5:GOSUB IBOO
340 NEXT J
350 LET Ir=INKEYI
370 IF IS=' AND BE=O THEN LET I=Z+I:GOTC 420
380 LET z=o
390 IF (I$="A" OR 1S="a "J AND CF= .. AND CY
THEN LET CM=-l
400 IF ( I$= 'Z" OR U="o"iAND CR=v AND C'I<18
THEN LET CM=!
410 IF I$=CHR'(13) AND CR=O AND BE=O
THEN GOSUB 2500
420 IF Z=40 THEN GO TO 440
430 LET CR=CR+SGN(CR) : IF CR ( 20 THEN GOTO 460
440 LET MX=MI-5:IF MX=O THEN GOSUB 2800:STOf
450 GOTO 80
460 FOR J=l TO 3
470 IF I(J)=l AND H(J)=O AND RND " .Ol
THCN LET r(J)=l
480 NEXT J
490 FOR J=l TO 3
500 IF H(J)=O OR I(J)=O THEN GOTO 520
510 LET I(J)=I(J)+l:IF I J)=MX'IO
THEN LET M(JJ=l:LET !(J)=l
520 NEXT J
530 IF 1(1)+1 (2)+1 (3)=0 THE~ GOSUB 2600:5iOP
540 'GOTO 110
1000 REM INITIALIZE
1020 LET MX=25:LET S=O:LET BN=O
COWBOYS AND INDIANS 77

1030 DIM Y(3):DIM I(3) : DIM H(3):DIM M(3)


1050 RETURN
1100 REM DEFINE CHARACTERS
1110 FOR 1=65 TO 82
1120 FOR J=O TO 7
1130 READ D
1140 POKE USR CHRI(I)+J,D
1150 NEXT J : NEXT I
1160 RETURN
1200 REM DISPLAY TITLE
1210 CLS
1220 PRINT HT 4,14;INK 2j"COWBOYS"
1230 PRINT AT 6, 16j INK 4; "AND"
1240 PRINT AT B,14;JNK 5j"INDIANS"
1250 INK 0: PRINT AT 16,0;" A TO GO UP'
1260 PRINT" Z TO GO DOWN"
1270 PRINT "ENTER TO FIRE"
1280 FOR 1=1 TO 500 : NEXT
1290 RETURN
1500 REM SET UP VARIABLES
1510 LET CX =2: LET CY=18 : LET CR=O : LET CM=I
1520 LET BX=D:LET BY=O:LET BE=O
1530 LET YII)=3 : LET YI21=10 : LET Y131=17
·1540 LET III)=I : LET J(2)=I:LET 1(3)=1
1550 LET rlll)=I : LET H(2)=I:LET H(3)=1
1560 LET Mll)=I : LET M(2)=I : LET M(3)=1
1570 LET IX=4:LET k=O:LET l=O
1580 RETURN
1600 REM DISPLAY GAME SCREEN
1610 INK 7: CLS
1620 LET C=I : GOSUB 2100
1630 LET C=2 : GOSUB 2100
1640 LET C-3 : GOSUB 2100
1650 RETURN
1700 REM DRAW COWBOY
1710 INK C
1720 PRINT AT CY,CX;CHR$1,144)
1730 PRINT AT CY+I,CXjCHR$(145)
1740 PR I NT AT CY+2,CXjCHR$I!46)
78 COWBOYS AND INDIANS
1750 RETURN
1800 REM DRAW INDIAN
1810 lNK [
1820 PRINT ~T YIJI-HIJ)<:,MI+1K;CHRII1591
1830 PRINT AT YIJI-HIJI12+I,MX+IX;CHRSI16UI
1840 PRINT AT YIJI-HIJI'2+2,MX+II;CHR$(161)
1850 F'ETuf;N
1900 REM DRAW BULLET
1910 PF, INT AT BY ,BX; INK Cj 'I_1I
1920 RET UhN
2000 REM SPLAT CACTUS
201(1 INK 7
2020 PRINT AT B'I-l, BI ; "
2030 PRINT AT BY,SX; " "
2040 PRINT AT BY+I ,B X; "
2050 RETURN
2100 REM DRAW CACTUS
2110 INK 4
2120 PRINT AT VICI ,M XiCHR$11471;CHRS(1521;
CHR S I 1551
2130 PRINT AT YICI +I,MXiC HRSI14Bl i CHR$1153I i
CHR$ 11 56 1
2140 PRINT AT YICI+2,MX i CHR $ 11491 ;CHR$ 115 41 i
CHR$11571
2 15 0 PRINT AT YICI +3 ,MXiCHRSI150I iCHR$ 11531;
CHRS ' 1581
2160 PRINT AT YICI+4 , MX : CHR I I1511.;CH R$11531;
CHR$ (1 58 1
2170 RETURN
2200 REM BANG SOUND
2210 FOR 1~1 TO 15 STEP 2:BEEP " . 0111 , 0:
BEEP 0 .01 1l ,IO:NEXT I
2220 RETURN
2300 REM PING SOUND
2310 BEEP . 05,24
2320 RETURN
2400 REM lEAD INDIAN SOUND
2410 BEEP .2,-10
2420 RETURN
COWBOYS AND INDIANS 79

2500 REM GUN FIRE ROUTINE


2510 LET BE~l, LET BX~CX+l: LET BY~CY+l,
LET BN~BN+l
2520 IF BN=7 THEN LET BN=O: LET BE=O ,
LET CR= 1: RETURN
2530 GOSUB 2200
2540 RETURN
2bOO REM PLAY ER WON
2610 CLS: INK 0
2620 PRINT "THE REST OF THE INDIANS"
2630 PRINT "HAVE RUIJ AWAY. YOU SAVED"
2640 PRINT "THE VILLAGE'"
2650 RETUEN
2700 REM DISPLAV SCORE
2710 PF:INT AT O,O,INf " : "INDIANS fILLED: " :5
2720 RETURN
2800 REM PLAYER LOST
2810 CLS: INk (I
:820 PRINT "YOU HAVE BEEN OVERWHELMED"
2830 PRINT "BY THE INDIANS. BAD LUCK'"
2840 RETUHN
3000 DATA 60,60,~55!60,oO,60,56.254
3010 DATA 146,146,146,146,186,154,138,1.38
3030 DATA 138,254~40,40,40.40,44,48
3050 DATA 0,0,0,0,0,',14,14
3060 DATA 14,14,14,14,14,15,7,1
3070 DATA 0,0,8,28,28,28,28,28
3080 DATA 29,28,28,28,28,28,28,31
3090 DATA 15,7,0.0,0,0,0,0
3100 DATA 56,124,124,254 . 254,254,254,254
3110 DATA 254,254,254,254,254,254,254,254
3120 DATA 255,255,255,254,254,254,254,254
3130 DATA 0,0,0,0,0,0,0,32
3140 DATA 112,112,112,112,112,112,112,112
3150 DATA 240,224,192,0,0,0,0,0
3160 DATA 0,0,0,0,0,0,0,0
3200 DATA 4,8,8,60,60,60,60 , 28
3210 DATA 124,68 , 68,68,68,68 , 68,68
3220 DATA 124,40,40 , 40 , 40,40, 104 . 24
80 16 : COWBOYS AND INDIANS
VIC
A whole village depends on you. You, Wild Bill, are the only
person left who can defend the village from a group of advancing
Indians. You have got your trusty Six-shooter, and you use it to kill
the Indians hiding behind the cacti, shooting one bullet at a time.
But you have to keep pausing to reload every six shots, in which
time the enemy will creep forwards and dead Indians will be
replaced with live ones.
The Indians will only come out of hiding for a few seconds - so
be quick! If you do not shoot, they will once again come closer. Let
them creep too close and you will be overwhelmed.
To move up and down press the A and Z keys respectively. To
fire, press the RETURN or ENTER key_

10 REM COWBOYS AND INDIANS


20 REM FC~ THE VIC
4.) GOSUB 1o(}I)
60 GOSUB 1 ~(j\)
SO GOSUEt 1500
90 GOSUB 1601)
100 GOSUS 271)0
110 IF '-l THEN S-S+I : K-O : GOSUB 2700
120 IF eM-O THEN 16(,
130 C-l:G05U8 !700
140 [Y-Cy·eM : CM=O
150 C-3:GOSUB 1700
160 IF 8E-(I THEN 270
170 C=I:GOSUB 1900
180 BX=8X'1
190 IF 81 , 21 THEN BE-D:GOTO 270
200 P-PEEf (38378+SY<22+SXl AND 7
210 IF pol THEN C-2:GOSU2 1900 : EOTO 270
220 IF P-5 THEN GOSUS 2000 : BE-0:GOTO 270
230 FOR J·l TO 3
240 IF SY ' YIJ)-4 AND BY(YIJ)+4
THEN [IJ)=O:MIJ)=I:f:'=1
250 NEXT
COWBOYS AND INDIANS 81

260 8E=0
270 FOR J=! TO 3
280 IF MIJ)=O THEN 340
290 C=l:GOSUB 1800
300 HIJ)=l··HIJ):MIJ)=1)
310 IF IIJ)=O THEN G05UB 2400:GOTO 340
320 GOSUB 2300
330 C=3 : G05UB 1800
340 NEXT
350 GET Jj"
370 IF IS="" AND BE=O THEN Z=Z+l : GOTO 4~O
380 Z=0
390 IF I.="A" AND CR=(i AND CY)2 T~EN CM=-l
400 IF I$="Z' AND CR=O AND CY<19 THEN CM=l
4]0 IF U=CHR$I]3) AND CR=O AND BE=O
THEN GOSUB 2500
420 IF Z=40 THEN 440
430 CR=CR+SGNICR) : IF CR(20 THEN 460
440 MX=MX-3:IF MI=l THEN GOSU8 2800:END
450 CR=O:GOTO 80
460 FOR J=l TO 3
470 IF IIJ)=l AND HIJ)=I) AND RND(1) \ ,Ol
THEN MIJ)=l
480 NEXT
490 FOR J=l TO 3
500 IF HIJ)=O OR IIJ)=O THEN 520
51(, liJ,=IIJ)+i:P' I(J)=MX +l0 THEN MI.JI =l:
IlJ)=1
521) NEXT
530 IF !ll)+1121+11})=0 THEN GOSUB 2600 : END
540 GOTD 110
1000 REM INITIALIZE
lOll) MX=16 : S=O : BN=O
1020 DIM V(3) , 1(3) ,H(3) ,M(3)
1030 POkE 36879,25
104,) RETURN
1200 REM DISPLAY TITLE
1210 PRINT eHRS(147)
82 COWBOYS AND INDIANS
1220 PRINT TAB(8) jCHR$(159) j "COW80YS'
1230 PRINT TAB(IO),CHR$(30),"AND"
1240 PRINT TAB(8)jCHR$(28)j"INDIANS"
1250 PRINT,PRINT
1260 PRINT CHR$(144)
1270 PRINT A TO GO UP·
1280 PRINT Z TO GO DOWN"
1290 PRINT "RET TO FIRE"
1300 FOR 1=1 TO 2000:NEXT
1310 RETUf\N
1500 REM SET UP VARIABLES
1510 CX=2:CY=18:CR=O:CM=1
1520 BX=O:BY=O:BE=O
1530 Y(I)=5:Y(2)=12:Y(3)=19
15401(11=1:1(21=1:1(31=1
1550 H(!I=I:H(21=I:H(31=1
1560 M(II=I:M(21=I:M(31=1
1570 ;X=5:K=0:Z=0
1580 RETURN
1600 REM DISPLAY GAME SCREEN
1610 PRINT CHR!(147Ij
1620 C=I:GOSUS 2100
1630 C=2:GOSUS 2100
1640 C=3:S0SUS 2100
1650 RETURN
1700 REM DRAW COWBOY
1710 P=CX+CY*:2+7658
1720 POKE P,254:POKE P+I,252:POKE P+22,225:
POKE P+23,126
1730 POKE F+44,225:POKE P+45,97:POKE P+66,225:
POKE P+b7, 126
1740 POKE F+88,225: POKE p t 8?,I23
1750 FOR X=O TO I:FOR Y=0 TO 4:
POKE P+X+Y'22+30720,C:NEXT:NEXT
1760 RETUR~
1800 RE~ DRAW INDIAN
1810 P=MX+!).+i\ (JI-H (J ; f31<22+7658
1820 POKE F,B5:POKE P+22,81:POKE P+44,91:
POKE P+66,113
COVVBOYSANDINDU\NS 83

IB30 FOR V=O TO 3:POKE P+Y<22+30720,C:NEXT


1840 RETURN
1900 REM DRAW BULLET
1910 P=BX+BY>22+7658
1920 POKE P,9B:POKE P+30720,C
1930 RETURN
2000 REM SPLAT CACTUS
2010 P=BX+BY>22+7658+30720
2020 POKE P,I:POKE P+22,I:POKE P+44,1
2030 RETURN
2100 REM DRAW CACTUS
2110 P=MX+Y(C)122+7658
2120 POKE P,225:POKE P+l,108:POKE P+2,252
2130 POKE P+22,225:POKE P+23,225:POKE P+24,224:
POKE P+25,225
2140 POKE P+44,124:POKE P+45,251:POKE P+46,224:
POKE P+47,254
2150 POKE P+67,225:POKE P+6B,224
2160 FOR x=o TO 3:FOR V=0 TO 3:
POKE P+X+YIZ2+30720,5:NEXT:NEXT
2170 RETURN
2200 REM BANG SOUND
2210 POKE 36877,240
2220 FOR V=15 TO 1 STEP -I
2230 POKE 36B7B,V
2240 NEXT
2250 FOR Q=I TO 80:NEXT
2260 POKE 36877,0
2270 RETURN
2300 REM PING SOUND
2310 POKE 36874,252
2320 FOR V=15 TO 1 STEF -I
2330 POKE 36878,V
2340 NEXT
2350 FOR Q=1 TO 80:NEXT
2360 POKE 36874,0
2370 RETURN
2400 REM DEAD INDIAN SOUND
2410 FOR V=12 TO ! STEP -I
2420 POKE 36B74,V+IO+130
2430 POKE 3687B,V
2440 NEXT
2450 POKE 36874,0
2460 RETURN
2500 REM GUN FIRE ROUTINE
2510 BE=I:BX=CX+2:BY=CY+I:BN=BN+I
2520 IF BN=7 THEN BN=O:8E=O:CR=I:RETURN
2530 GOSUS 2200
2540 RETURN
2600 REM PLAYER WON
2610 PRINT CHR.CI47)
2620 PRINT "THE REST OF THE"
2630 PRINT "INDIANS HAVE RUN AWAY."
2640 PRINT "YOU SAVED THE VILLAGE"
2650 RETUF:N
2700 REM DISPLAY SCORE
2710 PRINT CHR$(19); "INDIANS KILLED: ";5
2720 RETURN
2800 REM PLAYER LOST
2810 PRINT CHRt(147)
2~20 PRINT "YOU HAVE BEEN"
2830 PRINT "OVERWHELMED BY THE"
2840 PRINT "INDIANS . BAD LUCK'"
2850 RETURN
17: COWBOYS AND INDIANS 85

BBC/ Electron
A whole village depends on you. You, wild Bill, are the only
person left who can defend the village from a group of advancing
Indians. You have got your trusty six·shooter, and you use it to kill
the Indians hiding behind the cacti, shooting one bullet at a time.
But you have to keep pausing to reload every six shots, in which
time the enemy will creep forwards and dead Indians will be
replaced with live ones.
The Indians will only come out of hiding for a few seconds - so
be qUick! If you do not shoot, they will once again come closer. Let
them creep too close and you will be overwhelmed.
To move up and down press the A and Z keys respectively. To
fire, press the RETURN or ENTER key.

10 REM COWBOYS AND INDIANS


20 REM FOR THE BBC / ELECTRON
30 110DE 5
40 PROClNlT
50 PROCCHARS
60 PROCTITLE
70 PROCENVELOPE
80 PROCVARS
90 PROCSCR EEN
100 FROCSCOR E
110 IF K-l THE N S- S+I: K-O : PROCSCORE
120 IF CM - O THE N 160
130 PROC CO WB OYICI,CY,O , CL,OI
140 CY-CY +CM *20 : CM=O : CL -I - CL
150 PROCC OWBO YI CI , CY,3 , CL, Ol
160 I F 8E-0 THE N 270
170 PROC BULL ETIB.,BY,OI
180 8X-BI +25
190 I F BI ) 1200 TH EN BE-O : GO TO 270
200 P-PO I NTI BX+I0,BY)
210 IF P-O THEN PROCBULL ETIBX,BY,I) : GO TO 270
220 IF P-2 THE N PROCSPLATIBX -2 0 ,B Y+50) : BE-O :
GOTO 270
86 COWBOYS AND INDIANS
230 FOR J=1 TO 3
240 IF BY >Y( J)-90 AND BY (Y(J) <!10
THEN I(J)'O:M(J)'I:K=1
250 NEXT
260 8E=0
270 FOR J=1 TO 3
280 IF M(J)'O THEN 340
290 PROCINDIAN(MX<IX,Y(J)<H(J)*100,O)
300 H(J)'I-H(J):M(J)=O
310 IF I (J)=O THEN PROCDEAD:GOTO 340
320 PROCPING
330 PROCINDIAN(MX<IX,Y(J)<H(J)*100,3)
340 NEXT
350 1$=INKEY$(l)
360 *FXI5,1
370 IF 11="" AND 8E=0 THEN Z=Z<I:GOTO 420
380 ZoO
390 IF II'"A" AND CR=O AND CY ( 980 THEN CM=!
400 IF I$="Z" AND CR=O AND CY)!OO THEN CM=-!
4! 0 IF I$=CHR$ (!3) AND CR,O AND 8E=0
THEN PROCFIRE
420 IF Z=40 THEN 440
430 CR'CR<SGN(CR) : IF CR<20 THEN 460
440 MX,MX-200: IF MX=O THEN PROCLDST:END
450 CR=O:GOTO 80
460 FOR J = 1 TO 3
470 IF I (J) , 1 AND H(J)=O AND RND(l) <'O !
THEN M(J)=!
480 NEXT
490 FOR J=! TO 3
500 IF H(J)=O OR 1 (J ) =0 THEN 520
510 I (J)=I (JHl : 1F I(J)=MX/l0
THEN M(J)=I: 1 (J)'1
520 NEXT
530 IF 1(1»1(2HI(3)=0 THEN PROCWON:END
540 GOTO 110
1000 DEF PROCINIT
1010 *FXll,!
1020 *FXI2,1
COWBOYS AND INDIANS 8

1030 MX=800:S=0:BN=0 : DIM Y(3) ,1(3) ,H(3) ,M(3)


1040 VDU 19,0,7;0; 19,2,2;0; 19,3,6;0;
1050 ENDPROC
1100 DEF PROCCHARS
1110 FOR C=224 TO 246
1120 VDU 23,C
1130 FOR 1=1 TO 8
1140 READ D : VDU D
1150 NEXT: NEXT
1160 ENDPROC
1200 DEF PROCTITLE
1210 VDU 5
1220 MOVE 448,800 : GCOL 0,1
1230 PRINT 'COWBOYS'
1240 MOVE 576,700 GCOL 0,2
1250 PRINT 'AND'
1260 MOVE 448,600 GCOL 0,3
1270 PRINT 'INDIANS'
1280 MOVE 0,300
1290 PRINT A TO GO UP'
1300 PRINT" Z TO GO DOWN'
1310 PRINT 'R ET TO FIRE'
1320 PROCCACTUS(100,900) : PROCCACTUS(900,200)
1330 I=INV EY(200)
1340 ENDPROC
1400 DEF PROCENVELOPE
1410 ENVELOPE 1,0,0,0,0,0,0,0,64,-5,-2,-20,
126,60
1420 ENVELOPE 2,0,0,0,0,0,0,0,64,-5,-10,-1,
126,60
1430 ENVELOPE 3,1,-5,0,0,30,0,0,64,-4,-1,-1,
126,60
1440 ENDPROC
1500 DEF PROCVARS
1510 CX=20:CY=80:CR=O:CM=I:CL=0
152 0 BX=O:8Y=O:BE=O
1530 Y(I)=250 :Y(21=550: Y(31 =850
1540 1(1)=1:1(2)=1:1(3)=1
1550 H(II=I:H(2)=I:H(31=1
1560 M(I)=I:M(2)=I:N(3)=1
1570 IX=200:K=0:Z=0
1580 ENDPROC
1600 DEF PROCSCREEN
1610 CLS
1620 PROCCACTUS(MX,Y(I))
1630 PROCCHCTUS(NX,Y(2))
1640 PROCCACTUS(MX,Y(3))
1650 ENDPROC
1700 DEF PROCCOW80Y(X,Y,C,L,F)
1710 MOVE X. Y : GCOL O,C
1720 VDU 224,8,10,225+F,8,10,227+L
1730 ENDPROC
1800 DEF PROCINDIAN(X,Y,C)
1810 MOVE X,Y : GCOL o,e
1820 VDU 244,8,10,245,8,10,246
1830 ENDPROC
1900 DEF PROCBULLET(X , Y,C)
1910 NOVE X,Y : GCOL o,e
1920 DRAW 1'10,Y
1930 ENDPROC
2000 DEF PROCSPLAT(X,Y)
2010 MOVE X,Y : GCOL 0,0
2020 VDU 241,8,10,242,8,10,243
2030 ENDPROC
2100 DEF PROCCACTUS(X,Y)
2110 MOVE I , Y : GCOL 0,2
2120 VDU 229,234,237,10,8,8,8
213(' VDU 230,235,238,10,8,8,8
2140 VDU 231,236,239,10,8,8,8
2150 VDU 232,235,240,10,8,6.8
2160 VDU 233,235,240
COWBOYS AND INDIANS 89

2170 ENDPROC
2200 DEF PROCBANG
2210 SOUND &10,1,5,10
2220 ENDPROC
2300 DEF PROCPING
2310 SOUND &11,2,200,5
2320 ENDPROC
2400 DEF PROCDEAD
2410 SOUND &12,3,200,35
2420 ENDPROC
2500 DEF PROCFIRE
2510 BE=I :B I=CI+80 : BY=CY-30 : BN=BN+1
2520 IF BN=7 THEN 8N=0 : BE=O : CR=1:ENDPROC
2530 PROCCOW80Y ( C~,CY,O,CL,OI
2540 PROCCOWBOY (CI,CY,3,CL, II
2550 PROCBANG
2560 PROCCOWBOY(CI , CY,O,CL, 11
2570 PROCCOWBOY(CI,CY,3,CL,01
2580 ENDPROC
2600 DEF PROCWON
2610 VDU 4,12 : COLOUR J
2620 PRINT ' "THE REST OF THE"
:630 PRINT . 'INDIANS HAVE RUN"
2640 PRINT . "AI~AY , YOU SAVED"
2650 PRINT "THE VILLAGE,"
2660 <FI12,O
2670 ENDPhOC
2700 DEF PROCSCORE
27!(1 VDU 4,30
2720 PRINT "INDIANS KILLED: " ; S
2730 \lDU 5
2740 ENDPROC
90 COWBOYS AND INDIANS
2800 DEF PROCLOST
2810 VDU 4,12 : COLOUR
2820 PRINT ' ' "YOU HAVE BEEN"
2830 PRINT' >"OVERWHELMED BY"
2840 PRINT ' '"THE INDIANS"
2850 SOUND 1,-10,16,8 : SOUND 1,-10,0,10
2860 *FXI2,0
2870 ENDPROC
3000 DATA 60,60,2~5,60,60,60,56,254
3010 DATA 140,146,146,146,186,154,138,138
3020 DATA 130,159,130,130,130,130,130,130
3030 DATA 138,254,40,40,40,40,44,48
3040 DATA 138,254,40,40,40,40,56,12
3050 DATA 0,0,0,0,0,4,14,14
3060 DATA 14,14,14,14,14,15,7, I
3070 DATA 0,0,8,28,28,28,28,28
3080 DATA 28,28,28,28,28,28,28,31
3090 DATA 15,7,0,0,0,0,0,0
3100 DATA 56,124,124,254,254,254,254,254
3110 DATA 254,254,254,254,254,254,254,254
3120 DATA 255,255,255,254,254,254,254,254
3130 DATA 0,0,0,0,0,0,0,32
3140 DATA 112 , 112 , 112 , 112,112,112,112,112
3150 DATA 240,224,192,0,0,0,0,0
3160 DATA 0,0 , 0,0,0,0,0,0
3170 DATA 0,0,0,192,192,248,252,255
3180 DATA 254,255,~55,254,254,255,255,255
3190 DATA 254,248,240,224,192,0,0,0
3200 DA TA 4,8,8,60,60,60,60,28
3210 DATA 124,68,68,68,68,68,68,68
3220 DATA 124, 40,40,40,40,40.104,24
18: COWBOYS AND INDIANS 91

Dragon
A whole viDage depends on you. You, wild Bill, are the only
person left who can defend the village from a group of advancing
Indians. You have got your trusty Six-shooter, and you use it to kill
the Indians hiding behind the cacti, shooting one bullet at a time.
But you have to keep pausing to reload every six shots, in which
time the enemy wiD creep forwards and dead Indians wiD be
replaced with live ones.
The Indians wiD only come out of hiding for a few seconds - so
be quick! If you do not shoot, they will once again come closer. Let
them creep too close and you will be overwhelmed.
To move up and down press the A and Z keys respectively. To
fire, press the RETURN or ENTER key.

10 REM COWBOYS AND INDIANS


20 REM FOR THE DRAGON
40 GOSUS 1000
60 GOSUB 1200
80 GOSUS 1500
90 GOSUS 1600
100 GOSUS 2700
110 IF K-l THEN S-S+I:K-O:GOSUB 2700
120 IF CM=O THEN 160
130 C-2:GOSUB 1700
140 CY=CY+CM*5 : CM-O
150 C-3:GOSUB 1700
160 IF DE=O THEN 270
170 C-2:GOSUB 1900
180 BX=EX+B
190 IF BX)240 THEN BE=O:GOTO 270
200 P-PPOINT(BX+6, EYI
210 IF P-2 THEN C=4:GOSUB 1900:GOTO 270
220 IF P-l THEN GOSUS 2000:BE=0:60TO 270
230 FOR J=1 TO 3
240 IF BY)Y(JI-26 AND BY (Y(JI +26 THEN I(JI=O :
MiJI=I : K=1
250 NEXT
92

260 BE=O
270 FOR J=1 TO 3
280 IF M,J)=O THEN 340
290 C~2:GOSUB 1800
300 H(J)=I··H(J):M(J)=O
310 IF I(J)=O THEN GOSUB 2400:60TO 340
320 GOSUB 2300
330 C=3:GOSUB 1800
340 NEXT
350 1$=INI EVt
370 IF 1$=" AND 8E=0 THEN Z=2+1:GOTO 420
380 Z=0
390 IF II='A' AND CR=O AND CYi5 THEN CM=-1
400 IF I'='Z' AND CR=O AND CY<160 THEN CM=1
410 IF I$=CHR$(13) AND CR=O AND BE=(I
THEN GOSUB 2500
420 IF Z=4V THEN 440
430 CR=CR+SeN (CIi) : IF CR 20 THEN 460
44v MX=MX-50 : IF MX=O THEN BOSUB 2800 : END
450 CR=O:GO·O 80
460 FOR J=I TO 3
470 IF I (J)=1 AND H(J)=O AND RND,(»)' .01
THEN M(JI=1
480 NUT
490 FO~ J=1 TO 3
500 IF H(J)=O OR I(J)=O THEN 520
510 I(J)=l i JI+I:IF I(J)=hX/5 THEN H(J)=I:I(J)=l
520 NE Xl
530 IF 1111+1(2)+1(31=0 THEN GOSUB 2600 : END
540 GOTO 11')
1000 REM INITIALIZE
1010 MX=200 : S=O : BN=O
1020 DIM VI3), 113! ,H(3) ,~1(:,)
1030 RETURN
1200 REM DISPLA\ TITLE
1210 CLSO
1220 PRINT @77,'COW80YS",
1230 PRINT @143,'AND' ,
1240 PRINT @205,'INDIANS';
COWBOYS AND INDIANS 93

1250 PRINT @384. " A TO GO UP " ,.


1260 PRINT @416. " Z TO GO DOWN· j
1270 PRINT @448.·ENTER TO FIRE " .,
1280 FOR 1=1 TO 2000:NEXT
1290 RETURN
1500 REM SET UP VARIABLES
1510 CX=16:CY=155 : CR=0:CM=1
1520 B~=O:BY=O:BE=O
1530 Y(I)=40:Y(2 ) =IOO:Y(3)=160
1540I(l)=I:I(2)=I:I!3)=1
1550 H(I)=I:H!2)=I:H(])=1
1560 M([)=I :M (2)=I : M(3)=J
1570 IX=30:K=0:Z=0
1580 RETURN
1600 REM DISPLAY GAME SCREE~
1610 PHODE 3.I:SCREEN 1.0
1620 COLOR 1.2:PCLS
1630 C=I:G05UB 2100
1640 C=2:GOSUB 210 0
1650 C=3:GOSUB 2100
1660 RETURN
1700 REM DRAW COWBOY
1710 DRAW ·BM·.STR$(CX).·.·.STR$(CY)
1720 CO LOR C
1730 DRAW ·02L4R 4D6L2DI ORIOUIOL4U2R2U 4R4L4U2L6·
94 COVVBOYSANDINDV\NS
1740 DRAW "BM+O,+18DIOR2BM+2,-IODI2R2"
1750 PAINT (CX+4,CY+4)
1760 RETURN
1800 REM DRAW INDIAN
1810 DRAW "8M"+STRI(MX+IX)+",
"+STR$(Y(J)-HIJ)*25)
1820 COLOR C
1830 DRAW 'D6R2D2L4DIORIOUI8L8R4U2E2"
1840 DRAW "BM+O,+22D8L2BM-2, - 8DIOL2"
1850 PAINT (MX+IX+4,Y(J)-H(J)*25+4)
1860 RETURN
1900 REM DRAW BULLET
1910 COLOR C
1920 LINE (BX,BY)-(8X+5,BY) ,PSET
1930 RETURN
2000 REM SPLAT CACTUS
2010 DRAW "BM"+STR$IBX)+","+STR$IBY-8)'"C2"
2020 DRAW "NRIDINR2DINR3DINR6DINR7DINR9DINR9DI
NR8DINR9DINR9DI"
2030 DRAW "NR8DINR8DINR7DINRBDINR9DINR7DINR5DI
NR3DINR2DINR1"
2040 RETURN
2100 REN DRAW CACTUS
2110 DRAW "BM"+STR$(MX)+","+STRS(Y(C))
2120 DRAW "DI6L2H2U8H2G2DI2F4R4D8RI0UIO"
2130 DRAW "R4E4UI6H2G2DI2G2L2UI4H4L2G4"
2140 PAINT (MX<4,Y(C)+4)
2150 RETURN
2200 BEN BANG SOUND
COWBOYS AND INDIANS 95

2210 PLAY "0ITl00":FOR 0=31 TO 7 STEP ··2 :PLAY


"V"+STR$(Q)+uGB"
2220 NEXT
2230 RETURN
2300 REM PING SOUND
2310 PLAY "04T50":FOR Q=31 TO 5 STEP -3:PLAY
"V"+STR:t(Q)+ "B"
2320 NEXT
2330 RETURN
2400 REM DEAD INDIAN SOUND
2410 PLAY "T804V30CG05C"
2420 RETURN
2500 REM GUN FIRE ROUTINE
2510 BE=I : BX=CXt\O:BY=CYt\D : BN=BNt \
2520 IF 8N=? THEN 8N=O : BE~O:CR~\:RETURN
2530 GOSUS 2200
2540 RETURN
2600 REM PLAYER WON
2610 PRINT @384,"THE REST OF THE INDIANS HA~E"
2620 PRINT "RUN AWAY . YOU SAVED THE VILLAGE"
2640 RETURN
2700 REM DISPLAY SCOR E
2710 SCR EEN O,O:CLS 4
2720 PRINT @262,"INDIANS KILLED : "is :
2730 FOR O~I TO IODO : NEXT
2740 SCREEN \,0
2750 RETURN
2800 REM PLAYER LOST
2810 PR I NT @384,"YOU HAVE BEEN OVERWHELMED"
2820 PRINT "8Y THE IND I ANS . BAD LUCK '"
2830 RETURN
HOW TO WRITE VOl
Sabotage is given as an example of how to write a simple game
program. The first thing you need to do before writing a game is to
think of an idea. The idea must really be based on what you know
the computer can and cannot do. You should know, for example,
how the computer can store and recall numbers and words, and
how it can make decisions depending on these numbers or words.
You must try to think through your idea in a logical way, and try to
write down something like this:
1. There is a bomb on a spaceship.
2. There are eight places where it could be, but you only have time
to check three of them .
3. If the bomb is found, you then have to defuse it quickly.
4. To defuse the bomb, you must guess a secret number. You have
a limited number of guesses, but the computer tells you if your
guess is too high or too low.
Once you have an idea of some sort you can start to plan out the
game. If your idea isn't completely clear, then don't despair - you
may find th.t it gets better as you go along. The best way to start is
to write down a series of simple steps that make up the game.
Write them in English, but try to split them up into things that you
know the computer can do. In our case, the list would look
something like:
1. Set up the game:
(al Start the game and print out the title.
(bl Decide where the bomb is hidden and what the secret code is
going to be.
2. Get a chOice from the player:
(al Ask which section of the spaceship he wants to look in.
(bl Get his answer.
(cl Check if he guessed the right section.
3. Give the player three chances to find it. Make a loop that starts
just before 2(al and ends just after 2(c). This loop should give the
player three chances to check a section of the spaceship.
SABOTAGE 97

4. If the player doesn't find the bomb after three tries, print a
message saying that the ship has blown up, and stop the game.
5. If the player guesses the position of the bomb in time, print a
message saying that he has found it.
6. Defusing the bomb:
(a) Print a question asking for the code number to defuse the
bomb.
(b) Get an answer from the player.
(c) Check if he got the correct code.
(d) If not, print a message telling him if his guess was higher or
lower than the actual code.
7. Give the player six chances to guess the code. Make a loop that
starts just before 6(a) and finishes just after 6(d). This loop
should give the player six guesses at the code to defuse the
bomb.
8. If the player doesn't guess the code after six tries, print a
message saying that the ship has blown up, and stop the game.
9. If the player guesses the code, print a message telling him so,
print 'WELL DONE', and stop the game.

It may take several tries to get a plan like this. You must practise
the process of converting an idea into very simple steps that you
know the computer will be able to understand. If you are not sure
whether the computer can do something, see if you can split that
thing into even smaller stages.
98 SABOTAGE
Once you have a plan like the one above, the best thing to do is
to try to convert each step into a few lines of BASIC. Try to do this
on paper first. You will find that you are constantly moving around
the program and changing things, and this is much easier on paper
than on the computer itself. You might find it easier to go through
the steps and change them into a mixture of BASIC and English. For
example, you might write

Loop 10 times
(you would put the part of the
program that you want inside the
loop here)
End of·loop

You can convert this into a FOR. .. NEXT loop at a later stage. You
should try to foresee the things that could happen during the game,
and try to cater for them all. For instance you must make sure that,
when there is an input from the player, your program checks that
whatever he typed in is actually allowed by the game and is not
too big or too small.
Here is a listing of a program that will play the game described
above. Each section below corresponds to the step with the same
number in the list above. Each section has been written separately,
so the line numbers are not all in numerical order. This doesn't
matter when you are typing a program into the computer, because
the computer will sort the lines automatically into the right order.

Section 1

10 GOSUB 1000 : GOSUB 2000


20 PRINT 'SABOTAGE'
30 PRINT
40 LET N=8 : LET P=FNR(N) LET C=FNR(IOO)

Explanation
line 10 sets up the random number generator and clears the
screen. This is the same as in all the other programs in this book,
SABOTAGE 99

and is written like this to make it easier to change the programs to


work on different computers.
Lines 20-30 print the title followed by a blank line.
Line 40 sets the number of sections in the spaceship to 8 (this
number is placed in N). It chooses a random section for the bomb to
be hidden in between 1 and N (which is 8), and puts this number
into P. It also chooses a secret code number (between 1 and 100) to
defuse the bomb, and stores this number in C.

Section 2
60 PRINT 'WHI CH SECTI ON TO LO OK IN (1- 8)'
70 INPUT S
80 IF S( 1 OR S>N THEN GOTO 70
9 0 I F S=P THEN GOT O 200

Explanation
Line 60 asks the player which section he wants to look in.
Line 70 gets his answer and puts it in S.
Line 80 checks if the number that he typed in is allowed. If it is
less than 1, or more than the total number of sections in the
spaceship, it is not allowed, so the program will go back and ask for
another number.
Line 90 checks if the number that the player typed in is the same
as the random number that the computer chose at the beginning of
the program . If it is, then the player has found the bomb, so the
computer will go to line 200 (see later).

Section 3

50 FOR 1=1 TO 3
100 NEXT

Explanation
Line 50 is the start of the loop giving the player three chances to
find the bomb. It is put just before line 60, which asks the player for
his guess.
100 SABOTAGE
Line 100 is the end of this loop, and will make the computer go
back to line 60 until the player has had three guesses.

Section 4
110 PRINT 'THE SHIP HAS BLOWN UP!'
120 GOTO 4000
Explanation
Line 110 prints a message telling the player that the ship has blown
up; he has had three guesses and has not found the bomb in time.
Line 120 then stops the program by going to line 4000, which
has a STOP or END instruction in it (according to the type of
computer).

Section 5
200 PRINT 'YOU FOUND THE TIME BOMB!'
Explanation
Line 200 prints a message telling the player that he has found the
time bomb.

Section 6
220 PRINT 'GIVE A CODE TO DEFUSE I T II

230 INPUT C1
240 IF C1<1 OR CI >IOO THEN GOrO 230
250 IF CI=C THEN GoTO 400
260 IF C1<C THEN PRINT nTOO LOW n
270 IF CDC THEN PRINT 'TOO HIGH'
Explanation
Line 220 prints a question asking the player for a code to defuse
the bomb.
Line 230 gets an answer from the player and puts it in Cl.
Line 240 makes sure that the answer is allowed - that is,
between 1 and 100. If it is not, the computer will go back to line
230 and ask again.
SABOTAGE 101

Line 250 checks if the answer in (1 is the same as the random


code chosen by the computer earlier. If it is, the computer will go to
line 400.
Lines 260-270 print a message, either 'TOO HIGH' or 'TOO LOW',
depending on the guess at the code.

Section 7
210 FOR 1;1 TO 6
280 NEXT 1
Explanation
Line 210 is the start of a loop, just before the question asking the
player for a guess at the code. The loop will give the player six
chances to guess the code.
Line 280 is the end of the loop, and will make the computer go
back to line 220 until the player has had six guesses.

Section 8
290 PRINT "YOU TOOK TOO LONG"
300 PRINT "THE SHIP BLEW UP"
310 GoTo 4000

Explanation
Lines 290-300 come after the end of the loop giving the player six
tries at the code. If by that time he has not guessed it, the computer
will print a message to tell the player that he has taken too long
and that the ship blew up.
Line 310 will stop the program. ....

~/I I~"I'

102 SABOTAGE
Section 9
400 PRINT "WELL DONE. YOU GUESSED THE CODE"
410 GO TO 4000

Explanation
Line 400 prints a message if the player has guessed the code
correctly (see line 250).
Line 410 stops the program.

The last part of this program is the same as all the other programs
in this book. You do not need to put a section like this at the end of
your program, but it is useful if you want to make the game work
on a different computer from your own.

BBC and Electron


1000 OEF FNR(X)=RNO(X)
1010 RETURN
2000 CLS : RETURN
3000 LET U= INKEY$
3010 RETURN
4000 END

Dragon
1000 OEF FNR (X)=R NO(X)
1010 RETURN
2000 CLS : RETURN
3000 LET U=INKEY$ ([)
3010 RETURN
4000 END
SABOTAGE 103

VIC
1000 DEF FNR(X)
=INT(RND(I)*X+l)
1010 RETURN
2000 PRINT CHR$(147);
: RETURN
3000 GET U
3010 RETURN
4000 END

ZX·Spectrum

1000 DEF FNR (Xl


=INT (RND*X+I)
1010 RETURN
2000 CLS : RETURN
3000 LET I $= I NKEY$
30 I 0 RETURN
4000 STOP

Once you have written the BASIC program, type it into the
computer, and SAVE it to tape or disc straight away. You should
always do this, because you will probably change the program
while you are testing it, and it is useful to have a copy of the
original somewhere. Testing a program is a difficult and lengthy
business.
How you do this testing depends on what sort of program it is.
You should always try to get the computer to execute every section
of the program, and try to make happen all the various things you
have anticipated. For instance, when the program waits for an
input from you, type in numbers or strings that you know are not
!'Uowed. If the program is written properly, the computer should
notice that these are invalid, and should tell you or at least ask for
the input again.
104 SABOTAGE
When the program is complete you are ready to write the
scenario. For Sabotage, it could be something like this:

Someone has sabotaged your spaceship! You are just about to take
off in your commander ship to save the empire, and you only have
time to check three parts of your ship for the hidden time bomb. If
you manage to find the bomb in time, you must use your expertise
to defuse it while your ship is warming up for the flight - but be
quick .. ..
BASIC AND ITS COMMANDS 105

BASIC is the name of the computer language that your machine can
understand. It isn't like English, since you have to write everything
very precisely and carefully. The smallest mistake would probably
make the computer misunderstand you, and do something
unexpected.
When you want to tell the computer to do something, you
usually write a program . A program is a series of simple, logical
steps that you want the computer to follow . Each step is written
using words from the BASIC language, and you store them in the
computer by giving them line numbers at the beginning of each
instruction. Usually you use line numbers that go up in steps of ten,
so that if you decide to put an extra line between two others, you
can give it a line number that goes between the other two. Unless
told otherwise, the computer goes through these lines one by one,
starting at the first and working through in order of increasing line
numbers.
To understand the programs in this book, you must remember
that the computer is VERY stupid. In fact, it is so stupid that it
needed a very good programmer to make it understand BASIC in
the first place. So we have to ask it to do lots of simple things
which, when put together, make it do what we want.
First, you must know how the computer remembers things. You
use the word LET Isee glossary) to tell it to put something into its
memory. The place that holds this 'thing' is like a box. You give the
box a name, and the computer will use that box whenever you use
its name in a program. If the box holds a number it is called a
'numeric variable', and is given a single·letter name such as B.
Some computers allow more complicated names, such as B1 or
even Box. If the box holds a string of letters, digits or any other
characters it is called a 'string variable'. As before it is given a
name, followed by a dollar sign - hence N$ or P1 $, for example.
So
LET g-12
puts the number 12 into the numeric variable Q, whereas
LET N'-"DANIEL"
106 BASIC AND ITS COMMANDS
puts the word DANIEL into the string variable N$. Notice that when
you use string variables, the string itself has quotation marks
before and after it.
You can also use LET to do maths on numbers and other
variables. For example,
LET W-Q+S
will make the computer fetch the number stored in the variable Q,
add five to it, and save the result in variable W. As well as +, you
can use - for subtraction, * for multiplication, / for division and /I
for powers of a number. You can also use + with string variables.
'Adding' two strings means putting the second one on to the end of
the first. For example:
LET A.="HELLO'
LET 8.-' THERE'
LET C.-A'+9$
would make ($ hold the words HELLO THERE.
Doing things like this with variables is only useful if you can ask
the computer to show you the results on the screen. The PRINT
command is used for thiS, and can do two things. It can display
messages on the screen, for example:
PRINT "HELLO THERE"
and it can be used to show you what numbers or strings are stored
in variables, for example:
PRINT A
PRINT N.
You can combine these by putting more than one item in a PRINT
command. To do this, you separate each item with a semicolon or
comma. Usually a semicolon will display the items with no spaces
between them, while a comma will space the items neatly across
the screen.
BASIC AND ITS COMMANDS 107

Using sound on your computer


Adding sound effects to a computer game can make it even more
fun . The computers that this book is written for can all make
sounds of some sort, although the SSC is the best at it. Try the
following examples on your computer, and try putting them in a
program you have typed in, so that you get sound effects at the
right time during the game.

Dragon
The simple command to make a sound is
SOUND P,D
where P and 0 are numbers or numeric variables that tell the
computer what note you want to play, and for how long,
respectively. P can be between 1 and 255; a value of 89 will cause
the computer to play the note middle C. 0 can also be between 1
and 255: each unit is 1/ 16th of a second, so that a value of 8 will
make the note last for half a second.
You can combine lots of SOUND commands to make more
interesting noises. The best way to do this is to put them in a loop,
and use the loop variable to change the note or the length of the
note or even both. For example:
10 FOR 1-20 TO 50
20 SOUND 1,1
30 NEXT 1
If you want to send everyone totally mad, try the following:
10 LET P-RND(255)
20 LET O-RND(4)
30 SOUND P,O
40 GOTO 10
The Dragon also has a more sophisticated way of playing music.
The PLAY command lets you use note names instead of numbers,
and has several powerful features. If you are interested, read about
this command in the Dragon manual.
108 BASIC AND ITS COMMANDS
zx-Spectrum
The ZX-Spectrum has a command BEEP, which produces a
particular note for a chosen length of time:
BEEP D,P
You must use numbers or numeric variables for 0 and P. 0 is the
length of the note, and each unit is one second. P is a number that
gives you a particular note, and each unit is one semitone above
middle C. (It can be negative. Thus 3 gives three semitones above,
and - lone semitone below, middle C) Experiment with different
BEEP instructions to see what it can do. For example:
BEEP 1,12
BEEP 0.5,-2
You can put the BEEP command into a loop to make more
interesting sounds:
10 FDR 1-0 TO 24
20 BEEP 0.05,1
30 NEXT I
or
10 FOR lei TO 25
20 BEEP 1/500,12
30 BEEP 1/500,19
40 NEXT I
BBC
The BBC computer has a very complicated system of producing
sounds. In fact, you can have three notes all playing at once.
together with 'white noise', which can sound a bit like a gun shot or
explosion. The Simplest way of making a noise is:
SOUND C,E,P,D
You must give a channel number in C. This tells the computer which
of the four channels (three notes plus noise) to use. It can be either
o (for noise) or 1 to 3 (for notes). E should be a minus number,
BASIC AND' ITS COMMANDS 109

which tells the computer how loud to play the note. The quietest is
·1 and the loudest is ·15. P is the pitch, and must be between 0 and
255. This chooses which note to play. Finally, D is the length of the
note, and must be between 1 and 255 . Each unit of length is
1/2Oth of a second, so that D = 20 will give a note one second
long. Try the following examples:
SOUND 1,-10,100,20
SOUND 2,-10,40,10
SOUND 3,-15,150,40
SOUND 0,-10,5,20
For the more complicated types of sound, read your manual about
the SOUND and the ENVELOPE commands.

Electron
The Electron uses exactly the same command to produce sounds
as the SBC, but it can only play one note at a time. Therefore, you
should always put the channel number as 1:

80UND 1,-I~,IOO,20
SOUND 1,-10,40,10
SOUND 1,-15,200,25

V1C
The VIC computer does not have simple instructions to make
sounds. However, using the POKE instruction you can produce
three channels of notes and create noise, and you can set the
volume of the sounds. The instructions to use are:
POKE 36878, X to set the volume (0 to 15)
POKE 36874,X to set note 1 (128 to 255)
POKE 3687~, X to set note 2 (128 to 255)
POKE 36876, X to set note 3 (128 to 255)
POKE 36877, X to set 'noise' (128 to 255)
110 BASIC AND ITS COMMANDS
Try the following example of making more complicated sounds on
the VIC:
10 POKE 36877,220
20 FOR LoiS TO 0 STEP -I
30 POKE 36878,L
40 FOR 10 1 TO 100 I NEXT
50 NEXT L
60 POKE 36877,0
70 POKE 36878,0

Using colour on your computer


Adding colour to a game program can make it much more
interesting to play. You can use colour to make some things show
up more than others. You can print messages in different colours -
messages of danger in red, for instance, and messages of
encouragement in green.
Each computer in this book has different ways of controlling the
colour of what is displayed on the screen. The following examples
show simple ways in which you can use colour on each machine. If
you want to experiment further, then read the relevant parts of
your computer manual. You can then go on to using graphiCS,
which you can use to draw pictures on your screen.

ZX-Spectrum
To change the colour of text being printed, use the INK command;
for instance:
INK 2
gives red text. To change the background colour, use PAPER; for
instance:
PAPER 5
gives a pale blue, or cyan, background colour.

BBC and Electron


On the BBC computer, you must choose the mode that you want
the screen to operate in. The mode makes a difference to the
BASIC AND ITS COMMANDS 111

number of different colours you can see on the screen at once, and
also the number of characters across the screen.

The following examples will work on both the BBC and the Electron.
We will use mode 5, which gives you four colours and twenty
characters on a line. First, type in the instruction:
"ODE 5
Then try the following examples:
COLOUR 1
give red text. The other colours, yellow and white can be used by
giving the numbers 2 and 3 respectively in the COLOUR instruction.
COLOUR 131
give a white background to the text. The background number is
obtained by adding 128 to its foreground number, so that 129 and
130 give red and yellow backgrounds respectively.

Dragon
The Dragon cannot easily produce text of different colours,
although it can draW' pictures using its colour graphics. If you wish
to try the Dragon's graphics commands, then look them up in your
computer manual.

VIC
The easiest way to get colour on the VIC, is to use the keys on the
keyboard marked with the various colours. Pressing Control along
with a number key will make the computer display text in that
colour from then on. Thus:
PRINT 'tHELLO THERE'
where the # sign signifies you pressing Control-3, will make the
message appear in red. You can put these control characters
anywhere in your text. You can use control-9 and control-o to
get reverse characters.
112 GLOSSARY
This glossary gives explanations and examples of most of the
common instructions that make up the BASIC language. You can
use it to check against the games in this book and to find out more
about how they work. In some cases different words are used for
the same function on different machines, in which case the
alternatives are given.
There is a separate section for BASIC functions, which are not
instructions in their own right.
In each section the words are listed in alphabetical order.

BASIC instructions
CLS is a simple command that clears the screen of all the
computers except VIC. On VIC you must use:
PRINT CHR$( (47);
DATA is used with the READ command. It tells the computer that
the following numbers or strings are just pieces of data that will at
some point be READ by the program. You can put more than one
item on a DATA statement, by separating each one with commas.
Examples

DATA 'JAN',30,'FES',28,'MAR',31
DATA 'ONE'f"TWO',"THREE'
DATA 9.8,3.2,77.99
DEF FN .. . is used to define your own mathematical instructions or
functions . You will probably have noticed that in most of the
programs in this book there is a line that looks like:
1000 DEF FNR(X)·RND(X)
or
1000 DEF FNR(X)·INT(RND(l)fX+I)
or
1000 DEF FNR(X)=INT(RNDfX+I)
depending on which computer you are using. The right-hand side of
this, after the equals sign, is the normal expression for working out
GLOSSARY 113

random numbers, but what about the left-hand side? This is called
a function definition, and it lets you make up your own
mathematical instructions and give them names. Once you have
done this, you can use them throughout the program, using the
name FNv where v is any normal variable name. The letter X inside
the brackets on the left-hand side is not a real variable, but a way of
telling the computer what to do with what it finds inside the
brackets when you actually use the function. In the above case,
typing
PRINT FNR(lO)
will display a random number between 1 and 10. On some
computers, this would save typing
PRINT INT(RND(I)*lO+I)
every time you wanted a random number.
Examples
DEF FNV!XI.X*1.15 (A function to add
VAT to the number)
DEF FNS(XI-SIN!X1180*3,1411
DIM tells the computer to reserve memory for a special type of
variable called an array. These variables are really like a lot of
boxes in a row; each box can itself hold a number or string_So, you
get a lot of places in memory to store numbers, but all the places
have the same name. To tell them apart you must put a number in
brackets to tell the computer which box you want to look at. You
must also decide beforehand the total number of boxes that you
want. You put this number in brackets in the DIM statement.
DIM A(251
makes an array called A, with twenty-five boxes to put separate
numbers in_ A(1) is the first, and you could use it like this:
LET A(I)=1999
A(2) is the next, and could hold something else:
LET A(21=2001
114 GLOSSARY
You could use aU the boxes, or elements, in A to store different
numbers, aU the way up to A(25)
You can use a loop to print out aU the boxes in an array (see the
entry under FOR). To do this, you should put the loop control
variable inside the brackets after the array name, so that each time
the loop is repeated, the next box will be printed. For example:
FOR 1=1 TO 10
PRINT All)
NEXT I
DIM can be used to create a grid of boxes, instead of a simple row.
This is called a two·dimensional array, and you must give two
numbers inside the bracket in the DIM to specify the array's size.
You must give two numbers to specify the box whenever you wish
to use this array. For example:
LET AI2,4)-5
would store the number 5 in what may be thought of as the second
box in the fourth row of the grid. You can also create an array of
strings instead of numbers, by using a string variable name in the
DIM instruction.
Examples
DIM C(52)
DIM BI8,9)
DIM 8$120,5)

END will tell the computer to finish running the program and wait
for another command, such as RUN. You can put more than one
END command in a program, but too many get very confusing.
The ZJ(-Spectrum uses STOP, not END. See the entry under STOP.

FOR marks the beginning of a set of instructions that you want the
computer to go through a number of times. This repetitive
operation is called a loop, because of the way it goes round and
round. You must use a variable to control the loop, and a beginning
GLOSSARY 115

and end number for this variable. The computer will start with the
beginning number, and add one each time it goes round until it
reaches the end number. Then it will carry on with the rest of the
program. To show the computer where the end of the loop is, you
must put a NEXT command. For instance:
FOR I-I TO 5
the part of the program that you want to loop
round goes here

NEXT [
This loop is controlled by the variable I. It starts at one and
increases by one until it reaches five, so the instructions within it
will be repeated five times. You can change the amount that the
loop control variable increases each time by putting the word STEP
into the FOR instruction. Put the number that you want to increase
each time after STEP.
Examples
FOR J=IO TO 20
FOR Kal TO 10 STEP 2

You can have loops one


after the other, as or inside each other, as

FOR FOR

NEXT FOR
loop
FOR
NEXT

NEXT
NEXT
The latter is called 'nesting'.
,,6 GLOSSARY
Note that the control variables must be carefully specified. Each
of your loops will usually use a different control variable name.

GOSUB is a little like GOTO in that it tells the computer to go to a


particular line of the program other than the next one. Unlike
GOTO, however, the computer remembers the line number that it
came from, and will go back to it when it encounters a RETURN
instruction. You must always remember to use a RETURN
instruction at the end of this section. This section is called a
subroutine. Subroutines are useful If you want to do the same thing
again and again in different parts of a program. Instead of writing
the same instructions again and again through the program, just
write them once, say at the end of the program, and use GOSUB to
run them whenever you need to.
Examples

IF S=9 THEN BOSUe ~OO


sosue 1000

GOTO simply tells the computer to carry on running the program


from a particular line number. Normally the computer goes through
the program line by line. Suppose, however, you want to change
what happens during a program, depending on the result of an
IF .. .THEN command. You can use GOTO to make the computer run
a different part of the program, but only when a particular thing is
true. Alternatively, having executed one particular part of the
program, you may want to start again near the beginning of the
program . You then use GOTO to transfer control back to the earlier
program lines.
Examples

IF Z=I THEN SOTO 1095


SOTO 900
GLOSSARY 117

IF ... THEN is used to make decisions. It asks the computer to work


out whether some condition is true or false, and tells it to do
different things depending on the answer. You can use various
things in the expression:
= equal to
< less than
> more than
< = less than or equal to
= > more than or equal to
<> not equal to

AND is used if you want to decide if both one thing AND the other
are true
OR is used if you want to decide if one thing OR the other OR both
are true.
If the final decision is that the condition is true, the computer will
then go on to the instructions following the word THEN. On the
other hand, if the condition was false, it will simply go on to the
next line of the program .
Examples

IF Z=9 THEN GOTO 100


IF Nt.'JOHN' AND A) 19 THEN PRINT 'HELLO"
IF (Q/2)(aSIN(Z) OR Fa l THEN LET Ga 99

INPUT is used to get answers from the person using the computer.
It is a bit like a LET command, except that it obtains the value to
put into the variable from you instead of from the program. You
can INPUT values for numeric or string variables, according to the
type of the variable you use. For instance:

10 INPUT Z
118 GLOSSARY
will expect you to type in a number, which will be stored in variable
z. You must always press the ENTER or RETURN key so that the
computer knows that you have finished typing in the answer and it
can carry on with the program.
Examples

INPUT Z
INPUT Q$

LET is used to put a value into a named place in the computer's


memory. These places are like boxes, and are called variables. They
are usually given single· letter names, and there are two main types.
Numeric variables can hold any number, for instance:
LET Q=II
will put the number 11 into a variable called Q. String variables can
hold any letters, digits or other characters; their names are followed
by a dollar sign, for instance:
LET N$'"HELLD-123'
You can also do maths using the LET command, by putting more
complicated things on the right· hand side of the equals sign.
Remember that on the left must be a single variable name, the
name of the variable where you want to put the final result. For
instance :
LET A=IO+(B/2)
will take the value stored in variable B, divide it by two, add ten
and finally store the answer in variable A. You can also use
mathematical functions such as square root and sine, if you need
them in your program.
You can use + with string variables. In this case addition means
adding one string on to the end of another. For example:
LET N$="FRED"
LET M$= ' BLDGGS'
LET Q$=N$+M$
GLOSSARY "9

would make the string variable Q$ contain the string FRED


BLOGGS.
Examples

LET Q-4S
LET 61=10
LET R2(Z+L)/(4+P)
LET X-SIN(f)
LET W$-'HELLO'
LET S$'"THE "+C$

NEXT is the command used with FOR (see entry FOR). It tells the
computer where the end of the loop is. Each time the computer
comes across a NEXT statement (followed by the name of the loop
control variable. e.g. NEXT I) it increases the loop variable by one
and jumps back to the line with the FOR command in it. unless it
has reached the tenminating number.
Examples
NEXT W
NEXT
The second of these examples is NEXT without the control variable.
Provided that the program has the same number of FORs and
NEXTs, and that these are placed correctly, the computer will know
which FOR to return to. The omission of the control variable is not
allowed on the ZX ·Spectrum.

PRINT tells the computer to put something on the screen. It can be


used to display messages (look at all the programs in this book)
and also to show what particular variables have stored in them . To
display a message, put it inside quotation marks after the PRINT
command:
pRINT "HELLO"
120 GLOSSARY
To show the contents of a variable, put its name after the PRINT
command:
PRINT N
or
PRINT AS
For a blank line on the screen, type in PRINT on its own. You can
separate things after PRINT with commas or semicolons. Usually a
semicolon will display the items next to each other, while a comma
will space them out on the screen.
Examples

PRINT 1
PRINT 'HELLO THERE 'IN.
PRINT FtV,G/2
RANDOMIZE is used to get around a problem with random
numbers generated by the computer. You may notice that the
computer always gives you the same random numbers just after
switching it on. To stop this happening, use the following
commands, right at the beginning of your program :
10 RANDOMIlE for the BBC and Electron
10 RANDOM for the ZX·Spectrum
10 LET R-RND(-TI) for the VIC
10 LET R-RND(-TIMER) for the Dragon
These make sure the random numbers start off completely
randomly.

READ is used to copy DATA you may have stored in the program
into chosen variables. It behaves like INPUT, but instead of stopping
and asking the person using the computer for something, it gets
that something from the list of items that you should have put into
the program beforehand. These items are put in DATA statements.
Each time you execute a READ command, the next item (starting
with the first item when you run the program) is read into the
variable whose name you give. If you give a numeric variable it will
GLOSSARY 121

expect to read a number from the DATA statements, and if you give
a string variable it will expect to find a string in quotes. These
commands are useful if you want to have a lot of data in a program
which is unchanging - for instance, the names of the months and
how many days each one has.
Examples
READ P
READ H$,A,8
RE11IRN tells the computer that it has reached the end of a
subroutine, and that it should return to the program line that the
subroutine was called from . It will then continue with the next
instruction after GOSUB.

STOP is the same as END, except that on some computers a


message is printed to tell you what line the program stopped in.
Note that the zx·Spectrum does not understand END, and so you
must always use STOP.
You can also use STOP while you are trying to get a new program
to work. By putting it in the midcJJe of the program, you can
temporarily stop the computer while you look to see what is
contained in the variables, and then use the CONT command to
carry on running the program.

BASIC functions
Now we come on to various 'functions' that BASIC understands.
These can be used together with variables in LET and IF ... THEN
commands. Most of them produce a result depending on
something in brackets. For the functions that are not described,
look up what they do in your computer manual.
ABS ignores any minus sign in front of a number, and always gives
you the absolute value. For example:
ABS(42) gives the answer 42, and
ABS(-42) also gives 42
122 GLOSSARY
CHR$ converts numbers into single letters or other characters. It
uses a special computer code called ASCII, in which each number
(normally between 1 and 127) corresponds to a particular letter.
For example, the letter A has a code number of 65, so that
PRINT CHR$(65)
would print out an A.

Examples
CHR$(147l
CHR$(64+I)

INT is a maths command that is used to convert numbers with


something after the decimal point into whole numbers. For positive
numbers, it just ignores everything after the point, so that
INT(19.86) is 19. For negative numbers, it also ignores everything
after the decimal pOint, and it increases the number by one, making
it more negative; thus INT (-5.45) is -6.
Examples
INTlS/IO)
INTlRNO(1I110)

RND is a very useful function . The simplest form produces a


random number which is always between 0 and 1. You can use
this, and a bit of maths, to get the computer to choose random
numbers in any range, or to get the computer to choose randomly
between doing two different things.
Examples

RNO (II (VIC, BBC and Electron)


RNO (ZX ·Spectrum)
RNO(O) (Dragon)

On the BBC, Electron and Dragon computers there is another


version of the function RND that will give you a random whole
GLOSSARY 123

number between 1 and your selected number. For instance. RND(6)


will give a random whole number between 1 and 6.
To get a random whole number between 1 and another number
on other computers. you should use the expression:
INT (RNo (1) *n+1) (for the VIC)

(for the ZX·Spectrum)

where n is the highest random number that you want. For


example. to get a random number between 1 and 6. use
INT(RNo(1)*6+1) (for the VIC)
or
INT(RNo*6+1) (for the ZX·Spectrum)

SIN. COS. TAN. ATN are all maths functions that you can use in
your programs. Remember that the computer normally works in
Radians. not Degrees.
Examples:
SIN(3.142)
COS(A)
TAN<T/2)
ATN (F+U

SQR is a useful function that gives you the square root of a number.
Examples:

SQR(16)
(would give the answer 4)
SQR(T*2)

VAI. takes a string variable and. if there is a number written in that


variable. converts it to a true number that you could put into a
numeric variable instead . In other words. if your program has a
number written into a string variable. and you want to do some
maths on it. you must use VAL first.

j
124 GLOSSARY
Examples:
VAL (. 4~') (would give the number 45)
VAl( N$)

BASIC direct commands


There are a few commands which are not usually used within a
program . These 'direct' commands are used to tell the computer
what to do with your program .
LIST is used to display all or part of your program on the screen.
Typing LIST on its own will display the whole program (on the ZX-
Spectrum, the computer will pause at the end of every page and
ask whether you wish to continue). Typing LIST followed by a line
number will list the program starting at that line number. To
display a smaller section of a program, you should give the start
and end line numbers of the section. For example:
LIST 10-100
will list lines lata 100 on the Dragon and the VIC, while
LIST 10,100
will list lines lata 100 on the BBC and Electron.
LIST
will list from line lOon the ZX-Spectrum

LOAD is used to recall programs from tape or disc back into the
computer. The Dragon uses CLOAD to load programs from tape.
Look up this command in your computer manual to find out how
to use it.
RUN tells the computer to start running the program in its memory.
It will always start at the very first line of the program. Before
running the program , the computer clears any variables that have
been used previously, so that it's memory does not become full up_
GLOSSARY 125

SAVE is used to store your programs onto tape or disc. The Dragon
uses CSAVE to save programs onto tape. Look up this command in
your computer manual to find out how to give the programs
names on the tape or disc.
126 APPENDIX
Here is a list of some of the ASCII' codes. Each character has a
Hexadecimal or Decimal number next to it, which is its
corresponding code:

Char Hex Dec Char Hex Dec

sp 20 32
21 33 > 3E 62
22 34 ? 3F 63
£ 23 35 @ 40 64
$ 24 36 A 41 65
Yo 25 37 8 42 66
~ 26 38 C 43 67
27 39 D 44 68
28 40 E 45 69
29 41 F 46 70
• 2A 42 G 47 71
+ 28 43 H 48 72
2C 44 I 49 73
2D 45 J 4A 74
I 2F 47 L 4C 76
0 30 48 M 4D 77
31 49 N 4E 78
2 32 50 a 4F 79
3 33 51 P 50 80
4 34 52 Q 51 81
5 35 53 R 52 82
6 36 54 5 53 83
7 37 55 T 54 84
B 38 56 U 55 85
9 39 57 V 56 86
3A 58 W 57 87
; 38 59 X 58 88
< 3C 60 V 59 89
= 3D 61 Z 5A 90

*ASC11 stands for American Standard Code tor Information Interchange. Most
computers use this code to represent the various different letters, numbers, and
symbols used by the computer.
l
SOFIWARE ORDER FORM
computer Games
The programs listed in this book are available on cassette direct
from the publisher.
There is a cassette available for each machine, price £4.95 (plus
£1 .00 postage and packing). The cassettes are only available on a
cash·with·order basis.
Fill in the form below, making sure you state clearly which machine
you have. Send the completed form with your cheque or postal
order to:
Sparrow Software
Hutchinson House
17·21 Conway Street
London W1 P 6JD

Please send me one cassette at £4.95 (plus £1.00 p+p) for the
following machine:
zx ·Spectrum
D Electron
D J
VIC
D Dragon
D
BBC
D (tick box where applicable)

I enclose cheque/ PO made out to Sparrow Books.

Name

Address

postcode
ISBN 0-09-933330-9
Children 's
Non-fiction
U.K. £1 .50

You might also like