52
COMPUTER ^SpeCtrU-^8,BBC,TRS-80.App^ / i o * . . . . . o . 0 * * . o . . PROGRAMS & m M

Computer Battle Games

Embed Size (px)

Citation preview

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 1/52

COMPUTER

/ i

• • o • • * •

. . . . . o .0 * • * •

. o . .

PROGRAMS & mM

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 2/52

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 3/52

COMPUTER

T T L E G A M E* W £ "

Daniel lsaaman

and Jenny TylerContents

2 AboutthisBook4 RobotMissile6 TheVitalMessage8 Shootout

10 DesertTankBattle

Battle at Traitor's CastleRobot Invaders

16 SecretWeapon18 Escape!20 PirateDogfight22 SupersonicBomber24 Iceberg26 TheWal l

1214

30 Missile!:TRS-80version31 Missile!:BBCversion32 Missile!:ZXSpectrumversion33 Missile!:VIC20version34 Missile!:Appleversion

35 Missile!:ZX81 version36 Addingtotheprograms38 W riting your ow n programs40 SummaryofBASIC46 Conversionchart47 PuzzleAnswers

I l lustrated by:

Rex Archer , J im Ba mbe r , Ton y Baskeyf ie ld , M ar t in Ne w to na n d G r a h a m R o u n d

Designed by:Graham Round and Roger Pr iddy

Robot Invaders program by Bob Merry

First published in 1982 by Usborne Publishing Ltd,20 Garrick Street, London WC2E 9BJ

© 1982 Usborne Publishing Ltd

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 4/52

AboutThisBook

This book contains simple gamesprograms to play on a microcomputer.

They are written for use on ZX81, ZX

Spectrum,BBC,VIC20,TRS-80 and Pet and Apple micros, andmanyare short enough to fit into theZX81'slKofmemory.

Most micros use the language BASIC,but they aU have their ow n variations ordialects. In this book, the main listing foreach program works on the ZX81 andUnes which need changing for the othercomputers are marked with symbols and

printedunderneath. The fact that theprograms are written for several microsmeans that they do not make fuU use ofeach one's faciUties. You could tryfinding ways of making the programsshorter and neater for your micro.

For each game, there are ideas forchanging and adding to the programsand towards the back ofthe book youwiU find tips and hints on writing games

of your own. Also in the book is aconversion chart to help you adaptprograms in magazines and other booksfor your micro and a summary oftheBASIC terms used in this book.

Typing in the programs

Lines which need changing forcomputers other than ZX81 are markedwith these symbols:A VICandPet* BBCandAcornElectron• TRS-80• Apples ZXSpectrum

Every time you see the symbol for themicro you are using, look below for thecorresponding Une number with thesame symbol and type that in instead.

Points to remember

1 Type th e Unes exactly as they are printedincluding aU punctuation and spaces.

2 Press RETURN, NEWLINE or ENTERkey at the end of each program Une.

3 CheckeachUneasyougo .

4 Makesureyoudon'tmissoutaUneorconfuse one with another. A piece ofpaperor a ruler is useful to mark your place inthe Usting.

5 Lookoutforthesymbolsandmakesureyou use the correct Unes for yourcomputer.

6 If you ar e using a ZX81 or ZX Spectrum,remember not to type the programinstructions letter by letter but to use thespecial key for each instruction instead.

You may find it easier to get someone toread the program out to you while youtype it in. Don't forget to explain thattheymust read every comma, fuUstop, bracketand space and differentiate between letter"0" and zero, FOR an d 4, and TO and 2.

Debugging programs

When you have typedin the program , checkyour manual to find outhow to display it on thescreen. (Usually youtype LIST foUowed byth e line numbers ofthesection you want t osee.)

VIC20 versions ofallexcept thegraphicsprogram should workonPetcomputers.

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 5/52

Checkyouhavetyped everythingcorrectly. It is easytomake mistakes, soexpect to find some . Useyour manual to find out

how to make changes tothe program once it istyped in. Ifin doubt, youcan always type th e lineagain. AU the computerswiU replace an existinghne with a new one withth e same number.

Here is a checklist of commonmistakes to look out for:

1 Linemissedout2 Linewronglynumbered

3 Thebeginnihgofonehnejoinedontothe end ofanother.

4 Brackets, comm as, colons, semicolons, fullstops or spaces missed out,especiaUy in long, compUcated lines.Watch for double brackets in particular.

5 Wrong Une used for your computer.

6 Letter "O" confused with zero.

7 Wrong numbers used, e.g. extra zerosincluded.

Playing the games

To start th e game you must type RUN. Insome games things happen very quickly,so make sure you have read th einstructions and know what you aresupposed todo .

It is quite Hkely that the program stiU

has a mistake in it and either won't iat aU or the game won't work properly.Sometimes your computer wiU give youan error code which you can look up inth e manual. This may help you findthemistake, though not always. List the

program again and check it carefuUyagainstthebook.

Whenthe game is over, the computerwiU usually say something like BREAK INLINE 200. To play again, you have totypeRUN.

Experimenting with the games

There are suggestions for changing and

adding to the programs throughout thebook, but don't b e afraid to experimentwith changes ofyour own. You can'tdamage th e computer and you canalways change back to the original ifthechanges don't work.

You wiU probably find you want toadjust th e speed of some games, *especiaUy after you have played them anumber of times . You will find out which

Une to change on each program page.Whereveryou se ePRINT,youcanchange th e message in/quotes that foU6ws it toJwhatever you Uke.Also, unless you haveZX81 with only lK, youcan add extramessages.Type a line number (say 105 ifyou wantto ad d a message between lines 100 and110), then type PRINT, then yourmessage inside quotes.

Ifyour computer can make coloursand sounds, you could use your manualto  find out how they work and try addingthem to the games in this book.

*Seepage37foraspecialnoteforBBCandSpectrumusers.

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 6/52

RobotMissileThe year is 2582 and the people ofEarth are inthemidst ofbattle against the Robots. A lethal RobotMissile has just landed and everyone is dependingon you to find the secret code which unlocks itsdefuse mechanism. Ifyou fail, the entire Earth

Command Headquarters will be blown up.Your computer knows what the codeletter is . You must type in your guess andit wUl tell you whether th e code letteris earUer or later in the alphabet.You have four chances to find th ecorrectletterbeforethemissileblowsup. iiUf*.

m. - ' * — * — .,«11, matfmJlw TrWr", j M*Sl

t \ i mB^ B i ^ % i i **

I I I

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 7/52

^

*

K>

10 PRINT "ROBOT MISSILE"

20 PRINT

30 PRINT "TYPE THE CORRECT CODE"

40 PRINT "LETTER (A-Z) TO"

50 PRINT "DEFUSE THE MISSILE."

60 PRINT "YOU HAVE 4 CHANCES"

70 PRINT

s*BA#80 LET C*=CHR*<37+INT<RND*26+1>>-

How the programworks

- Th ese Unes print the title andinstructions.

This sel ec ts a numberb e t w e e n 0 and 26, conver ts itto a letter (the "secre t code" )and puts it in CS.

££f£

90 FOR G=1 TO 4

100 INPUT G*

CS \ L i n e 9 0 begin s a loop whic h_ J ma kes Unes 100-140 repeat 4

— t imes .

• Puts your gue ss in GS.

110 IF G*=C* THEN BOTO 210'

120 IF G*<C* THEN PRINT "LATER";

130 IF G*>C* THEN PRINT "EARLIER";

140 PRINT " THAN ";G*

1

1 C h e c k s i f y o u r l e t t e r i s t h esam e as the "secret code" inCS. I fso com puterjumps to 210.

150 NEXT G

160

170

180

190

200

210

220

?30

PRINT

PRINT

PRINT

PRINT

STOP

PRINT

PRINT

STOP

C he cks i f s ecre t code l e tt er isI earU eror la ter in the

J a l p h a b e t t h a n y o u r s a n dprints an appropriatem e s s a g e .

End ofloop . Go es back fornextturn.

"BOOOOOOOOMMM "

"YOU BLEW IT."

"THE CORRECT CODE WAS";C*

- Th is prints if aU your gue sseswere wrong .

" T I C K . . , F Z Z Z Z . .

"YOU DID IT"

CLICK.- This prints i fyo u gue ssed

right.

T h e a b o ve t is ting w i l l w ox k on a Z X 8 1 . F o ro t h e r c o m p u t e r s , m a k e t h e 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^Adding to the program

Y o u c a n m a k e t h e c o m p u t e r p r in t an

e x t ra m e s s a g e f o r a c o r r e c t g u e s s o n t h e

las t go . C ha ng e tine 220 by a d d i n g ase m ic o l on to i t , tike th i s :

220PRINT"YOUDIDIT";

a n d a d d a n e w t ine 230:

230 IF G = 5 THEN PRINT "OUST)"B0._ i u i . j i m , i . , , ii. . « p . . ^ . . i w i

Puzzlecorner

S e e i f y o u c a n w o r k o u t h o w to c h a n g e

t h e p r o g r a m t o g i v e y o u m o r e o r l e s sc h a n c e s o f g u e s s i n g t h e c o d e le ,tt er .

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 8/52

The Vital Message

i

. ^

i

\ _ ^a ^j^TSk

> 4 »

- a i ,

f/ rA' /

v , ' ^4yr

w to * if M

*s^**&4*

*'** *$sSf**% **»^v

N i 2

Youarealasercommunicationsoperator. Yourjob is to interceptrobot mes sag es and relaythem to Command HQ. A vitalcode messa ge is expected. Ifyourelay it correctly, th e Robot attackwiUbecrushed.

This gam e tests your skUl atremembering a group of

letters which yousee for only a very

short time. The computerwiU ask you for a difficulty

from 4 to 10. When you have typedin your answer, letters will appear

top left of your screen and disappearagain fairly quickly. Memorize them

and then type them into the computerand see if you were right.

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 9/52

• • 1 0 C L S .

How the program works

•C lea n screen before game starts.20 PRINT "VITAL MESSASE"

3 0 PRINT fisksyoufora"difficuItynumber"and40 PRINT "HOW DIFFICULT? ( 4 - 1 0 ) "L_ putsit inD .50 INPUT D J

6 0 IF D<4 OR D> 10 THEN GOTO 4 0 Check syournum berisn'tlessthan4ormorethanlO.

70 LET M*==""

Sets up an empty ("nuU" in computerlanguage) string labeUed M Sinw hichthe computer can store the secretmessage.

chosen and put in MS

80 FOR 1 = 1 TO D ~|ComputerloopsroundDtimes.Each8*«A»90 LET M*=M*+CHR*<INT<RND*26+38) )Lloopitchoosesaletterandaddsitto

100 NEXT I | thestringoflettersithasabeady

A #1 1 0 C L S120 PRINT "SEND THIS MESSAGE:

130 PRINT I Clearsscreenandthenprintsthe

140 PRINT M* J message.

. • 1 5 0 F O R 1 = 1 T O D * 8 l tttttZEEgZ***for a number of times depending on D.

i——i———i.i—i- Clears sc reen w hen loop has finished.

160 NEXTI 1A#170 CLS

180 INPUT N*-

190 IF N*=M* THEN GOTO 240-

WRONG"

HAVE SENT:

