Computer Battle Games
Computer Battle Games
/ i
^SpeCtrU-^8,BBC,TRS-80.App^
. . . . . o .
0
m
M
*
. o . .
PROGRAMS
&
COMPUTER
*W"
TTLEGAME
Daniel lsaaman
and Jenny Tyler
Contents
2
4
6
8
10
12
14
16
18
20
22
24
26
AboutthisBook
RobotMissile
TheVitalMessage
Shootout
DesertTankBattle
Battle at Traitor's Castle
Robot Invaders
SecretWeapon
Escape!
PirateDogfight
SupersonicBomber
Iceberg
TheWall
30
31
32
33
34
35
36
38
40
46
47
Missile!:TRS-80version
Missile!:BBCversion
Missile!:ZXSpectrumversion
Missile!:VIC20version
Missile!:Appleversion
Missile!:ZX81 version
Addingtotheprograms
Writing your own programs
SummaryofBASIC
Conversionchart
PuzzleAnswers
Illustrated by:
Rex Archer, Jim Bamber, Tony Baskeyfield, Martin Newton
and Graham Round
Designed by:
Graham Round and Roger Priddy
Robot Invaders program by Bob Merry
First published in 1982 by Usborne Publishing Ltd,
20 Garrick Street, London WC2E 9BJ
1982 Usborne Publishing Ltd
AboutThisBook
This book contains simple games
programs to play on a microcomputer.
They are written for use on ZX81, ZX
Spectrum,BBC,VIC20,
TRS-80 and Pet and Apple micros, and
manyare short enough to fit into the
ZX81'slKofmemory.
Points to remember
Most micros use the language BASIC,
1 Type the Unes exactly as they are printed
but they aU have their own variations or
including
aU punctuation and spaces.
dialects. In this book, the main listing for
2
Press
RETURN,
NEWLINE or ENTER
each program works on the ZX81 and
key
at
the
end
of
each
program Une.
Unes which need changing for the other
computers are marked with symbols and 3 CheckeachUneasyougo.
printed underneath. The fact that the
4 Makesureyoudon'tmissoutaUneor
programs are written for several micros
confuse one with another. A piece ofpaper
means that they do not make fuU use of
or a ruler is useful to mark your place in
each one's faciUties. You could try
the Usting.
finding ways of making the programs
5 Lookoutforthesymbolsandmakesure
shorter and neater for your micro.
you use the correct Unes for your
For each game, there are ideas for
computer.
changing and adding to the programs
6 If you are using a ZX81 or ZX Spectrum,
and towards the back ofthe book you
remember not to type the program
wiU find tips and hints on writing games
instructions letter by letter but to use the
of your own. Also in the book is a
special key for each instruction instead.
conversion chart to help you adapt
programs in magazines and other books
You may find it easier to get someone to
for your micro and a summary ofthe
read the program out to you while you
BASIC terms used in this book.
type it in. Don't forget to explain thatthey
must read every comma, fuUstop, bracket
and
space and differentiate between letter
Typing in the programs
"0" and zero, FOR and 4, and TO and 2.
Lines which need changing for
computers other than ZX81 are marked
Debugging programs
with these symbols:
When you have typed
A VICandPet
in the program, check
* BBCandAcornElectron
your
manual to find out
TRS-80
how
to
display it on the
Apple
s
screen.
(Usually you
ZXSpectrum
type
LIST
foUowed by
Every time you see the symbol for the
the
line
numbers
ofthe
micro you are using, look below for the
section
you
want
t
o
corresponding Une number with the
see.)
same symbol and type that in instead.
VIC20 versions ofallexcept thegraphicsprogram should workon
Petcomputers.
Checkyouhave
typed everything
correctly. It is easyto
make mistakes, so
expect to find some. Use
your manual tofindout
how to make changes to
the program once it is
typed in. Ifin doubt, you
can always type the line
again. AU the computers
wiU replace an existing
hne with a new one with
the same number.
Here is a checklist of common
mistakes to look out for:
1 Linemissedout
2 Linewronglynumbered
3 Thebeginnihgofonehnejoinedonto
the end ofanother.
*Seepage37foraspecialnoteforBBCandSpectrumusers.
RobotMissile
The year is 2582 and the people ofEarth are inthe
midst ofbattle against the Robots. A lethal Robot
Missile has just landed and everyone is depending
on you to find the secret code which unlocks its
defuse mechanism. Ifyou fail, the entire Earth
Command Headquarters will be blown up.
Your computer knows what the code
letter is. You must type in your guess and
it wUl tell you whether the code letter
is earUer or later in the alphabet.
You have four chances to find the
correctletterbeforethemissile
blowsup.
iiUf*.
m. -'** .,11, matfmJlw
TrWr"
, j M*Sl
^ B i ^
t i\ ii
%
III
mB
**
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT
s*BA#80 LET
*
"ROBOT MISSILE"
C*=CHR*<37+INT<RND*26+1>>-
K>
i1
90 FOR G=1 TO 4
100 INPUT G*
"LATER";
"EARLIER";
Checksifyourletteristhe
same as the "secret code" in
CS. Ifso computerjumps to 210.
150 NEXT G
160 PRINT
"
170 PRINT "BOOOOOOOOMMM
- This prints if aU your guesses
180 PRINT "YOU BLEW IT."
were wrong.
190 PRINT "THE CORRECT CODE WAS";C*
200 STOP
210 PRINT " T I C K . . , F Z Z Z Z . . CLICK.
- This prints ifyou guessed
220 PRINT "YOU D I D I T "
right.
?30 STOP
The a b o v e tisting will woxk on a ZX81. For
other computers, m a k e the c h a n g e s b e l o w .
* A 8 0 LET C * = C H R * < 6 4 + I N T < R N D < 1 > * 2 6 + 1 > )
8 0 LET C * = C H R * ( 6 4 + I N T ( R N D ( 0 ) * 2 6 + 1 ) )
s 8 0 LET C t = C H R * ( 6 4 + I N T ( R N D * 2 6 + l ) )
T^
Puzzlecorner
i
/
\ \
ii.
. p..^..iw
i
.^
_
a
>
^j^TSk
4
-ai,
f/ rA *s^
'
v , ' ^4yr
**&4*
*'** *$sSf
**%
**^v
w to * if M
Ni2
Youarealaser
communications
operator. Your
job is to intercept
robot messages and relay
them to Command HQ. A vital
code message is expected. Ifyou
relay it correctly, the Robot attack
wiUbecrushed.
This game tests your skUl at
remembering a group of
10
20
30
40
50
60
80 FOR 1 = 1 TO D
~ | ComputerloopsroundDtimes.Each
8*A90 LET M*=M*+CHR*<INT<RND*26+38) )Lloopitchoosesaletterandaddsitto
100 NEXT I
| thestringoflettersithasabeady
chosen and put in MS
A#110 CLS
120 PRINT "SEND THIS MESSAGE:
130 PRINT
I
Clearsscreenandthenprintsthe
140 PRINT M*
J
message.
. 1160
5 0 NEXT
FOR 1I= 1 TO D * 8 l
tttttZEEgZ***
A#170 CLS
180 INPUT N*190
200
210
220
230
240
250
260
Howtomakethegame harder
You can change the program to include
numbers and punctuation marks in the secret
message. Do this by changing line 90 as foUows:
zx90 LETM$=M$+CHR$(INT(RND*43+21))
A 9 0 LETM$=M$+CHR$(INT(RND(l)*43+48))
90 LETM$=M$+CHR$(INT(RND(0)*43+48))
s90 LETM$=M$+CHR$(INT(RND*43+48))
Shootout
V
1 0 CLS
You are standing back to
20 PRINT "COWBOY SHOOTOUT -"
back. You take 10 paces, turn
30 PRINT "YOU ARE BACK TO BACK"
and reach for your gun. How
40 PRINT "TAKE 10 PACES..."
quick are you? Can you
50 FOR 1 = 1 TO 1 0
shootfirst?
PRINT I ;
Your computer prints the ^ t p o NEXT I
^" 70
numbers 1 to 10to represent
80 PRINT
the 10 paces, pauses and
90 FOR 1=1 TO RND*200
en prints HE DRAWS...
100 NEXT I
must be ready to press a
y(anyonewill(
llO IF INKEY*<>"" THEN GOTO 160
i^mgfcesewords
thescreen.Ii
120 PRINT "HE DRAWS
";
enough, you #fltwifl$8bn't,
ssakeybefareH"
130 FOR 1 = 1 TO 5
WScomesupoi
1 4 0 IF INKEY*<>"" THEN SOTO 190
.ticaUylose.
1 5 0 NEXT I
To
keyao*
160
170
180
190
200
210
PRINT "AND
PRINT "YOU
SOTO 210
PRINT "BUT
PRINT "YOU
STOP
"
1
AD.'J
SHOOTS
ARE DEAD
L^L
10 HOME
10 PRINT CHR*(147)
60 PRINT |I|".."|
65 FOR J=1 TO 300 : NEXT J
90 FOR 1=1 TO RND(l>*lOOO
90 FOR 1=1 TO RND(0)*1000
110 IF PEEK(-16384)>127 THEN GOTO 160
110 GET I* : IF I*<>"" THEN 60T0 160
110 IF INKEY*(1)<>"" THEN GOTO 160
130 FOR 1=1 TO 20
130 FOR 1=1 TO 50
DELETE 130,150
140 IF PEEK(-16384)>127 THEN GOTO 190
140 GET I* : IF I*<>"" THEN GOTO 190
140 IF INKEY*(40><>" THEN GOTO 190
^ai
jmq
M i
^^_^
"3
i*J"l^
Puzzle corner
'1
DesertTankBattle
The last major stronghold ofRobot forces outside the U.R.S* is hiddeninancient
castle ruins in the middle ofthe desert. A fleet ofdesert hovertanks has beensent
to destroy it and you are the commander. Your tank controls the five remaining
missiles.
You must assess carefully the direction and elevation before you launch each
one. Your computer wiU ask you for a direction angle between 90 (extreme left)
and +90 (extremeright)and an elevation angle between 0 (along the ground) and
90 (straight up in the air). The elevation determines the distance the missile wiU
travel.
Is your aim good enough to destroy the robot stronghold?
FOR S=1 TO 5
PRINT "DIRECTION <-90 TO 90) ?"
INPUT T1
>) ?"
PRINT "ELEVATION (0 TO
INPUT B
90 LET Dl=SIN(2*(B/1803.1416>).
THEN 60TO 2 2 0
Ifyour
directionwaswithin2 degrees
and your distance within 0.05,
then you have hit the castle,
Program jumps to line 2 20 to
teU you so.
an appropriate message.
140
IF ABS(Dl-D)>.05
THEN P R I N T
"AND " j
Decides
whethertoprint "and" by
A semi-colon at the end ofa print statement X comparing the distance
tells the computer notto go to a new Une for ) your missile travelled with
thenextitemtobeprinted.
S thenumberchoseninUne30.
150
160
170
180
190
200
210
220
230
240
Prints a message
IF D-Dl>.05 THEN PRINT "NOT FAR ENOUGH";
ifyourshot was
IF Dl-D>.05 THEN PRINT "TOO FAR
too long or short.
PRINT
NEXT G
PRINT DISASTER - YOU FAILED
Prints ifyou lose.
PRINT 'RETREAT IN DISGRACE"
STOP
1
PRINT "*KABOOOMMM*,
Prints ifyou win.
PRINT "YOU'VE DONE: iT"J
STOP
LET
LET
LET
LET
T=INT(RND(l)*181)-90
T=INT(RND(0)tl81)-90
D=RND(1)
D=RND(0)
Puzzlecorner
Can you work out how to add the
possibility ofthe robots seeing you and
shooting at you before your five goes
areup?
11
UnitedRobotStates
BattleatTraitor's
Castle
*
&
FOR L=1 TO 9
IF L=T THEN LET R*=R*+"0"
IF L O T THEN LET R*=R+".'
NEXT L
lOO PRINT
R*,'
4 1 1 0 FOR 1=1 TO
*xri220
The King is waging a fierce and
bloody battle against his
deadliest enemy - the Traitor
Baron. You are one ofthe King's
crack bowmen and at this very
moment you are crouching
behind the bushes outside the
Baron's Castle, shooting at his
men as they lift their heads above I
the battlements.
Your computer will print a row
containing eight dots and an O.
The number keys 1 to 9
correspond to the position of the 0
in the row. You have a short time
to press the correct key, and hit
the O, before it disappears.
How many ofthe Baron's men
canyouhit?
LET I*=INKEY*
PRINT "MISSED'
GOTO 190
PRINT "GOOD SHOT"
LET S=S+1
NEXT G
'
'
E5'
Puzzlecorner
Can you change the program so that you get two
i kinds of target - either O (one of the Baron's
Ordinary soldiers) which is worth 1 point, or S
(one of his Special branch) which is worth 5
points?
&&
$*Hr
j C . -*^A
_ j ; :-w
Notice how the scoring works
in this program (Unes 20 and
180). You could try adding
this to other programs.
f*K /' ^ ^
w>
'l*&wmito&
530?
g*^<TTI^l!^"/
~V
'
bB-I: /*
iM&
v<*m
7\mk(,
^ 1 ^ ^ 1
X<;4/
S 9^^9*r.
M^^mH
Robot Invaders
You must act quickly.
Robot invaders of all kinds
are approaching. You
have plenty ofweapons,
but for each type ofRobot
you must select exactly
the right one for it to have
anyeffect.
Code symbols for each
Robot will flash up on your
screen. Quickly press the
key with that symbol on it
- beware, some need the
shift key too - and see how
many Robot invaders you
candestroy.
m*f
u
^
IP
ff
CZ3
' IMI
kji
T 1~
^^m^
^"
LET A=INT<RND*20)
LET D=INT<RND*15>
LET P*=CHR*(INT(RND*53+11)).
CLS
100
110
120
130
A140
^A#150
160
170
180
190
200
210
220
230
A*240
250
260
:}
FOR J=0 TO D
PRINT
NEXT J
PRINT TAB<A);P*
FOR 1=1 TO 15
LET R*=INKEY*
IF R*=P* THEN GOTO i 10
IF R<>"" THEN GOTO 190
NEXT I
PRINT "MISSED"
GOTO 230
PRINT "A HIT"
LET H=H+1
NEXT T
CLS
PRINT "YOU SCORED ";H;"/25"STOP
- Random delay.
Selects numbers for across
and down positions on
- screen.
Choosesakeyboard character.
-Clearsscreen
Moves cursor down the
screen, one Une at a time,
-until it reaches Une number O
(which was chosen in Une 70).
- Moves cursor A spaces
across the screen and prints
the character chosen in Une
80there.
-Checks keyboard a number
oftimes to see ifyou are
pressing a key, checks ifthis
is therightkey and then
jumps to the appropriate Une
to print hit or miss.
- bicreases score by 1.
- Goes back for another turn.
Prints score after 25 goes.
CZD
<r- -
-X
LL
Movingthecursor
A 9 0 , 2 4 0 PRINT CHR*(147)
A 1 4 0 FOR 1=1 TO 150
145
150
A150
150
R*=""
R*=INKEY*<1)
GET R*
IF PEEK(-16384)>127 THEN BET R*
Puzzlecorner
JL W X-
These are
the most
dangerous of
the robots.
Mechans
>XT
* T
Tintroids
Scrapions
Wireheads
Steeleyes
Can you adjust the program so that you get 100 points for each ofthese and
only 10 points for any ofthe others?
Y>*
SecretWeapon
Ifyou could destroy the main Robot Spare Parts Store, which lies
underground somewhere in the eastern wastes ofthe U.R.S., you could
cripple the robot attack quite severely.
You have a new secret weapon, as yet unknown to the robots, which
can cut silently through soUd rock, vapourizing everything in its path.
The Store is very cleverly concealed though. All you can do is aim
your weapon bUndly and hope you get somewhere near the target.
Your computer will ask you for a difficulty number (the
smaUest number aUowed is 4) and then ask for your
guesses for the X and Y coordinates ofthe target. (Enter
these separately, pressing RETURN, NEWLINE or
ENTER after each one.)
Foracluetothepossible
^^y*><t&S
valuesofXandY,look
^*>
carefully at the program
_^,^Zy^SM
tisting.
16
*N
\
.r
N*
A10
20
30
40
50
A60
A70
80
~~_
CLS
PRINT "SECRET WEAPON"
PRINT "ENTER DIFFICULTY
INPUT D
IF D<4 THEN SOTO 30
LET X=INT<RND*D+
LET Y=INT(RND*D+
FOR 6=1 TO D+5
130 I F
140 I F
150 I F
Z=SQR((X-Xl)*(X-Xl)+<Y-Yl)*(Y-Yl>)
Worksoutthe
distance between
your shot and the target and puts
theanswerinZ.
i
ChecksZtoseehowclose
Z = 0 THEN GOTO 2 0 0
youwereandprintsa
Z < = 3 THEN P R I N T " C L O S E "
U-message.(IfZ = Oyou've
Z>3 THEN PRINT "NOT EVEN C L O S E ^
won.)
160 NEXT G
170
180
190
200
210
220
PRINT
PRINT
STOP
PRINT
PRINT
STOP
10
A10
*A*60
60
*A#70
70
HOME
PRINT CHR*(147)
LET X=INT(RND(1)*D+1)
LET X=INT(RND(0)*D+1)
LET Y=INT(RND<1)*D+1)
LET Y=INT(RND(0)*D+1)
Escape!
The Robots have caught you, taken your weapons andlocked youup.
Suddenly you remember you stiU have your sonar wristwatch, which can be
tuned to produce sounds ofany frequency. Ifyou can onlyfindthe resonant
frequency ofyour Robot guards, they should vibrate so much they faUapart.
You must be careful not to use frequencies that are too low or the building
wiU vibrate and coUapse on top ofyou. Ifyou go too high, you wUl get sucha
terrible headache you wiU have to give up.
Can you escape the horrors ofthe Robot prison? (Look carefuUy at the
program for a clue to the range offrequencies to try.)
How the program works
1 0 CLS
#
20 PRINT "ESCAPE"
A 3 0 LET F=INT<RND*lO0+l)
H}
'}
10
AlO
A30
18
"30
HOME
PRINT C H R * ( 1 4 7 )
LET F = I N T < R N D ( 1 ) * 1 0 0 + 1 )
LET F=INT(RND<0>*100+1>
Puzzle corner
The three Robot guards
each have their own
resonant frequency. You
can't escape until you
have found aU three. How
could you change the
\ programtodothis?
Howtomakethe
gameharder
Change the 5 in Une 90 to a
lower number. This means
you have to get closer to F
to win. You can also
increase the possible
range ofF by changing
100 in Une 30 to a higher
number.
PirateDogfight
It's you against the Sky Pirate. He moves ahead, you accelerate-He
drops behind, you slow down. You must try to get level with him andthen
you canfire,hoping that he won't be able tofireand hit youfirst.
Use the letter keys A to accelerate, D to decelerate and F tofire.Your
computer will tell you your speed and position relative to the pirate. You
will need to be ready to press the appropriate keys as soon as youpress
RUN. Keep pressing A and D until you get level and thenfire.
CLS
40 LET S=-INT<RND*3+1>
20
^
^ifli
j
'}
FOR 1=1 TO 20
NEXT I
GOTO 50
PRINT "YOU LOST SIBHT OF HIM"
GOTO 330
260
270
280
A* 90
145
*150
150
A150
*BA#200
B290
*A*290
i*="I*=INKEY*<1>
IF PEEK(-16384)>127 THEN GET 1
6ET I*
FOR 1 = 1 TO 200
IF RND<0)>.7 THEN 60T0 320
IF RND(l)>.7 THEN GOTO 320
Puzzlecorner
The random test in line 290 is loaded in
your favour. How could you change it so
your chances ofwinning are equal?
21
Supersonic
Bomber
60 LET M=1
70 FOR 1=1 TO 5
80 LET B<I)=INT(RND*10+1)
90 IF B(I)>B(M) THEN LET M=I
100 NEXT I
110 CLS
120 FOR 1=1 TO 5
130 PRINT I;
Prints the S numbers on the
140 FOR J=1 TO B(I)
screen in the form ofrows of
150 PRINT "**";
stars.
160 NEXT J
170 PRINT
180 NEXT I
190 FOR 1=1 TO G*3
Checks ifyou are pressing a
T5200 LET I*=INKEY*
key and goes to 270 ifyou are.
210 IF I*<>"" THEN GOTO 270
220 NEXT I
Ifyou didn't press in time,
230 PRINT "TOO LATE"
prints TOO LATE and goes
240 FOR J=1 TO 10
< back for next go.
250 NEXT J
Checksifthe key you
260 GOTO 280
pressed was correct and, if
270 IF VAL(I*>=M THEN LET S=S+1
so, increases your score by 1.
280 NEXT G
' Goesbackforanothergo.
290 PRINT "YOU HIT ";S; " OUT OF 1 0 "
300 PRINT "HIGH DENSITY TARGETS"
Prints score after
3 1 0 I F S=10 THEN PRINT "YOU'RE A HERO'
10 goes.
320 IF S<10 THEN PRINT "TOUGH - YOU FAILE1
330 STOP
1 9 5 I*=""
200 I*=INKEY*U>
2 0 0 SET I *
2 0 0 I F P E E K < - 1 6 3 8 4 ) > 1 2 7 THEN BET
2 4 0 FOR J = 1 TO 4 0 0
Puzzlecorner
Can you work out how to make the
computer give you more than 5 targets
to choose from each time?
I*
Iceberg
Your huU is badIy damaged and
you've no weapons to speak of. As
youtimpslowly home through
treacherous iceberg-strewn waters,
you become aware that an enemy
ship is taUing you. Strangely it can
detect you but not the icebergs, so
your best chance is to lure it into
hittingone.
Your computer wiU print a grid
showing the position ofyour ship
(Y), the enemy (Z) and the icebergs
(*). You can move one space North,
South, East or West each go. The
enemy moves towards you by the
most direct route (it can move
diagonaUy too). Ifyou move into any
ofthe 8 positions surrounding the
enemy, you wUl be captured, and if
you hit an iceberg you wUl sink.
Can you escape?
*QU^Q*'J
4 0 FOR 1=1 TO N
| s * B A B 5 0 LET B < I N T < R N D * 8 + l > , I N T < R N D * B + l > ) = 2 3
6 0 NEXT I
+ B A B 7 0 LET SX=INT(RND*8+1>
+ 8 0 LET SY=INT<RND*B+1>
9 0 IF B < S X , S Y ) 0 0 THEN BOTO 7 0
| s * B A B 1 0 0 LET B < S X , S Y ) = 6 3
*BA#110
+120
130
|s*BAB140
AB150
160
170
180
190
200
210
220
230
240
250
LET YX=INT(RND*8+1>
LET YY=INT(RND*8+1)
IF B ( Y X , Y Y ) 0 0 THEN 6 0 T 0
LET B<YX,YY>=62
CLS
FOR Y=1 TO 8
FOR X=1 TO 8
IF B < X , Y ) = 0 THEN BOTO 2 1 0
PRINT C H R * ( B ( X , Y ) ) ;
BOTO 2 2 0
PRINT " . " ;
PRINT " ";
NEXT X
PRINT
NEXT Y
110
Puzzlecorner
Can you work out how to make the grid
bigger?
Now work out how to add more
icebergstoo.
MX~H
(S
290
29
300
0
32
320
LET
LET
LET
LET
YY=YY+<D*="S"
YY=YY-(D*="N"
YX=YX+(D*="E"
YX=YX-(D*="W"
AND
AND
AND
AND
if
YY<>8)
YY<>1)
YX<>8)
YX<>1)
1
I
:}
>}
SOTO 150 . i - - - i i - - i i - i i - i
PRINT "YOU'VE BEEN CAUBHT"
BOTO 800
PRINT. "YOU'VE HIT AN ICEBER6"
BOTO 800
PRINT "YOU'RE SAFE - HE'S HIT ONE"
STOP
TheWizard'sWall
The waU the Wizard built to surround his secret stronghold is no ordinary
waU. The stones in it are people, petrified by the Wizard's angry stare, and,
what's more, it can move. Ifyou can break a hole through it with yourtrusty
catapults which fling gigantic boulders, you wiU destroy the Wizard's
magic powers and turn the stones back into people again. There are
problems though - the Wizard is working on a speU which stops missiles in
mid-air and sends them back where they came from. Sometimes he can
make it work...
Ifyou don't succeed, you wiU become just another stone in the Wizard's
WaU!!!!
Aio CLS
20 PRINT "WIZARD'S WALL"
30 PRINT
40 PRINT "DO YOU WANT ANY HELP?"
50 INPUT I*
A60 IF I*<l>="Y" THEN GOSUB 740
70 PRINT "DIFFICULTY?"
80 PRINT "<5=EASY, l=DIFFICULT)"
90 INPUT Q
100 DIM W(8,8)
110 DIM E(8)
120 FOR Y=1 TO 8
130 FOR X=1 TO 4
**A#l40 LET W<X,Y>=20
150 NEXT X
160 NEXT Y
170 LET Z=0
180 FOR C=1 TO 3
190 LET D=INT(RND*80+21)
200 GOSUB 430
210 IF Z=1 THEN GOTO 1150
220 PRINT "YOU ARE ";D5" YARDS AWAY"
*"A#230 LET W=INT(RND*41)-20
240 IF W=0 THEN PRINT "NO WIND"
250 IF W<0 THEN PRINT "WIND TO RIGHT"
260 IF W>0 THEN PRINT "WIND TO LEFT":
270 PRINT "GIVE ELEVATION (1-90)"
280 INPUT A
290 PRINT "GIVE SPEED"
300
310
320
330
340
350
360
*"A370
380
390
400
410
420
*BA*430
440
450
460
470
480
*BA*490
500
510
520
530
540
550
560
*"A#570
*BA*580
590
600
A610
620
630
640
650
660
670
680
690
700
710
INPUT V
LET A=A/lSO*3.1416
LET H=TAN<A>*<D-W)-<5*<D-W)^2>/<V*C0S(A> > A 2
LET H=INT<H/Q)
IF H>0 AND H<9 THEN GOSUB 540
IF H<1 THEN PRINT "SHOT WAS TOO NEAR'
IF H > 8 THEN PRINT "SHOT WAS TOO FAR"
IF RND>.2 THEN GOTO 200
PRINT "THE WALL HAS MOVED..."
NEXT C
PRINT "YOU HAVE BEEN TURNED"
PRINT "INTO STONE"
STOP
FOR 1=1 TO 30
NEXT I
CLS
PRINT
FOR Y=8 TO 1 STEP -1
FOR X=1 TO 8
PRINT CHR*<W<X,Y)>;
NEXT X
PRINT
NEXT Y
RETURN
GOSUB 650
LET W(E<H>-1,H)=0
IF V*COS(A)>50 THEN LET W(E(H>-2,H)=0
I F R N D > . 5 AND H < > 1 THEN LET
W<E(l),l)=29
'
TheWizard's Wallcontinued
720 NEXT Y
730 RETURN
740 PRINT "YOU ARE ATTACKING THE"
750 PRINT "LAST STRONGHOLD OF THE"
760 PRINT "NOTORIOUS WIZARD, WHO"
770 PRINT "IS HIDDEN BEHIND AN"
780 PRINT "ENDLESS STONE WALL,"
790 PRINT "EACH STONE BEING ONE"
800 PRINT "OF HIS FORMER VICTIMS."
810 PRINT "ONLY YOU CAN ATTACK,"
820 PRINT "AND FREE THEM FROM"
830 PRINT "HIS MAGIC."
840 PRINT "YOU MUST DESTROY THE"
850 PRINT "WALL USING CATAPULTS,"
860 PRINT "BUT BEWARE, THE WIZARD"
870 PRINT "HAS THE POWER TO MOVE"
880 PRINT "THE WALL BACK AND"
890 PRINT "FORTH, AND OCCASIONALLY,"
900 PRINT "TO DEFLECT YOUR SHOTS"
910 PRINT "BACK AT YOU."
920 GOSUB 1110
930 PRINT "AFTER EACH SHOT, YOU ARE"
940 PRINT "SHOWN A CROSS-SECTION"
950 PRINT "OF THE WALL, SHOWING"
960 PRINT "HOW MUCH DAMAGE THERE"
970 PRINT "IS. "
980 PRINT "NOTE THERE ARE CERTAIN"
990 PRINT "KEY STONES THAT PRODUCE"
1000 PRINT "LOTS OF DAMAGE, AND"
1010 PRINT "ALSO, THE FASTER THE"
1020 PRINT "BOULDER IS MOVING"
1030 PRINT "HORIZONTALLY, THE MORE"
1040 PRINT "DAMAGE IT WILL CAUSE."
1050 PRINT "CAN YOU DEFEAT THE"
1060 PRINT "WIZARD IN TIME TO SAVE"
1070 PRINT "THE THOUSANDS OF TRAPPED"
1080 PRINT "SOULS
"
1090 GOSUB 1110
llOO
lllO
1120
1130
1140
1150
1160
1170
1180
1190
1200
RETURN
PRINT "PRESS A KEY ";
IF INKEY*="" THEN GOTO 1120
CLS
RETURN
PRINT "YOU MANAGED TO BREAK"
PRINT "A HOLE IN THE WIZARD'S"
PRINT "WALL - YOU HAVE BEATEN"
PRINT "HIS MAGIC POWERS, AND"
PRINT "FREED HIS VICTIMS."
STOP
Missile!
This game is different from tne
others in this book because it uses
graphics. As the computers vary so
much in the way their graphics
work, there is a separate -rogram
for each one. Read the infructions
on this page for how to play the
game and then look through the
pages that follow for the version for
| 1 yourcomputer.
31
32
FOR J=1 TO 3
IF F(J)=O THEN 220
POKE 8164+J*5-Y<J>*22,32
IF Y<J)=22 THEN 240
Y(J)=Y<J)+1
POKE 8164+J*5-Y(J)*22,30
IF ABS(I-J*5)<=1 AND P=Y(J) THEN 280
NEXT
NEXT
PRINT CHR* <147);"MISSED! ! ! i"
END
PRINT CHR*(147>;"HIT!H!"
POKE 36877,220 : POKE 36878,15
FOR K=1 TO 500 : NEXT
POKE 36877,0 : POKE 36878,0
END
POKE 8163+I-P*22,32
POKE 8164+I-P*22,121
RETURN
34
j|
4ifc.:-"-
J
'-"3fcfe
35
1
2
3
3
You can add as many print statements
4
5
as you like for the instructions, just
6
remember to put a number and the
SZX7
word PRINT at the beginning ofeach*i A 7
36
PRINT
PRINT
PRINT
PRINT
0,-15,5,10
Change line
numbers according
to your program.
SpecialnoteforBBCand
Spectrumusers
^^
^W^
38
Planningagame
~~TT~x^nrT~?nr~?rF
PLAN
2)
PRlNTTlTLEMD
INSTRUCTIONS
2) CHOOSE A TARCET
FORTHl5 GAME
3)BECilN A LOOP TO
GIVE THE PLAYER
N COES
4-) CiET A SHOT FROM
THE
PLAYEH
39
SummaryofBASIC
This section lists some common BASIC words and describes what they
make the computer do and how they are used. Most ofthem have beenused
in the programs in this book, so you can check back through the book to see
how they work in a game. Not all the words can be used on allthe
computers mentioned iri this book. The conversion chart on page 46 shows
whatyoucanuseinstead.
LET tells the computer to label a section ofits
memory and put a particular value in it e.g. LET
A=6 means label a section of memory "A" and put
the value 6 in it. "A" is called a "variable" andputting
something in it is called "assigning a value to a
variable".
Some variable labels are followed by a dollar
sign e.g. A$. This means they are for "strings",
which can contain any number ofcharacters,
including letters, numbers and symbols.
PRINT tells the computer to display things on the
screen and you can use it in several ways:
A message enclosed in quotation marks with
PRINT in front of it will be displayed on the screen
exactly as you typed it. The section inside quotes
does not have to be in BASIC, it can be anythingyou
like.
PRINT followed by a variable label e.g. PRINT A
or PRINT A$ tells the computer to displaythe
contents ofthat variable on the screen.
PRINT can also do calculations and then display
the results e.g. PRINT 6*4will make the computer
display 24.
You can use PRINT by itself to leave an empty
line.
RND tells the computer to choose a number at
random. Different computers use different forms of
RND and you can see what these are in the
conversion chart on page 46. On Sinclair computers
D by itselfproduces a number between 0 and
99999999. You can vary the limits of the number it
chooses by multiplying RND and adding to it. E.g.
RND*20 produces a number between 0 and
19.99999999, while RND*20+1 producesanumber
between 1 and20.99999999.
See INT for how to produce only whole numbers.
See CHR$ for how to produce letters and other
keyboard characters at random.
ASCII chart
Code
number
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
ASCII
character
space
1
>)
#
$
%
&
i
(
)
*
+
i
I
0
12
3
4
5
6
7
8
9
:
i
<
=
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
ASCII
character
>
>
(a)
A
B
C
D
E
F
G
H
I
K
L
M
N
O
P
R
S
T
U
V
W
X
Y
Z
Code
number
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
ZX81
character
Code
number
19
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
$
'
?
(
)
>
<
I
i
>
0
1
2
3
4
5
6
7
8
9
A
B
C
ZX81
character
D
E
F
G
H
I
T
K
L
M
N
O
P
oR
S
T
U
V
W
X
Y
Z
Max. number of
lines down
(or number of rows)
VIC 20
22
23
TRS-80
64
16
BBC
20/40/80
16/24/32
ZX81
32
22
ZX Spectrum
32
22
Apple
40
25
r^
Conversion chart
This quick reference chart shows some ofthe variations in the BASIC used by the machines in this book. Itdoes
not include instructions for graphics, sound or colour as these vary so enormously from machine tomachine.
Note also that although most computers (except the BBC) use PEEK and POKE, they do not use the samesystem
ofmemory addresses, so the numbers used with PEEK and POKE must be changed for eachcomputer.
Select random
number between 0
and 0.99999999
Select random
number between 1
andN
Select random letter
between A and Z
BBC
VIC/Pet
Apple
TRS-80
ZX Spectrum
ZX81
RND(1)
RND(1)
RND(1)
RND(0)
RND
RND
RND(N)
RND(1)*N+1
RND(1)*N+1
RND(N)
RND*N+1
RND*N+1
CHR$(INT(RND(1)
CHR$(RND(26)+64) CHR$(INT(RND(1)
*26+65))
*26+65))
CLS
HOME
CLS
CLS
CLS
Check keyboard to
see if key being
pressed
INKEY$(N)
GETX$
X$=" "
IF PEEK(-16384)
> 127 THEN GET X$
INKEY$
INKEY$
INKEY$
Convert characters
into code numbers
ASC("X")
(using ASCII code)
ASC("X")
(using ASCII code)
CODE("X")
(using ASCII code)
CODE("X")
(using ZX81 code)
Clear screen
ASC("X")
ASC("X")
(using ASCII code) (using ASCII code)
Move cursor up
CALL-998
PRINT CHR$(27)
PRINT CHR$(26)
PRINT CHR$(8)
PRINT CHR$(8)
PRINT CHR$(24)
PRINT CHR$(8)
PRINT CHR$(9)
PRINT CHR$(29)
PRINT CHR$(21)
PRINT CHR$(25)
PRINT CHR$(9)
LEFT$(A$,N)
LEFT$(A$,N)
LEFT$(A$,N)
LEFT$(A$,N)
A$(lTON)
A$(1T0N)
RIGHT$(A$,N)
RIGHT$(A$,N)
RIGHT$(A$,N)
RIGHT$(A$,N)
A$(NTO )
A$(NTO )
MID$(A$,N1,N2)
MID$(A$,N1,N2)
MID$(A$,N1,N2)
MID$(A$,N1,N2)
A$(NlTON2)
A$(NlTON2)
Take 1 st N
characters of string
Take last N
characters of string
Take middle N
characters of string
<fi
<t
Answers
You mayfindthat your answers to
some ofthe puzzles are different to
the ones given here. As long as they
work on your computer then this
doesn't really matter, but check to
see ifthey are as neat and simple as
the answers in the book.
Page5
Robot Missile
Line 90 teUs the computer how many
times to loop round and get a guess
from you. So, for more chances of
guessing the secret code letter,
change the last number intine90 to a
higher one. For less chances, change
ittoalowerone.
Page7
The Vital Message
Page 11
Desert Tank Battle
Add the following lines to the program
to add the possibitity ofthe robots
seeingyou:
175 IF RND<.05 THEN GOTO 250
250 PRINT "THEY'VE SEEN YOU-AABG6HHHH"
260 STOP
hi this program, tines 150 and 160 are a This is a difficult puzzle, so dont worry
"delay" loop. They make the computer ifyou couldn't do it. Try out the answer
anyway. Add thesetinesto get the two
dd nothing for a certain length oftime
targets.
before going on to the next instruction
in the program which is to clear the
55 LET P=INT(RND+.5)*4+l
messageoffthescreen.Tomakethe szx57 LET p*=cHR*<p+5i>
messagestayonthescreenlonger, *mA*% ^ ^ T r a ^ L E R*=R*+P*
youneedtomakethecomputerloop
iso LET s=s+p
round more times. You can do this by
changing the last number in tine 150 to
a higher one.
Page 15
Robot Invaders
Page9
You can get 100 points for U, V, W, X or
Shootout
Y and 10 points for the others by
making these changes.
To make it possible for the computer
to miss too, add the foUowingtinesin
220 LET H=H+10
addition to those in the 'Making the
225 IF P*>"T" AND P*<"Z" THEN LET
H=H+90
game harder" box.
155 IF RND<.1 THEN GOTO 250
250 PRINT "HE SHOOTS BUT MISSES"
260 GOTO 90
Page17
SecretWeapon
You can add the scoring system in the
Page19
Escape!
This is the simplest way to add three
robots to the game, though it makes
the game rather difficult to win.
22 FOR R=1 TO 3
25 PRINT "ROBOT "jR
300 NEXT R
310 STOP
Page21
Pirate Dogfight
To make your chance ofhittingthe
pirate equal to his chance ofhitting
you, change the .7 in line 290 to .5.
Page23
Supersonic Bomber
To get more targets each time, change
the 5 in lines 30,70 and 120 to a higher
number. You must put the same
number in aU three Unes.
Page25
Iceberg
48
Goingfurther
Here is a Ust of books you should
find useful if you want tofindout
more about computers or writing
programs.
Usborne Guide to Computers by
Brian Reffin Smith, Usborne
Understanding the Micro by
Judy TatcheU and Bill Bennett,
Usborne
bitroduction to Computer
Programming by Brian Reffin
Smith, Usborne
niustrating BASIC by Donald
Alcock, Cambridge University
Press
Fred Learns about Computers,
Macdonald & Evans
The BASIC Handbook by David
A. Lien, Compusoft PubUshing
The Computer Book by Robin
Bradbeer et al, BBC PubUcations
Printed in Spain by
ELEXPURU, S. A. L.-Bilbao
Usborne Computer Programs Each ofthese colourful new books contains 14 simple games programs to
play on a microcomputer.* Alongside the programs there are
explanations of how they work and puzzles and suggestions for ways of
changing them. Through playing these games even complete beginners
wiU quickly begin to understand how a simple program works and be
itching to write their own. There are tips and hints on writing programs
and a summary of BASIC at the back ofeach book and aJso a chart which
wiU help you convert programs in magazines and other books to work on
your micro.
*The programs in these books are suitable for use on the foUowing
micros: ZX81, BBC, TRS-80, VIC 20, Pet, Apples which use PalsoftBASIC
andZXSpectrum.
\
tT
_____
COMPuTR
*rraoouCTONTO-^^
COMPUTER
PROGRAMMING
^Agutd*tor>tMotatet>*ginmri
A colourful guide to
microcomputers, how
they work and what they
can do, with lots of ideas
for things you can do
with a micro.
A step-by-step guide to
progxanuning in BASIC
for absolute beginners.
With lots of programs to
runonany
microcomputer.
PubUshed in Canada by Hayes Pubhshing Ltd, 3312 Mainway, Buriington, Ontario, Canada, L7MlA7.
PubUshed in the USA by Hayes Books, 4235 South Memorial Drive, Tuka, Oklahoma, USA.