200 PRINT "YOU GOT IT

210 PRINT "YOU SHOULD220 PRINT Mt230 GOTO 260240 PRINT "MESSAGE CORRECT"250 PRINT "THE WAR IS OVER"260 STOP

The abo ve U sting wiU woxk on a ZX81. Forother computers , ma ke the ch an ges b e low .

#10,110,170 HOMEA10,110,170 PRINT CHR*(147)

*A#90 LET M*=M*+CHR*(INT < RND <1)«26+65)•9 0 LET M*=M*+CHR*(INT<RND(0)*26+65)s90 LET M*=M*+CHR*(INT<RND*26+65))

• A» 15 0 FOR 1 = 1 TO D*180

•150 FOR 1=1 TO D*400

Howtomakethegame harder

You can chan ge the program to inc ludenum bers and punctuation mark s in the sec retm essa ge . Do th is by c hang ing l ine 90 as foUows:

zx90 LETM$=M$+CHR$(INT(RND*43+21))•A»90 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))

• Puts your version of the message inNS.

< Checks ifyour m essage is the same asthe message in MS andjumps to 240ifitis.

• Prints if you are wrong, teUing youwhat the message should have been.

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 10/52

VShootoutY o u a r e s t a n d i n g b a c k t oba ck . You ta ke 10 p a c e s , t u r nand re ac h fo r yo ur gun . Howq u i c k a r e y o u ? Ca n y o us h o o t f i r s t ?

Y o u r c o m p u te r p r i n t s t h en u m b e r s 1 t o 1 0 t o r e p r e s e n tth e 10 p a c e s , p a u s e s a n d

e n p r i n t s H E D R A W S . . .m u s t b e r e a d y t o p r e s s a

y ( a n y o n e w i l l (i^mgfcesewords

t h e s c r e e n . I ie n o u gh , y o u #f l twi f l$8bn' t ,

s s a k e y b e f a r e H "

W S c o m e s u p o i. t i caUylose .

••10 CLS20 PRINT30 PRINT40 PRINT

¥COWBOY SHOOTOUT -"

"YOU ARE BACK TO BACK""TAKE 10 PAC ES.. ."

5 0

^ • t p o^ " » » 7 0

F O R 1 = 1P R I N T I ;NEXT I

T O 1 0

• i

L

How to change thespeed ofth e gam e

You can adjust the tim e youhave to react to the m essageand press a key by cha ngingthe las t num ber in Une 130. AsmaUer number wiU give youless time. (For the BBC,chang e the number inbr ac ke ts in Une 140.)

a ijm q

80 PRINT• •± •9 0 FOR 1=1 TO RND*200

100 NEXT I

•• •l lO IF INKEY*<>"" THEN GOTO 160

120 PRIN T "HE DRAW S ";

• •± •1 30 FOR1 = 1

TO 5• ± • 1 4 0 IF INKEY*<>"" THEN SOTO 190•1 50 NEXT I

To

keyao*

160170180

190200210

SHOOTSARE DEAD 1

AD.'J

YOU SHOOT FIRST.KILLED HIM."

PRINT "AND

PRINT "YOU

SOTO 210

PRINT "BUTPRINT "YOU

STOP

The abov e Usting wiU work on a ZX81. Forother comp uters , m ake the chan ges below.

•10 HOME• 10 PRINT CHR*(147)•60 PRINT |I|".."|

• •• •6 5 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• 140

GET I* : IF I*<>""

IF INKEY*(40><>"THEN GOTO 190

THEN GOTO 190

Making the game harderIfyou c han ge th e progra m as foUows, you wiU add

the possibUity ofyou missing som etimes:1) b i Une 140, change 190 to 220.2)AddtheseUnes:

s ZX 220 ff RND >.3 THEN GOTO 190• • • 2 2 0 f f R N D ( l ) > .3 T H E N G O T O 190

•220 ff RND(0)>.3 THEN GOTO 190230 PMNT "BUT YOU MKSED"240GOTO90

— M i^^_^

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 11/52

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 12/52

DesertTankBattleThe last major stronghold ofRobot forces outside the U.R.S* is hid de nin an cien t

castle ruins in the middle ofthe desert. A fleet ofdeser t hov ertanks has bee nsentto destroy it and you are the comm ander. Your tank controls the five rem aining

missiles.You must as se ss carefully the direction and elevation before you launch each

one. Your computer wiU ask you for a direction angle be twe en —90° (extreme left)

and +9 0° (extreme right) and an elevation angle betwee n 0° (along the ground) and90° (straight up in the air). The elevation determines the distance the m issile wiU

travel.Is your aim good enough to destroy the robot stronghold?

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 13/52

10 PRI NT "D ESERT TANK BATTLE'• • A » 2 0 LET T=»INT(RND»181 )-90

• • A » 3 0 LET D=RND-

90) ?" I

>) ?"

Howthe program works

This sele cts a whole number. between - 9 0 and 90 forthedirection.

• This selects a number

between 0 and 1 for thedistance o fthe c astle fromyou.

Get your guesses and putsthem in A and B.

90 LET Dl=SIN(2*(B/180»3.1416>).

40 FOR S=1 TO 5

50 PRINT "DIRECTION <-90 TO

60 INPUT T1

70 PRINT "ELEVATION (0 TO

80 INPUT B

Uses your elevation an gle to— calculate the distance your

missile went. (Answer wiU bebetween 0 and 1).

lO O I F A B S < T - T l ) < 2 AND A B S < D - D l > < . 0 5 T HEN 6 0 T O 220 I f y o u r

directionwaswithin2 degreesand your distance within 0.05,

ABS takes the "absolute" \ then you have hit the castle,value of a number, wh ich J Program jumps to line 2 20 tomeans it ignores + or —J teU you so .signs.

1 1 0 P R I N T " M I S S I L E L AN DE D "; ~| C o m p a r e s y o u r d i r e c t i o n1 2 0 I F T l < T T H EN P R I N T "TO THE L E F T " ; U a n g l e w i t h t h e n u m b e r1 3 0 I F T l > T T H EN P R I N T "TO THE R I G H T " ; | c h o s e n i n l i n e 2 0 a n d p r i n t s

an appropriate message.

1 4 0 I F A B S ( D l - D ) > . 0 5 AND T l < > T T HE N P R I N T "AND " j D ec i d eswhethertoprint "and" by

A semi-colon at the end ofa print statement X comparing the distan ce

tells the computer notto go to a new Une for ) your missile travelled withthenextitemtobeprinted. S thenumberchoseninUne30.

150 IF D-Dl>.05 THEN PRINT "NOT FAR ENOUGH";

160170180190200210220230240

IF Dl-D>.05 THEN PRINT "TOO FAR

PRINTNEXT G

PRINTPRINTSTOPPRINT "*KABOOOMMM*

PRINT "YOU'VE DONESTOP

• Prints a messageifyourshot wastoo long or short.

•DISASTER -

'RETREAT IN

YOU FAILEDDISGRACE" }

, • 1

: iT"J

• Prints ifyou lose.

Prints ifyo u win.

The above tisting will work on a ZX81. Forother computers, make the chan ges below* A # 2 0 LET T=INT(RND(l)*181)-90

• 2 0 LET T=INT(RND(0)tl81)-90* A » 3 0 LET D=RND(1)

• 3 0 LET D=RND(0)

Puzzlecorner

Can you work out how to add the

possibil ity ofth e robots see ing you andshooting at yo u before your five g oe sa r e u p ?

11

UnitedRobotStates

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 14/52

BattleatTraitor'sCastle

*«&

LlO PRINT "TRAITOR'S CASTLE'20 LET S=0 — ~ — — ~ — —

30 FOR G=1 TO lO 1

40 LET R$=""

|* B A* 5 0 LET T=INT(RND*9+1)-

60 FOR L=1 TO 970 IF L=T THEN LET R*=R*+"0"80 IF L O T THEN LET R*=R»+".'90 NEXT L

The King is wag ing a fierce andbloody battle against h isdeadliest enem y - the TraitorBaron. You are one ofthe King'scrack bowm en and at this verymoment you are crouchingbehind the bushes outside theBaron's Castle, shooting at hismen as the y lift their head s above Ithe battlements.

Your computer will print a rowcontaining eight dots and an O.The number key s 1 to 9correspond to the position of the 0in the row. You ha ve a short timeto press the correct key, and hit

the O, before it disappears .How many o fthe Baron's men

canyouhit?

lOO PRINT R* , '

• • 4 « 1 1

*xri20 FOR 1=1 TO

20 LET I*=INKEY*«}130 IF VAL<'140 NEXT I

O"+I*)=T THEN GOTO 170-

I50 PRIN T "MISSED'

160 GOTO 190

170 PRIN T "GOOD SHOT"

180 LET S=S+1

190 NEXT G

200 PRINT "YOU HIT '*jS;"OUT OF 10'210 STOP

The above Listing wiU work on a ZX81. Forother computers, make the changes below.

• 5 0 LET T = I N T ( R N D ( 0 ) * 9 + 1 )* A * 5 0 LET T = IN T < R N D < 1 >* 9+ 1 )

A 1 1 0 FOR 1 = 1 TO 20 0• 110 FOR 1 = 1 TO 6 0

• • 1 1 0 FOR 1 = 1 TO 90

• 1 1 5 LET I * = " "i *120 LET I*=INKEY*<1)

• 1 2 0 I F P E E K ( - 1 6 3 8 4 ) > 1 2 7 THEN GET I *M 2 0 GET I *

1• ' ' • — , • - v . - ^

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 15/52

E5'Mak ing the gam e faster or slower

You m ay f ind tha t the com pu te r wo rk s too quicklyor too s l owl y for you in th is ga m e. You can adjus tth i s by ch a ng ing the l a s t nu mb e r in l i ne 110. Al ow e r nu mb e r wiU m a k e the ga m e f a s te r .

Ho wth e program works

Sets your sco re to zero for•star tofgame.

• Beginning ofloop whic h

gives you 10 goes.• Sets up an empty string, RS.1 Selects a number betw een 1and 9 and pu ts it in T.

Loops round 9 t imes, adding acha ract er to the string, RS,

• each t ime. The character is O

Puzzlecorner

Can you cha ng e the program so that yo u get twoi kin ds of target - eithe r O (one of the Baron'sOrdinary soldiers) w hic h is worth 1 point, or S(one of his Special branch) wh ich is worth 5p o i n t s ?

forthepositioncorresponding to the numberin T and a dot for all the others.

• Prints the string.

Loops round a number of> times to see if you a repressing a ke y. (End ofloop atUne 140)

' Chec ks ifyou are pressingthe right ke y. Jumps to 170 ifso.

Prints ifyou press ed the- wrong key or didn't pre ss intime, thenjum ps to 190.

• Licrea ses your score by 1.

- Sends computer b ack to line

30foranothergo.• Prints your score w hen 10goes are up.

Notice how the scoring w orksin this program (Unes 20 and180). You could try add ingthis to other program s.

_ j ; :-w '

f * -: /'• ^ ^

& § &

$*Hrj C . -*^A v

~V

iM&

7\mk(,

v<*m

w >

bB-I /*«K

S 9^^9*r.

^ 1 ^ ^ 1

'l*&wmito&

530?g * ^ < T T I ^ l ! ^ " /

i X<;4/

M̂ -^mH

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 16/52

Robot Invaders

m*fYou must act qu ickly.Robot invad ers of all kindsare approaching. Youhave plenty ofweapons,but for eac h type ofRobotyou must select exactlythe right one for it to haveanyeffect.

Code symb ols for e achRobot will flash up on yourscreen. Qu ickly p ress theke y with that sym bol on it- beware, some need theshift key too - and see how

many Robot invaders youcandestroy.

10 PRI NT "ROBOT I NVAD ERS"

20 LET H =0

30 FOR T=1 TO 25

IA *4 0 FOR 1= 1 TO IN T ( R N D *30+ 20)

50 NEXT I

• • A « 6 0 LET A = IN T < RN D * 20 )• • A « 7 0 L ET D = IN T <R N D *1 5 >

| s * B A # 8 0 LET P * = C H R * ( I N T ( R N D * 5 3 + 1 1 ) ) .

A »90 C LS

:}}

100 FOR J =0 TO D110 PRINT120 NEXT J

130 PRINT TAB<A );P*

•• A« 14 0 FOR 1=1 TO 15^A# 150 LET R*=INKEY*

160 IF R*= P* THEN G OTO i

170 IF R»<> "" THEN GOTO180 NEXT I

190 PRINT "MISSED"200 GOTO 230210 PRINT "A HIT"

220 LET H=H+1 — — —

230 NEXT T

A*240 CLS

10

190

u

_

IP

ff1~

^ "

^

' IM Ikji

m ^^m^

CZ3

How the program works

- Sets score to zero for start.• Beginning ofloop which

givesyou25goes .

- Random delay.Selects numbers for acrossand down positions on

- screen.

•Choosesakeyboard character.-Clearsscreen

M oves cursor down thescreen, one Une at a time,

-until it reaches Une number O(which wa s chosen in Une 70).

- M oves cursor A spaces

across the screen and printsthe character cho sen in Une80there.

-Check s keyboard a numberoftimes to see ifyou arepressing a key, checks ifthisis the right key and thenjumps to the appropriate Uneto print hit or miss.

- bicreas es score by 1.

- Goes back for another turn.

250 PRINT "YOU SCORED ";H;"/25"-

260 STOP•Prints score after 25 goes.

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 17/52

u• • • •

CZD

<r- - -X

LLie ab ove usting wiU work on a ZX81. For

other computers, mak e the ch ang es below.• ± • 4 0 FOR 1 = 1 TO I N T < R N D < T > * 3 0 0 + 2 0 0 )

• 4 0 FOR 1 = 1 TO I N T ( R N D < 0 ) * 3 0 0 + 2 0 0 )• • • 6 0 , 7 0 c h a ng e RND t o RND<1>

•60,70 change RND to RND(0)*A»80 LET P*=CHR*<INT<RND<l>*58+33>>

•SO LET P*=CHR*<INT<RND<0)*58+33))

s BO LET P*=CHR* (I NT (RND * 58+33) )•90,240 HOMEA 9 0 , 2 4 0 P R I N T C H R * ( 1 4 7 )

• • A » 1 4 0 FOR 1 = 1 TO 1 50•145 R*=""•150 R*=INKEY*<1)

A150 GET R*•150 IF PEEK(-16384)>127 THEN BET R*

Speeding upthe game

As you get used to playing thisgame, you wiU probably findyou want to speed it up. Do thisby changing the last number intine 140 to a lower one.

MovingthecursorYour computer may ha ve asimpler wa y ofmo ving thecursor to a particular point onthe scr een (see tines 100-130).Check your manual and s e e .

" >XTPuzzlecorner

These arethe mostdangerous ofthe robots. f JL W X-

* • T ¥V

Mechans Tintroids

W X YScrapions Wireheads Steeleyes

Can you adjust the program so that you get 100 points for each ofthese andonly 10 points for any o fthe others?

Y>*^

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 18/52

SecretWeaponIfyou could destroy th e main Robot Spare Parts Store, which liesunderground somewhere in the eastern wastes ofthe U.R.S., you couldcripple the robot attack quite severely.

You have a new secret weapon, as yet unknown to the robots, whichcan cut silently through soUdrock, vapourizing everything in its path.

The Store is very cleverly concealed though. All you can do is aimyour weapon bUndlyand hope you get somewhere near the target.Your computer will ask y ou for a difficulty number (the

smaUest number aUowed is 4) and then ask for yourguesses for the X and Y coordinates ofthe target. (Enterthese separately, pressing RETURN, NEWLINE orENTER after each one.)

Foracluetothepossible ^^y*>- <t&SvaluesofXandY,look ^ * >carefully at the program _^,^Zy^SM

tisting.

16

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 19/52

*N \. r

N * ~~_

A«10 CLS20 PRINT "SECRET WEAPON"30 PRINT "ENTER DIFFICULTY40 INPUT D

50 IF D<4 THEN SOTO 30

Ho wth e program works

Gets a difficulty number fromyou, puts it in D and checks it

- isnotlessthan4.

• ••A»60 LET X=INT<RND*D+A«70 LET Y=INT(RND*D+

80 FOR 6=1 TO D+5 —«} •Selects numbers for X and Y.

90 PRINT "GUESSES FOR100 INPUT XI110 INPUT Y1

X AND Y "

- Beginning of loop whichgives you a number ofgoesdepending on the difficultyyou chose.

- Gets your gue sses ahd putstheminXlandYl .

1 2 0 L E T Z = S Q R ( ( X - X l ) * ( X - X l ) + < Y - Y l ) * ( Y - Y l > ) •Worksoutthedistance between

your shot and the target and putstheanswerinZ.

—i ChecksZtoseehowclose1 3 0 I F Z = 0 T H E N G OTO 2 0 0 youwereandprintsa1 4 0 I F Z < = 3 TH E N P R I N T " C L O S E " U-message.( I fZ = Oyou've1 5 0 I F Z > 3 T H EN P R I N T " N O T E VE N C L O S E ^ won.)

160 NEXT G Endofloop. Goes back fornexttum.

170 PRINT180 PRINT

190 STOP

"THE ROBOTS HAVE SEEN"YOU - A6GHHHHH

-Prints when you've used aUyourgoes.

200 PRINT "YOU DESTROYED210 PRINT G;" GOES"

220 STOP

The abo ve Hsting wiH work on a ZX81. Forother computers , ma ke the chan ges be low .

•10 HOMEA10 PRINT CHR*(147)

*A*60 LET X=INT(RND(1)*D+1)•60 LET X=INT(RND(0)*D+1)

*A#70 LET Y=INT(RND<1)*D+1)•70 LET Y=INT(RND(0)*D+1)

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 20/52

Escape!The Robots ha ve caught you, taken your weapons a ndlocked youup.Suddenly you remember you stiU h ave your sonar wristwatch, wh ich ca n betuned to produce sounds ofan y frequency. Ifyou can only find the resonantfrequency ofyo ur Robot guards, they should vibrate so m uch they faUapart.

You must be careful not to use frequencies that are too low or the building

wiU vibrate and coU apse on top ofyou. Ifyou go too high, you wUl get su ch aterrible heada che you wiU have to give up.Can yo u esc ap e the horrors ofthe Robot prison? (Look carefuUy at th e

program for a clue to the range offreq uen cies to try.)

• • 1 02 0

• • A » 3 0

4 0

5 0

CLSP R I N T " E S C A P E "LET F=INT<RND*lO0+l)

#

LET

LET

H }60 FOR G=1 TO 5

7080

PRINTINPUT

"SUESS'F1 '}

90 IF ABS(F-Fl)<5 THEN BOTO 290-

100 IF F-Fl>40 THEN BOTO 170'

110 IF Fl-F>40 THEN BOTO 230'

120 PRINT "NO VISIBLE EFFECT"130 NEXT B140 PRINT "YOU TOOK TOO LONB."150 PRINT "THE FREQ. WAS ";F160 STOP

170 IF L=2 THEN 60T0 210180 PRINT "TOO LOW...CAREFUL"190 LET L=2200 BOTO 130210 PRINT "THE BUILDING COLLAPSED"220 STOP

230 IF H=2 THEN BOTO 270240 PRINT "TOO HIBH...OUCH"250 LET H=2260 BOTO 130270 PRINT "YOUR HEAD ACHES - SIVE UP'280 STOP290 PRINT "YOU' VE DONE IT"300 STOP

T h e a b o v e U s t i n g w i I l w o r k o n a Z X 8 1 . F o rother com puters , m a k e t h e c h a n g e s b e l ow .

• 1 0 HOMEA l O P R IN T C H R * ( 1 4 7 )

• A » 3 0 LE T F = I N T < R N D ( 1 ) * 1 0 0 + 1 )18 " 3 0 L E T F = I N T ( R N D < 0 > * 1 0 0 + 1 >

How the program wo rks

Chooses a number betwee n 1and 100 for frequency of

-m robots and pu ts it in F.

Puts 1 in L and H. These are— used ifyou go oo ow or too

high-seeUnes 170-190and230-250.

—B eginning ofloop wh ichaUows you to ha ve 5 turns.

— Gets a gue ss from you andpU ts i t i n F l .

— Ch ecks if your g ues s iswithin 5 ofF. Ifit is , jumps to290 to prin t YOU'VE DONE IT .

—Jumps to 170 if your gu ess isso low it is less than F bymorethan40.

— Jumps to 230 ifyour gu ess isso high it is mo re than F bymorethan40

— Prints ifyour guess w aswithin 40 ofF and goes backfor nex t turn. If aU turns ha vebeen used, it prints the answer.Checks the value ofL. Thefirst time this par t oftheprogram is reached, L is 1. So

— the computermoves downthe program to print a

warning, chang e L to 2 and gobac k for ano ther turn.Next time Une 170 com es intooperation the program jumpsstraight to210toteUyouyouVelost .

< These Unes check H in thesame way to give you awa rning first time you go tooh ighandte l lyouyou 've los tthesecondt ime.

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 21/52

Puzzle corner

The three Robot guardseach have their ow nresonant frequency. Youcan't escape until youhave found aU three. Howcould you change the

\ programtodothis?

i

Howtomakethegameharder

Change th e 5 in Une 90 to alower number. This meansyou have to get closer to Fto win. You can alsoincrease the possiblerange ofF by changing

100 in Une 30 to a highernumber.

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 22/52

PirateDogfightIt's you a gainst the Sky Pirate. He moves ahead, you accelera te-H edrops behind, you slow down. You must try to get level with him andthenyou can fire, hoping that he won't be ab le to fire and hit youfirst.

Use the letter key s A to accelerate, D to decelerate and F to fire. Yourcomputer w ill tell you your sp eed and position relative to the pirate. You

will need to be ready to press the appropriate key s as soon as y oup ressRUN. Keep press ing A and D until you get lev el and thenfire.

• • 1 0 CLS*

How the program works

20 PRINT "PIRATE DOBFISHT"••••30 LET V=INT(RND*ll-5>

••••40 LET S=-INT<RND*3+1>

50 IF ABS(S)>20 THEN GOTO 2 3 0 -••60 CLS

70 PRINT "YOU ARE ";80 IF S<0 THEN PRINT "BEHIND"90 IF S>0 THEN PRINT "AHEAD"100 IF S=0 THEN PRINT "LEVEL"110 PRINT "YOU ARE BOING ";120 IF V>0 THEN PRINT "FASTER"130 IF V<0 THEN PRINT "SLOWER"140 IF V=0 THEN PRINT "SAME"

• ^

•••15 0 LET I*=INKEY*

160 IF I*="A" THEN LET V=V+1

170 IFI*="D"

THEN LET V=V-1180 IF I*="F" AND S=0 THEN SOTO

Chooses a number between

—5 and +5 for your speedrelativetopirateandputsitinV.

Chooses a number for yourdistance from the pirate

• andputsitinS.Thisisnegative at the start,which m eans youarebehind him.

• Checks ifthe d istancebetween you is more than 20.Ifso, computerjumps to 230to say you've lost sight ofhim.

^^ i f l i

j

20

^ ^ — C h e ck st he va lu es ofS a nd Vand prints your position andspeed in relation to the pirate.

Looks to see ifyou arepressing a key and, ifso,which one. Ifit is A, yourspeed is increased by 1. IfD,your speed is decreased by 1.

r~~ i fyouarepress ingFandS=0'5 0 I (i.e.you'relevel)thenit

—I jumpsto250.(IfSisnot0when you press F thennothing happens.)

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 23/52

190 LET S=S+V

'}•A«200 FOR 1=1 TO 20

210 NEXT I

220 GOTO 50 — — — — — — —230 PRINT "YOU LOST SIBHT OF HIM"

240 GOTO 330250 IF ABS<V><2 THEN GOTO 290

• • A *

260270280

90

PRINT "YOU ONLY MANAGED TOPRINT "SCARE HIM."GOTO 40

IF RND>.7 THEN GOTO 320'

"YOU SHOT HIM DOWN"530"HE SHOT FIRST"

300 PRINT310 GOTO ;320 PRINT3 3 0 STOP

The abo ve ttsting wil l work on a ZX81. Forother computers , m ake the cha ng es be low.

• 1 4 5• 1 0 , 6 0 HOME * 1 5 0A 1 0 , 6 0 PR IN T C H R*<1 47 > « 1 5 0

* A » 3 0 LET V = I N T ( R N D ( l ) * l l - 5 ) A 1 50• 3 0 LET V = I N T < R N D < 0 > * l l- 5 > * B A # 2 0 0

* A # 4 0 LET S = - I N T < R N D U > * 3 + 1 ) B 2 9 0• 4 0 LE T S = -I N T< R N D < 0> * 3+ 1 > * A * 2 9 0

Works out the new distancebetweenyou.

Delayloop.

Goes back to 50 to repeat.

Comes into operation ifyoufired when leve l. Checksspeed is less than 2 (ignoring+ and — signs) and ifso,jumpsto290.

Prints a message if speed w asmore than 2 whe n you fired.Returns to 40 to start againwith a n ew v alue for S.

AppUes a random test to seeifyou fired before the pira te.

Pr in tsamessagedependingon the res ult of the test in 290.

i*="-

I*=INKEY*<1>

IF PEEK(-16384)>127 THEN GET 1»6ET I*FOR 1 = 1 TO 200IF RND<0)>.7 THEN 60T0 320IF RND(l)>.7 THEN GOTO 320

P

How to m ake the ga me easier

You m ay find this ga m e quite difficult.To ma ke it s l ightly ea sier, add these t woUnes . You wiU then be able to se e there lative pos it ions of the tw o pla nesprinted on the scre en.195 IF ABS<S)>10 THEN GOTO 200196 PRINT TAB(w/2);"HIM"

197 PRINT TAB<S+w/2>;"YOU"

Replace w with the width ofyour screen .

Puzz lecorner

The random tes t in line 290 is loade d inyour favour. How could yo u chan ge it soyour cha nce s ofwinning are equal?

21

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 24/52

SupersonicBomber

You are on a lone supersonic bombingmission over the U.R.S. Your computershows graphs ofRobot population basedon infrared photographs relayed to it by

sateUite. You only have time to attackone target in five, so yo u must quicklyselect the one with th e highestpopulation ofRobots and release one ofyour "Corrodarobe" bombs on it. (Thesecontain a substance so corrosive it candissolve a Robot's body in seconds.)

To release a bomb, press th e numberkey which corresponds to the numbernext to the graph ofhighest Robotpopulation. Ifthere are two the same,choose the one with the lowest number.

WiU you be a hero when you return tobase?

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 25/52

••10 CLS

20 PRINT "SL

30 DIM B(5

40 LET S=0

50 FOR G=10 TO 1 STEP -1

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 CLS120 FOR 1=1 TO 5130 PRINT I;140 FOR J=1 TO B(I)150 PRINT "**";160 NEXT J170 PRINT180 NEXT I

••••190 FOR 1=1 TO G*3•T5200 LET I*=INKEY*

210 IF I*<>"" THEN GOTO 270

220 NEXT I230 PRINT "TOO LATE"••••240 FOR J=1 TO 10

250 NEXT J260 GOTO 280270 IF VAL(I*>=M THEN LET S=S+1

280 NEXT G290 PRINT "YOU HIT ";S;300 PRINT "HIGH DENSITY3 1 0 I F S=10 THEN PRINT320 IF S<10 THEN PRINT330 STOP

The above UstuigwiUwork.onaZX81. Forother computers, make the changes below,

• 1 0 , 1 1 0 H O M E• 1 0 , 1 1 0 P R I N T C H R * < 1 4 7 >

• • • 8 0 L ET B < I> = I N T C R N D U > *1 0 + 1 >• 8 0 L ET B < I > = I N T ( R N D < 0 > * 1 0 + 1 >

• • • • 1 9 0 FOR 1 = 1 TO 6*30

H ow the program works

This sets up B as an "arrayvariab le". It can hold fivedifferent v alu es at a time,identifying them a s B(1), B(2),B(3),B(4)andB(5).

Sets opening score at zero.

Start ofloop for 10 goes. Done

backw ards in this game (i.e.G= 10 for first go , 9 for thesecond and so on). ThisaUows the d elay loop in Une190 to give you mo re time fortheearUergoes .

Sets num ber of highestpopulation grap h at 1 to startwith.

Chooses 5 numb ers and putsthem in the arra y B(1) to B(5).Checks which is biggest an dchan ges M to correspondwithi t .

• Prints the S num bers on thescre en in the form ofrow s ofstars.

Checks ifyou are pressing akey and g oes to 270 ifyou are .

Ifyou didn't pres s in time,prints TOO LATE and goes

< bac k for next go.

Checksif the key youpressed was correct and, if

• so , increases your score by 1.

' Goesbackforanothergo." O UT O F 1 0 "

TARGETS""YOU'RE A HERO'"TOUGH - YOU FAILE1h

rints score after10 goes.

• 1 9 5 I * = " "• 2 0 0 I *= INKEY*U>

• 2 0 0 S E T I *• 2 0 0 I F P E E K < - 1 6 3 8 4 ) > 1 2 7 THEN BET I *

• • • • 2 4 0 FOR J = 1 TO 4 0 0

Changing the speed ofthe gam e

To g ive you rse l f more c h an c e ofpress ing a key ea ch t ime, cha ng e the

last numb er in Une 190 to a high er on e.A s your sk iU impro ves , k eep

low ering the number in Une 190. H owlow ca n you go and stiU win?

Puzzlecorner

Can you work out how to mak e th ecomputer g ive y ou more than 5 targetsto cho ose from e a c h t i m e ?

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 26/52

IcebergYour huU is badIy dam aged andyou've no weapon s to spea k of. Asyou timp slow ly home throughtreacherous iceberg-strew n waters,you become aw are that an enemy

ship is taUing you. Strangely it candetect you but not the iceb erg s, soyour best chance is to lure it intohittingone.

Your computer wiU print a gridshow ing the position ofyour ship(Y), the enemy (Z) and the iceb ergs(*). You can move one spa ce North,South, East or West ea ch go. Theenemy m oves towards you by themost direct route (it can movediagonaUy too). Ifyou mov e into anyofthe 8 positions surrounding theenemy , you wUl be captured, and ifyou hit an iceberg you wUl sink.

Can you escape ?

*QU^Q*'J

10 PRINT "ICEBERG'20 DIM B(8,B) i i —

* B A » 3 0 LET N=INT<RND*8+4>

4 0 FOR 1 =1 TO N| s * B A B 5 0 LET B < I N T < R N D * 8 + l > , IN T < R N D * B + l > ) = 2 3

60 NEXT I

+ B A B 7 0 L E T S X = I N T ( R N D * 8 + 1 >+ • ± • 8 0 L E T S Y= INT< R ND*B+ 1 >

9 0 I F 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

* B A # 1 1 0 LET Y X = IN T (R N D *8 + 1>+ • ± • 1 2 0 L E T Y Y = I N T ( R N D * 8 + 1 )

1 3 0 IF B ( Y X , Y Y ) 0 0 THEN 6 0 T 0 1 1 0| s * B A B 1 4 0 L E T B < Y X , Y Y > = 6 2

A B 1 5 0 C L S160 FOR Y=1 TO 8170 FOR X=1 TO 81 8 0 I F B < X , Y ) = 0 TH EN BOTO 2 1 01 90 P RIN T C H R * ( B ( X , Y ) ) ;200 BOTO 220

2 1 0 P RIN T " . " ;2 2 0 P R I N T " " ;230 NEXT X2 4 0 P R I N T250 NEXT Y

How the program worksThis sets up the grid. B is an

• "array"withtheDIMensions

8by8.• N is the number oficebergs.Itvaries from 4 to 11depending on the value ofRND.

23 on ZX81 and 42 on theother computers is the codefor *. Computer loops round Ntimes putting * into randompositions in the grid.

This puts the enem y ship on• the grid for the start ofthegame. 63 (ZX81) and 90(others) are the cod es for Z.Checks the position has notah-eady been g iven to an icebergand finds anotherifit has.

• These Unes do the same asabove to put you on the grid.(62 and 89 are the cod es forY.)

* Prints out grid with current

positions ofship s andicebergs.

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 27/52

Puzzlecorner

Can you work out how to m ake the gridbigger?

No w work out how to add morei ce be r g s t o o .

• M X ~ H

260 LET B<YX,YY)=0'

270 PRINT "DIRECTION (N,S,E,W)280 INPUT D* if

(29

S32

290 LET YY=YY+<D*="S" AND YY<>8)300 LET YY=YY-(D*="N" AND YY<>1)

0 LET YX=YX+(D*="E" AND YX<>8)320 LET YX=YX-(D*="W" AND YX<>1)

Js**A#330 IF B(YX,YY)=63 THEN BOTO 500|a*lA*340 IF B<YX,YY>=23 THEN GOTO 600 1°I

| s * B A # 3 5 0 LET B(YX ,YY) =360 LET B(SX,SY

)=62T>=0 J"

370 LET SX=SX+SBN(YX-SX)380 LET SY=SY+SGN<YY-SY):}

|s**A»390 IF B<SX,SY>=62 THEN BOTO 500|s*>A*400 IF B<SX,SY>=23 THEN BOTO 700> }ls*BA*410 LET B<SX,SY)=63

420 SOTO 150 . i - - - i i - - i i - i i - i

500 PRINT "YOU'VE BEEN CAUBHT"510 BOTO 800600 PRINT. "YOU'VE HIT AN ICEBER6"610 BOTO 800700 PRINT "YOU'RE SAFE - HE'S HIT800 STOP

The abo ve tisting wiU work o n a ZX81. Forother computers , ma ke the chan ges be low.*A*30,50,70,80,110,120 change RND to

•30,50,70,80,110,120 change RND tortA#50,340,400 change 23 to 42»••100,330,410 change 63 to 90^ ••1 40, 350 ,39 0 change 62 to 89

• 150 PRINT CHR*(147);

• 150 HOMELET YY=YY-<D*="S" AND YY<>8)LET YY=YY+(D*="N" AND YY<>1>LET YX=YX-<D*="E" AND YX<>8>LET YX=YX+(D*="W" AND YX<>1)

ONE"

• Clears your current position

from the grid so you canspecify a new one.

• Puts your direction in DS.

Calculates your newposition, checking that you

• don't go over the ed ge of thegrid.

Check s your new position tosee ifyou have bumped into

• the enemy ship or an iceberg.Ifyouhave, itjumpsdowntheprogram to tell you.

You've m oved to a safe. position and the code for yourshipisputthere.

• Calculates the enemy's newposition.

Checks enemy's new position• to see ifhe has caught you orhit an iceberg. Jumps downprogram to teIl you if he has.

• Enemy's code is put in thenewposition.

• End of a turn. Loops back to

ISO to start another turn.

Computers can decidewhether an expression is true'or false. Ifthe an swer is falsethey give it the valu e 0. Ifitistrue,somecomputersgive

RND(i> / the va lue +l ,o th ers - l .Lines 290-320 have to bechangedforsomecomputers ]

.becau se ofthis.

* • • {

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 28/52

TheWizard'sWall

The waU the W izard built to surround his secret stronghold is no ordinarywaU. The ston es in it are p eople, petrified by th e W izard's angry stare, and,what's more, it can m ove. Ifyou can break a hole through it with yourtrustycatapults which fling g igantic boulders, you wiU destroy the Wizard'smagic pow ers and turn the stones back into peop le again. There areproblems though - the Wizard is working on a speU w hich stops missiles inmid-air and sen ds them back w here they cam e from. Sometimes he canmake it w o r k . . .

Ifyou don't succeed , yo u wiU beco m e just another stone in the Wizard'sWaU!!!!

A«io CLS20 PRINT "WIZARD'S WALL"30 PRINT40 PRINT "DO YOU WANT ANY HELP?"50 INPUT I*

••A»60 IF I*<l>="Y" THEN GOSUB 74070 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 8130 FOR X=1 TO 4

**A#l40 LET W<X,Y>=20150 NEXT X160 NEXT Y170 LET Z=0180 FOR C=1 TO 3190 LET D=INT(RND*80+21)

200 GOSUB 430210 IF Z=1 THEN GOTO 1150220 PRINT "YOU ARE ";D5" YARDS AWAY"

*"A#230 LET W=INT(RND*41)-20240 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 A290 PRINT "GIVE SPEED"

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 29/52

300310

320330340350360

*"A«370380390400410420

*BA*430440

±•450

460470480

*BA*490500510520

530540550560

*"A#570

*BA*580

590600

••A»610

620630640650660670680690700710

NEAR'

FAR"

INPUT VLET A=A/lSO*3.1416

LET H=TAN<A>*<D-W)-<5*< D-W)^ 2>/<V*C0S(A> >

A

2LET H=INT<H/Q)IF H>0 AND H<9 THEN GOSUB 540IF H<1 THEN PR INT "SHOT WAS TOOIF H > 8 THEN PRI NT "SHOT WAS TOOIF RND >.2 THEN GOTO 20 0PRINT "THE WALL HAS MOVED..."NEXT CPRINT "YOU HAVE BEEN TURNED"PRINT "INTO STONE"STOPFOR 1=1 TO 30NEXT ICLSPRINTFOR Y=8FOR X=1

TOTO

18

STEP -1

PRINT CHR*<W<X,Y)>;NEXT XPRINTNEXT Y

RETURNGOSUB 650LET W(E<H>-1,H)=0IF V*CO S(A) >50 THEN LET W(E(H> -2,H) =0I F R N D > . 5 AND H < > 1 TH EN L E T W < E ( l ) , l ) = 2 9IF RND>.5 AND H>5 AND H<8 THEN LET

W(E(H+1)-1,H+1>=0IF H>1 THEN GOT O 6 30FOR Y=2 TO 8IF RND<. 5 THEN LET W<E<Y> -1,Y> =0

NEXT YGOSUB 650RETURNFOR Y=1 TO 8LE T X=1 'IF W(X,Y)=0 OR X=8 THEN GOTO 700LET X=X+1GOTO 670LET E(Y)=XIF X=1 THEN LET Z=1

• • • • • ' •

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 30/52

TheWizard's720 NEXT Y730 RETURN

740 PRINT750 PRINT760 PRINT770 PRINT780 PRINT790 PRINT800 PRINT810 PRINT820 PRINT830 PRINT840 PRINT

850 PRINT860 PRINT870 PRINT880 PRINT890 PRINT900 PRINT910 PRINT920 GOSUB930 PRINT940 PRINT

950 PRINT960 PRINT970 PRINT980 PRINT990 PRINT1000 PRINT1010 PRINT1020 PRINT1030 PRINT1040 PRINT

1050 PRINT1060 PRINT1070 PRINT1080 PRINT1090 GOSUB

Wallcontinued

"YOU ARE ATTACKING THE""LAST STRONGHOLD OF THE""NOTORIOUS WIZARD, WHO""IS HIDDEN BEHIND AN""ENDLESS STONE WALL,""EACH STONE BEING ONE""OF HIS FORMER VICTIMS.""ONLY YOU CAN ATTACK,""AND FREE THEM FROM""HIS MAGIC.""YOU MUST DESTROY THE""WALL USING CATAPULTS,""BUT BEWARE, THE WIZARD""HAS THE POWER TO MOVE""THE WALL BACK AND""FORTH, AND OCCASIONALLY,""TO DEFLECT YOUR SHOTS""BACK AT YOU."1110

"AFTER EACH SHOT, YOU ARE""SHOWN A CROSS-SECTION"

"OF THE WALL, SHOWING""HOW MUCH DAMAGE THERE""IS. ""NOTE THERE ARE CERTAIN""KEY STONES THAT PRODUCE""LOTS OF DAMAGE, AND""ALSO, THE FASTER THE""BOULDER IS MOVING""HORIZONTALLY, THE MORE""DAMAGE IT WILL CAUSE."

"CAN YOU DEFEAT THE""WIZARD IN TIME TO SAVE""THE THOUSANDS OF TRAPPED"

"SOULS "1110

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 31/52

llOO RETURN

lllO PRINT "PRESS A KEY ";

1120 IF INK EY*= "" THEN GOTO 11201130 CLS1140 RETURN

1150 PRINT "YOU MANAGE D TO BRE AK"

1160 PRIN T "A HOLE IN THE WIZ ARD ' S"

1170 PRINT "WALL - YOU HAVE B EATEN"

1180 PRI NT "HIS MAGIC PO WE RS, AND"

1190 PRINT "FREED HIS VICT IMS ."

1200 STOP

The above listing will work on a ZX81. Forother computers, make the c han ges b elow.

all RND to RND(0)

all RND to RND(1)

10,450,1130 HOME

10,450,1130 PRINT CHR*(147);

60 IF LEFT*< I*,l)= "Y" THEN GOSUB 740

140 LET W(X,Y)= 29

43 0 FOR 1=1 TO 2 00

43 0 FOR 1=1 TO 1000

490 PRINT CHR*(W(X,Y)+32);

1120 I*=GET*

1120 GET I*

112 0 GE T I* : IF I*="" THEN GOTO 1120

Changes you can m ake to the gam e

You can m ake the wall thicker by changing the following lines:Line 100: change the first number to a higher one, say , 10.Line 130: subtract 4 from the number you u sed in line 100 and put theanswer at the end ofline 120. (i.e. in this ca se use 6.)Line 480: chan ge the last number to the number you used in line 100(10again in this case).Ifyou make the wa ll much thicker, you w ill probably need m ore time.

Change the last number in line 180 to a higher number to do this.

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 32/52

Missile!This ga m e is different from tneothers in this book b eca us e i t us esgraph ics. A s the comp uters vary somu ch in the w a y their graph icswork, there is a sepa rate -rog ramfor eac h one . Read the infru ct ion son this pa ge for ho w to pla y the

|

gam e and then look through thepa ge s that follow for the vers ion for

1 yourcomputer .

Ho w to play Missi le!

You ha ve three mis si le bas es, eacicapable of launchin g one miss i l e .When you see a p lane approaching,you must judge i ts height and sp eedand fire your m iss i les at it one byone.

Your m issi les are laun ched bypre ssin g any ke y. The first t ime y oupress laun ch es the left -hand on e,seco nd t ime the middle one andthird time the right-hand on e.

See how man y ene m y p lanes youcan shoot down.

Miss i le! : TRS -80 version

lO CLS 32 0 I

20 DIM Y(3),F (3) 400 I

30 N=1 41 0 :

40 PS=INT(RNDfO)*3+l) 420

50 P=INT<RND<0)*36+5> 430

60 GOSUB 400 440 I

70 FOR I=PS TO lOO ST EP PS

I SO GOSU B 30 0| 90 F*=INKEY$

lOO IF F*="" OR N>3 THEN 130

110 F(N>=1

120 N=N+1

130 FOR J = 1 TO .̂

140 RESET(32*J,46-Y(J)>

150 IF F(J )=O OR Y(J >>4 5 THEN 190

I 160 Y(J)=Y(J)+1

170 IF POINT(32*J ,46-Y(J )) THEN 230

180 SET (32*J ,46-Y(J ))190 NEXT

200 NEXT

( 210 PRINT @0,"MISSED"

| 220 END

| 2 3 0 P RI NT @ 0 , " H I T ! M "

! 240 END

30 0 RES ET (I-PS,P) : RESE T (I-PS+1,

31 0 SE T (I,P) : SET (I+l,P)

320 RETURN

40 0 FOR J=1 TO 3

410 SET (J *32,47)

420 SET (J *32+l,47)

430 NEXT

440 RETURN

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 33/52

M i s s i l e ! : BBC version

10 MODE 5

20 VDU 23,224,224,160,144,144,143,128,128,255

30 VDU 23,225,0,0,0,0,240,12,2,255

40 VDU 23,226,16,56,84,16,16,16,0,050 VDU 23,227,0,0,0,8,8,8,8.60

60 DIM Y<3),F(3)

70 N=l:MS=16

80 PS=RND(20)+10

90 P=RND<500)+400

100 PROCDISPLAY

110 FOR I=PS TO llOO STEP PS

120 PROCPLANE<I-PS,P,O) : PR0CPLANE(I,P,3)

130 F*=INKEY*<O>

140 IF F*="" OR N>3 THEN 170

150 F(N>=TRUE

160 N=N+1

170 FOR J=1 TO 3

ISO IF NOT F(J) THEN 240

190 PROCMISSILE(J,0)

200 Y<J)=Y(J>+MS

210 IF Y<J)<1024 THEN PROCMISSILE(J,3)

220 X=J*320-I : Y=Y<J)+32-P

230 IF X<128 AND X>-40 AND Y>-32 AND Y<2 THEN

240 NEXT

250 NEXT

260 CLS s PRINT "MISSED!!!!"

270 END

280 PROCPLANE(I,P,l> : SOUND 0,-15,5,20

290 END

300 DEF PROCPLANE(X,Y,C>

310 GCOL O,C

320 MOVE X,Y

330 VDU 5,224,225,4

340 ENDPROC

350 DEF PROCMISSILE(N,C)360 GCOL O,C

370 MOVE 320*N,32+Y(N>

380 VDU 5,226,4

390 ENDPROC

400 DEF PROCDISPLAY

410 FOR 1=1 TO 3

420 MOVE 1*320,32

430 VDU 5,227,8,226,4

440 NEXT

450 ENDPROC |

31

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 34/52

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 35/52

M issi le! : VIC20 vers ion

10 PRINT CHR*<147>CHR *(5>;

20 POKE 3 6879,8

60 DIM Y(3>,F(3>

70 N=l:MS=290 P=INT<RND(l>*9+2>*2

llO FOR 1=1 TO 21 STEP RND< l)/ 2+-5120 GOSUB 30 0

130 GE T F *

140 IF F*="" OR N>3 THEN 170

150 F(N)=-1

160 N=N+1

FOR J=1 TO 3IF F(J )=O THEN 22 0

POKE 8164+J*5-Y<J>*22,32

IF Y<J )=22 THEN 24 0Y(J)=Y<J)+1

POKE 8164+J*5-Y(J)*22,30IF ABS(I-J *5)<=1 AN D P=Y(J ) THEN 28 0

NEXT

NEXT

PRINT CHR * <147);"MISSED! ! ! i"

END

P R I N T C H R * ( 1 4 7 > ; " H I T ! H ! "POKE 36877, 220 : POKE 36878,15

FOR K=1 TO 50 0 : NEX T

POKE 36877,0 : POKE 36878 ,0END

POKE 8163+I-P*22,32

POKE 8164+I-P*22,121

RETURN

Special not e for Spectr um user s:

The convention used for showing gr aphics

cha r act er s in a PRI NT s tate ment ;i5 as folThe character C mean s pr ess the GRAPHICS

key onc e. Then type the following letter

ke ys (shifted for the ZX81). Press the

GRA PHI CS key again when D is shown.

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 36/52

M issi le ! : Ap ple vers ion

10 HOME

20 HGR

30 HCOLOR=3

40 DIM Y(3) ,F(3)50 N=1 : MS =5

60 PB=INT(RND(1)*6+4)

70 P=INT<RND(1>*135+11>

BO GOSUB 400

90 FOR I=PS TO 265 STEP PS

100 X=I- PS : Y=15 9-P : C= 0 : GOS UB 30 0

110 X=I : C= 3 : GOS UB 30 0

120 F*="" : IF PEE K<- 16 384 >>1 27 THEN GET F$

130 IF F*="" OR N> 3 THEN 160

140 F(N)=1

150 N=N+1

160 FOR J =1 TO 3

170 C=0 : GOSUB 350

180 IF F(J )=0 OR YCJ )>145 THEN ^r >

190 Y(J)=Y(J)+MS

200 C=3 : GOSUB 350

210 X=J*70-I : Y=P-Y(J )

220 IF X>-1 AND X<15 AND Y>-9 AND Y<5 THEN 270

230 NEXT

240 NEXT

250 VTAB 22 : PRINT "MISSED"

260 END

270 VTAB 22 : PRINT "HIT!!!"

280 END

300 HCOLOR=C

31 0 HPL OT X,Y TO X,Y-8

320 HPLO T TO X+3,Y-2 : HPLO T TO X+12 ,Y-2

33 0 HPL OT TO X+14,Y : HPL OT TO X,Y

340 RETURN

350 HCOLO R=C o

360 HPLOT 70*J,158-Y(J ) TO 70*J ,154-Y(J)370 RETURN

400 FOR J =1 TO 3

410 HPLOT 70*J -5,1 59 TO 70 .

420 NEXT

430 RETURN

PRINT "HIT!!

—-

34

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 37/52

M issi le! : ZX81 vers ion

10 CLS

20 DIM Y (3)

30 DIM F(3)

40 LET N=150 LET P=INT<RND*19+2)*2 r

60 FOR 1=1 TO 48

70 PL OT I,P80 PLOT I+l,P

90 UN PLO T I-l,P

100 LET B$=INK EY$

110 IF B*= "" OR N> 3 THE N GOT O 140

120 LET F(N)=1

130 LET N=N+1

140 FOR J =1 TO 3

150 IF F(J )=0 THEN GOTO 190

160 UNPLOT J *16,Y(J)

170 IF Y(J )=4 2 THEN GOTO 2 10

180 LET Y(J )=Y(J )+1

190 PLOT J *16,Y(J )

200 IF P=Y (J ) AND (J*16=I OR J *16=I+1)

THEN GOTO 26 0

210 NEXT J220 NEXT I

230 CLS

240 PRINT "MISSED"

250 STOP

260 CLS

270 PRINT "H IT"

280 STOP

j| J4ifc.:-"- '-"3fcfe

35

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 38/52

Add ing to th e program sHere are some idea s for additionsyou can make to the programs inthis book or to your own programs.In most cas es you won't be able toadd these to a ZX81 with only lK as

the gam es them selv es fill almost allits memory space , but you shouldfind there is p lenty of room on theother compu ters.

Remember you will either have torestrict your additions to the spareline numbers in a program orrenumber the program. Ifyoudecide to renumber, take care youchan ge all the GOTO and GOSUB

lines too. •Ge t t ing the com puter to te l l youh o w t o p l a yYou can add asectiontoanyprogramtomakethe compu ter printinstructions tellingyou what to do. The

easiest way to dothis is to add som e lines, such as thosebelow, at the beginn ing oftheprogram and then put a sub-routine atthe end.

10 PRINT "TITLE OF GAM E"11 PRINT "DO YOU WANT TO"12 PRINT "KNOW HOW TO PLAY?"15 INPUT It

SZX17 IF I*(l)="Y" THEN GOSUB lOOO* B A # 1 7 IF LEFT*<It,l)="Y" THEN GOSUB 1000

Mak ing the com pu te rstop and w ai t for you

Ifyour instructions a re very long, you

may want to insert this sub- routinewhich stops the prog ram running at aparticular point until you pres s a key.This way you can stop the instructionsscrolling offthe top ofthe sc ree nbefore you have rea d them. Put aGOSUB line at the p lace you want theprogram to stop and then put this subroutine at the end .

1000 PRINT "PRESS A KEY TO CONT INUESZX1 010 IF INKEY*="" THEN BOTO 1010

*1010 I*=GET*

#1010 GET I*AlOlO GET I*1020 PRINT1030 RETURN

IF I*= THEN GOTO 1010

Mak ing the com pu te r " ta lk " toyou

main program go es her e1000 PRINT "WHAT YOU HAVE

1010 PRINT "DO IS '1V99 RETURN

You can ma ke the compu ter ask youquestions and react to your answ ers.For instance , her e is an addition whichwill ma ke the com puter refuse to play

with you unless your nam e beg ins with J.TO "

36

You can ad d as many print statementsas you like for the instructions, justremember to put a num ber and theword PRINT at the beginning ofeach*ione. Restrict the length of the pa rtinside the quotation m arks to the

number of cha racte rs your computercan print on one line. Don't forget toput a RETURN line at the end or theprogram won't work.

1233456

S Z X 7• A « 7

PRINT "WHAT IS YOUR NAME?"

INPUT I*IF I*(1)<>"J" THEN GOTO 1000IF LEFT*<I*,1)<> "J " THEN GOTO 1000PRINT "OK-YOU CAN PLAY."PRINT "ARE YOU READY?"

INPUT J*IF J*(1)<>"Y" THEN GOTO 5IF LEFT*(J *,1)<>"Y" THEN GOTO 5

main program here

1000 PRINT1010 PRINT1020 PRINT1030 PRINT

•SORRY THIS GAME'ONLY FOR PEOPLE"'WHOSE NAMES BEGIN•WITH J"

IS"

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 39/52

Here is another on e whe re thecom puter dare s you to b e bra veeno ug h to play.

101214

1516

S ZX17• ••17

IB19

PRINT "VERY SCAREY GAME"PRINT "ARE YOU BRAVE ENOUGH"PRINT "TO TACKLE THE GREEN"

PRINT "HAIRY MONS TER? "INPUT I*IF I*<1>="Y" THEN GOTO 20IF LEFT*(IS ,1)="Y" THEN BOTO 20PRINT "COWARD"STOP

You could com bin e this with theinstruction sub-rou tine by taking l ines11 to 17 from the instructions sectionon this pag e a nd putt ing them at l ines20 to 26 of this pro gram . You canth en

start the main pro gr am at line 30 andad d the instruction s ub-rou tine at theend.

ca se s you can a dd a single line to yourpro gra m at the plac e you want thesound. In others , you need severa llines and it is best to put th es e in as asub-rout ine .

As an exam ple, h ere is the soun d ofa shot for the BBC. You can ex per im en twith w h er e to put it in the pr og ram , butyou must give it a line nu m be r to ma keit worK:

SOUND 0 , - 1 5 , 5 , 1 0

At the b ac k of the VIC man ual ybuwill find s om e useful sub -rou tines forsoun ds such as " laser beam","explosion " and "red alert". Put a

GOSUB line w he re you w ant the sou ndto appe ar , nu m ber the sub-rout ine andad d a RETURN at the e nd ofit.

W ou ld you l ike ano ther go?

Instead of typing RUN ea ch t ime youplay a game , you can ma ke thecom pu ter ask you if you'd l ike anoth ergo . Put the se l ines at the en d ofthe

prog ram , just befo re th e last STOPstatement.

lOOO PRINT "DO YOU WANT ANOTHER GO?1010 INPUT I*

SZX1020 IF I*<l>="Y" THEN RUN*B A# 10 20 IF LEFT*(I*,l)="Y" THEN RUN

1030 PRINT "OK THEN - BYE"1040 STOP

Change linenumbers according

to your program.

Ad ding sound ef fects

The BBC, VIC 20, ZX Spectrum andsome Apples a re able to p rod ucesound s and you can ad d l ines to yourprogram s tom ak e them do so a tappro pr ia te p lace s. You could add anexp losion for instan ce, o r a little tun e

wh ich pla ys if you win. All thecomputers need different instructionsto m ak e so un ds though , so you willhave to look at your m anual. In so me

S p e c i a l n o t e f o r B B C a n d A ^ ^Spec t rumusers ^W^

If you ha ve a BBC or a ZX Spectrum

you may find that som e of the g am esin this bo ok run too fast for you. Youwill find a box n ext to th es e g am escontaining instructions forchan ging the speed . Remem ber , toslow the gam e up you a lways ne edto use a higher number. Latermo dels of the BBC may run up totwic e as fast as the earlier m od els,and this could ma ke the gam es

ap pe ar impo ssible on the first run.Be p re pa r ed to mak e b ig chang esto the sp ee d num ber to correct this.

37

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 40/52

W rit ing your o w n program sAs you work through the ga m es inthe book, yo u will prob ably findyour se l fma king m ore and morecha nges to them and even tual lywant ing to wri te new gam es o fyourown. On these tw o pa ge s you wi l lfind som e hints on how to set aboutdoingth is .

Before you start, it is a go od id ea tostop and think about what yourcom puter can and cannot do.

*It ca n ask you for information.

*It can store information*It can select nu m ber s a t ran dom byusing RND.

*It can do calculations.

*It cann ot d o anyth ing u nles s you tell itto .

*It can mak e decis ions by com paringitems of information in various w ay s.

*It ca n tell you th e res ults ofitscalculations an d decisio ns and also

38 what is stor ed in its me mo ry.

*Provided you use its langua gecorre ctly, it ca n d o only exactlywhatyou tell it, ev en if it is silly.

Rem emb er , whe n you are t rying towork out a gam e, nofto includeanything which your comp uter won'tbe ab le to do.

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 41/52

P l a n n i n g a g a m e W ri t ing the p rogram

Before you can tell the compu ter howto play your game, you must knowexactly how to play it and what therules are yourself. The com puterwillneed a ser ies of simple logicalinstructions, so work out your gam e inyour head o r on pa pe r first and thenbreak it down into simple steps .

Next write a plan (in English - don'ttry to use BASIC yet) of all the stages ofthe gam e in order.

Here is a plan for a simple shootinggam e, such as firing cannon balls at apirate ship or shooting laser b eam s at

an alien invader, to give you an idea.

~~TT~x^nrT~?nr~?rF

P L A N2 ) PRlNTTlTLEMD

INSTRUCTIONS

2 ) CHOOSE A TARCET

F O R T H l 5 G A M E

3)BECilN A LOO P TO

GIVE THE PLAYER

N COES

4-) CiET A SHOT FROM

THE PLAYEH

5) CHECK IF SNOT WAS

ON TARQEJ

6) PRINT MESSAGE

DEPENDING ON

ACCURACY OFSHOT

7) <f0 8ACK FOR

ANOTM R qo \F SHOT

WAS UNSUCCESSFUL

The next stage is to convert your planinto BASIC. Each ste p in your plan maynee d several lines in BASIC. Don'tforget to leave gaps w hen numberingyour prog ram lines so you can go backand ad d extra ones if you need to.

Do a first draft of the p rog ram onpa pe r first and then start testing on thecomputer. Your computer will spoterrors much m ore quickly than youwill see them yourself and may giveyou a clue as to what is wrong.Remember that debugg ing program sis a long, tedious p roc ess even for

expert program me rs, so don't expectto get yours right first time.

Once you have got the co re of theprogram working, you can add to it.Scoring, extra com ments, m oretargets etc. can all be incorporated

later. You could add sections from theprogram s in this book to your gam es.Don't exp ect to be able to write

exciting and original gam es straightaway. Keep your ideas very simpleand be pr ep ared to,adapt them as yougo along. You may find you haveincluded something in your gamewhich is easy for humans to do butvery difficult for a com puter. As you

get more ex per ienc ed you will beginto know instinctively what yourcom puter can do and find it eas ier towrite prog ram s for it. 39

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 42/52

SummaryofBASICThis section lists some common BASIC words and describes wh at theymake the computer do and how they are used. Most ofthem have been usedin the programs in this book, so you ca n ch eck back through the book to se ehow they w ork in a gam e. Not all the words can be u sed on allthecomputers mentioned iri this book. The conversion chart on page 46 show s

whatyoucanuse instead.

LET tells the comp uter to label a section ofitsmemory and put a particular value in it e.g. LETA =6 m eans label a section of mem ory "A" and putthe value 6 in it. "A" is called a "variable" andputtingsomething in it is called "assigning a value to avariable".

Some variab le labels are followed by a dollarsign e.g. A$. This means they are for "strings",

which can contain any num ber ofcharacters,including letters, numbers and symbols.

PRINT tells the computer to display things on thescreen and you can use it in severa l ways:

A m essa ge enclose d in quotation marks withPRINT in front of it will be displayed on the screenexactly as you typ ed it. The section inside quotesdoe s not have to be in BASIC, it can be anythingyou

like.PRINT followed by a variable label e.g. PRINT Aor PRINT A$ tells the computer to displaytheconten ts ofthat variable on the screen .

PRINT can also do calculations and then displaythe results e.g. PRINT 6*4will mak e the computerdisplay 24.

You can use PRINT by itself to leave an emptyline.

RND tells the computer to choose a number atrandom. Different com puters use different forms ofRND and you can se e what these are in theconversion chart on pag e 46. On Sinclair com pute rs

D by itselfproduces a number between 0 and99999999. You can vary the limits of the num ber it

cho ose s by multiplying RND and adding to it. E.g.RND*20 produces a number between 0 and19.99999999, while RND*20+1 producesanumber

between 1 and20.99999999.See INT for how to pro duc e only whole num bers.See CHR$ for how to produce letters and other

keyboard characters at random.

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 43/52

INT is short for integer, w hich means wholenumber. For positive num bers, it tells the computerto ignore everything to the right of the decimalpoint. E.g. INT(20.999) is 20. For negative num bers,it ignores everything to the right ofthe decimal

point and " increases" the num ber to the left of it byonee .g . INT(-3 .6 ) i s -4 .INT is often used with RND, like this:

INT(RND*20+1) which tells the computer youwantit to choose a whole number betw een 1 and 20.

CHR$ converts num bers into letters. Apart fromtheZX81, all the computers in this book use theASCII*set ofkeyboa rd cha racte rs in which eachcharacter corresponds to a certain num ber. E.g.

letter A has the code num ber 65 and PRINTCHR$(65) will display an A on the scree n.

You can use CHR$ with INT and RND to make thecomputer select random letters, like this:

CHR$(INT(RND*26+65))This line will prod uce random letters on a ZXSpectrum (see conversion chart forothercomputers).

FOR is used to start a "loop" which will m ake thecomputer rep eat p art of a program a certainnumber oftimes. It must be followed b ya va riable(such as G to stand for the number of goes allowedin a game), and the variab le must be given start andend values (such as 1 TO 10.)

The end ofthe loop is marked by a NEXT line(NEXT G in this exam ple) which inc reas es the valueofthe variable by 1 each time and then sen ds thecomputer back to the FOR line again. When thevariable rea che s its end value, the computerignores the NEXT line and car ries on to the linewhich follows it. Every FOR must have a NEXT oryouwiUgetabug.

INPUT labels a spac e in the computer's memory,prints a question mark and then waits for you totype something which it can put in this memoryspace. It will not car ry on with the rest oftheprogram until you pre ss RETURN, ENTER or

NEWLINE.You can us e num ber or string variables withINPUT, but if you use a number variable thecomputer will not accept letters from you.

*Am erican Standard Code forInformation Interchange (seepage 45)

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 44/52

INKEY$ checks the keyboard to se e if a key isbeing press ed and if so which one. It do es not waitfor you to press a key like INPUT does. It is usuallyused in a loop which ma kes the com puter go roundcheckingthe keyboard lots oftimes. This is

bec aus e com puters w ork so quickly, you wouldn'thave a chance of pres sing a key in the time it takesthe computer to do one check.

Ifyou haven't pre ssed a key before the loopfinishes, the com puter c arrie s on with a stringcontaining nothing (ca lled a "null" string).NB Apple and VIC do not use INKEY$.

GET is use d instead of INKEY$ on VIC and Pet

computers.

GOTO mak es the computer jump up or down theprogram ignoring the lines in betw een. You mustput the num ber of the line you want it to jump toafterthe GOTO instruction.

GOSUB tells the computer to leave the main

program and go to a sub -routine. GOSUB must befolowed by the number o fthe first line ofthe subroutine. At the en d of the sub -routine you must havea RETURN line. This send s the computer ba ck tothe main prog ram to the line immediately followingthe GOSUB line. A GOSUB without a RETURN in aprogram will give a bug .

I F . . . THEN tells the computer to decide ifan

expression is true or false, and do differentthingsdep endin g on the answer. It is use d with thefollowing signs, and also with AND or OR:

= t he sa me a s<lessthan>greaterthan

< = le ss than or the same as> = greater than or the sam e as< > n o t t h e s a m e a s

Ifthe computer de cides an expression is true, itcarries on to do the instruction w hich followsTHEN. Ifit d ec ides it is false, it ignores the restofthat line and goes on to the next one.

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 45/52

CLS is us ed to clear everyth ing offthe sc ree nwithout rem ovin g or chan gin g anything in them em ory . It is useful for rem ov in g the listing fromthe scre en at the beg inn ing of a RUN or in gam esw hen you want the play er to reac t to someth ingse en for a limited amoun t oftime. (NB Apple andVIC do not use CLS - s ee conversion char t) .

HOME i s us ed by App le comp uters instead ofCLSto c lear the scre en.

ABS ign ores p lus and minus sign s in front of

nu mb ers an d tak es the i r "absolute" va lues. E.g.ABS( -1 0) is 10 an d ABS( +1 0) is also 10.

VAL tak es the num eric value of nu m ber s writ ten asstrin gs . In effect, it tel ls the com pu ter to ign ore thedollar sign and treat the str ing as an ordina rynum berva r iable . E .g . i fI$="60" thenVA L(I$) is then u m b e r 60.

ASC con verts a char acte r into i ts ASCII co denu m be re .g . ASC("3") gives 51 . The express ioninbr ack ets must be a str ing e.g. ASC(A$) orASC("20").NB ZX81 and ZX Spectrum d o not use ASC, thoughthe Spectrum d oe s use the ASCII co de .

CODE i s us ed b y ZX81 and S pectrum in place ofASC. Like ASC it must alway s be followed b y astr ing. Re m em be r that the ZX81 uses different codenu mb ers from the other comp uters .

TAB mo ves the cursor a cross the scre en to aspecif ied column nu m ber. It is usually us ed withPRINT to display som ething in the m iddle ofthe

screen . The num ber of sp ace s you want the cursormo ved is put in br ac ke ts after TAB. The maximumnumb er you can use dep en ds on the sc reen widthof your co mp uter .

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 46/52

SGN tells the c om pu ter to find out the sign ofanum ber. It pr od uc es - 1 for a negat ive num ber , 0for zero an d + 1 for positive num be rs. E.g.S G N ( - 3 0 ) i s - 1 , SGN (7)is + 1 andSG N(0) isO.

DIM te ll s the com pute r how much me mo ry sp ac ewill b e n e e d e d for an "array" (a row or a grid). E.g.DIM X(6) tel ls the com pu ter to set aside an a realarge en ou gh to contain a row of 6 e lements andlabelled X. DIM A(8,8) me ans a mem ory sp ac elabel led A and b ig enoug h to tak e 8 e lementsacross and 8 down i s ne ede d . The num ber ofelemen ts of data used in the pro gra m mustcor resp on d to the num ber s in bra ck ets after DIMor you will get a bu g.

SQ Rt ake s squ are roots ofnum bers . E.g . SQR(16)gives the ans w er 4 .

SIN calculate s the sine of an ang le. In a right-ang ledtr iangle the length of the s ide opposi te ana ngle ,divided by the length of the H ypote neuse ( the s ideopp osite the right ang le) is the sine ofth atan gle.W hen you use SIN in a prog ram , the angle you a reusing it with must b e m eas ure d in radians , notd e g r e e s .

ATN is one of the t rig , functions w hich com put erscan c alculate ( see also SIN abo ve) . It stan ds forarctangen t an d it is important to re m em be r that itgives an answ er in radians , not de gr ee s . Youwil lne ed to use a ma ths boo k to find out how this w ork sifyou d o not alre ad y kno w abo ut it.

STOP tel ls the com pu ter not to go any further in aprogram . Com puters o ther than the ZX81 can useEND instead .

PEEK is a way of finding out wha t is in a s pec ificarea of the com puter ' s m emo ry. You nee d to use itwith a num ber which specif ies an "add ress " in thememory .N B n o t u s e d o n B B C .

POKE is a spe cial way ofputting information inth ecomputer ' s memory by us ing a mem ory "ad dress ' .N B n o t u s e d o n B B C .

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 47/52

ASCII cha rt ZX81 code chart

Coden u m b e r

3233

343536373839404142

43444546474849505152535455565758596061

ASCIIc h a r a c t e r

s p a c e1

>)#

$%

&i

(

)*

+i

.

I01-23456789:

i

<

=

Coden u m b e r

6263

646566676869707172

737475767778798081828384858687888990

ASCIIc h a r a c t e r

>•>

(a )ABCDEFGH

IJKLMNOP

0RSTUVWXYZ

Coden u m b e r

1112

131415161718192021

22232425262728293031323334353637383940

ZX81c h a r a c t e r

19

£

$'

?

(

)>

<—

+

—*

I

i

>

0123456789ABC

Coden u m b e r

4142

434445464748495051

525354555657585960616263

ZX81c h a r a c t e r

DE

FGHITKLMN

OP

oRSTUVWXYZ

Ch art of screen sizes

VIC 20

TRS-80

BBC

Z X 8 1ZX Spec t rum

Appl e

Ma x . num ber o f

characters across(or number of columns)

22

64

2 0 / 4 0 / 8 0

3232

40

Ma x . num ber o fl ines dow n

(or nu m ber of rows)

23

16

1 6 / 2 4 / 3 2

2222

25

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 48/52

 Conversion chartThis quick reference chart shows some ofthe variations in th e BASIC used by the machines in this book. Itdoesnot include instructions for graph ics, 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 samesystemofmemory addresses, so the numbers used with PEEK and POKE must be changed for eachcomputer.

Select randomnumber betwee n 0an d 0.99999999

Select randomnumber betwee n 1andN

Select random letterbetween A and Z

Clear screen

Check keyboard tosee i f key beingpressed

Convert charact ersinto code numbers

Move cursor up

Move cursor down

Move cursor leftMove cursor right

Take 1 st Ncharacters of string

Take last Ncharacters of string

Take middle Ncharacters of string

BBC

RND(1)

RND(N)

CHR$(RND(26)+64)

CLS

INKEY$(N)

ASC("X")(using ASCII code )

PRINT CHR$( 11)

PRINT CHR$( 10)

PRINT CHR$(8)PRINT CHR$(9)

LEFT$(A$,N)

RIGHT$(A$,N)

MID$(A$,N1,N2)

VIC/Pet

RND(1)

RND(1)*N+1

CHR$(INT(RND(1)*26+65))

PRINT CHR$( 147)

GETX$

ASC("X")(using ASCII code)

PRINT CHR$( 145)

PRINT CHR$( 17)

PRINT CHR$( 157)

PRINT CHR$(29)

LEFT$(A$,N)

RIGHT$(A$,N)

MID$(A$,N1,N2)

Apple

RND(1)

RND(1)*N+1

CHR$(INT(RND(1)*26+65))

HOME

X $ = " "IF PEEK(-16384)> 127 THEN GET X$

ASC("X")(using ASCII code )

CALL-998

PRINT CHR$( 10)

PRINT CHR$(8)

PRINT CHR$(21)

LEFT$(A$,N)

RIGHT$(A$,N)

MID$(A$,N1,N2)

TRS-80

RND(0)

RND(N)

CHR$(RND(26)+64)

CLS

INKEY$

ASC("X")(using ASCII code)

PRINT CHR$(27)

PRINT CHR$(26)

PRINT CHR$(24)

PRINT CHR$(25)

LEFT$(A$,N)

RIGHT$(A$,N)

MID$(A$,N1,N2)

ZX Spectrum

RND

RND*N+1

CHR$(INT(RND * 26+65))

CLS

INKEY$

CODE("X")(using ASCII code)

PRINT CHR$( 11)

PRINT CHR$( 10)

PRINT CHR$(8)

PRINT CHR$(9)

A$(lTON)

A$(NTO )

A$(NlTON2)

ZX81

RND

RND*N+1

CHR$(INT(RND*26+38))

CLS

INKEY$

CODE("X")(using ZX81 code)

PRINT CHR$( 112)

PRINT CHR$( 113)

PRINT CHR$( 114)

PRINT CHR$( 115)

A$(1T0N)

A$(NTO )

A$(NlTON2)

<fi<t

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 49/52

AnswersYou may find that your an swer s tosom e ofth e p uzzle s are different to

the ones given here. As long as theywork on your com puter then thisdoesn't rea lly matter, but check tosee ifth ey are as neat and simple asthe answe rs in the book.

Page5Robot Missile

Line 90 teUs the computer how manytimes to loop round and get a gu essfrom you. So, for more chanc es ofguessing the secre t co de letter,

change the last number in ine 90 to ahigher one. For less chances, ch angei t toalowerone.

Page7The Vital Message

Page9Shootout

To ma ke it poss ible for the com puterto miss too, ad d th e foUowing ines naddition to those in the 'Making thegame harder" box.

155 IF RND<.1 THEN GOTO 250250 PRINT "HE SHOOTS BUT MISSES"

260 GOTO 9 0

Line 155 may need RND(1) or RND(0),depe nding on your computer.

Page 11Desert Tank Battle

Add the following lines to the prog ramto ad d the possibitity ofthe robo ts

seeingyou:175 IF RND<.05 THEN GOTO 250250 PRINT "THEY'VE SEEN YOU-AABG6HHHH"260 STOP

Change the RND in tine 175 to theversion your comp uter ne eds . You canchang e .05 to any number b etwee n 0and 0.999, but reme mber that thehigher the num ber you put he re the

greater the chanc e ofthe robotsseeingyou.

Page13Battle at Traitor's Castle

You can get 100 points for U, V, W, X orY and 10 points for the o thers bymaking these cha nges.

220 LET H=H+10225 IF P*>"T" AND P*<"Z" THEN LET

H=H+90

Page17SecretWeapon

You can add the scoring system in the

This is a difficult puzzle, so do nt worryifyou couldn't do it. Try out the an sweranyway. Add these ines o get the twotargets.

5 5 LE T P = I N T ( R N D + . 5 ) * 4 + l

hi this program, tines 150 and 160 are a"delay" loop. They m ake the computer

dd nothing for a certain length oftimebefore goin g on to the next instructionin the program which is to clear them ess ag eoff th es cre en .T om aketh e szx5 7 LET p*=cHR*<p+5i>messages tayonthescreenlonger , *

mA*% ^ ^ T r a ^ L E ™

yo une edto m ake thec om pu terlo op iso LET s=s+pround mo re times. You can do this bychanging the last number in tine 150 toa higher one. Page 15

Robot Invaders

R*=R*+P*

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 50/52

puzzle by putting these extra Unes intothe program.

15 LET S=0145 IF Z<=3 THEN LET S=S+1

190 GOTO 217215 LET S=S+10

217 PRINT "YOU SCORED ";S j" POINTS"

Page19Escape!

This is the simplest way to ad d threerobots to the gam e, though it makesth e game rather difficult to win.

22 FOR R=1 TO 325 PRINT "ROBOT "jR300 NEXT R310 STOP

Page21Pirate Dogfight

To make your chance ofhittingthepirate equal to his chance ofhitting

you, change the .7 in line 290 to .5.

Page23Supersonic Bomber

To get more targets each time, changethe 5 in lines 30,70 and 120 to a highernumber. You must put the same

number in aU three Unes.

Page25Iceberg

You can make th e grid bigger bychanging aU the 8s in Unes 20,50,70,80,110,120,160,170,290and310toabigger number. (Use th e same

number each time.)To add more icebergs change th e 448 inUne30toahighernumber.

Goingfurther

Here is a Ust of books you shouldfind useful if you want to find out

more about computers or writingprograms.

Usborne Guide to Computers byBrian Reffin Smith, UsborneUnderstanding the Micro byJudy TatcheU and Bill Bennett,Usbornebitroduction to ComputerProgramming by Brian ReffinSmith, Usborneniustrating BASIC by DonaldAlcock, Cambridge UniversityPressFred Learns about Computers,Macdonald & EvansThe BASIC Handbook by DavidA. Lien, Compusoft PubUshingThe Computer Book by RobinBradbeer et al, BBC PubUcations

First pubUshed in 1982 byUsborne Publishing Ltd, 20GarrickStreet, London WC2E9BJ, England.© 1982 Usborne PubUshing LtdThe name Usborne and thedevice # are Trade marks ofUsborne PubUshing Ltd.

AU rights reserved. No part ofthis publication may bereproduced, stored in a retrievalsystem or transmitted in any formor by any mean s, electronic,mechanical, photocopying ,recording or otherwise, withoutth e prior permission ofthepubUsher.

Printed in Spain byELEXPURU, S. A. L.-Bilbao

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 51/52

8/6/2019 Computer Battle Games

http://slidepdf.com/reader/full/computer-battle-games 52/52

Usborne Computer Programs -Ea ch ofth ese co lourful ne w books contains 14 simple gam es programs topla y on a microcomputer .* A long side the programs there areexplanat ions of how they work and puzzles and sugg est ions for w ay s ofch an gin g them. Through p laying these gam es ev en comple te beginnerswiU qu ick ly beg in to understand ho w a simple program work s and be

itch ing to w rite their ow n. There are t ips and hints on writ ing programsand a sum m ary of BASIC at the back o fe ac h book and aJso a chart whic hwiU he lp you c onv ert programs in m aga zines and other boo ks to work onyour micro .

*The program s in these b ook s are suitable for u s e on the foUowingmicros: ZX81, BBC, TRS-80, VIC 20, Pet, App les wh ich u se PalsoftBASICandZXSpectrum. \ tT ——_____

COMPuT£R

Other Computer Titles, * r r a o o u C T O N T O - ^ ^

C O M P U T E RPROGRAMMING

^ A g u t d * t o r > t M o t a t e t > * g i n m r i

K »

A colourful guide tomicrocom puters, howthey work and what theyca n do , with lots of ideasfor thing s you can do

A step-by-s tep guide toprogxan uning in BASICfor absolute beg inners.W ith lots of prog ram s tor u n o n a n y

A colourful look at howcom puters play SpaceInvad ers , chess andother gam es, with lots oft ips on how to beat the