SNAP (Spectrum)

by Bill Lythgoe

from Sinclair User 26 (May 1984)



SNAP IS A GAME for two players in which the screen and border

continually change colour. When the colours match, player one should

press 1 and player two should press 0. The player to press first gains

a point but a point will go to the opponent if you press at the

incorrect time. Written for the 16K Spectrum by Bill Lythgoe of

Shelvington, Wigan.



VARIABLES used by the program:

a$  1st player's name

b$  2nd player's name

a   1st player's score

b   2nd player's score

w   Winning score

bo  Border colour

pa  Paper colour

n   Used to vary the note in BEEP statements



  10-  60  Prints the opening titles

       70  Waits for a key to be pressed

 100- 120  Input the players' names and winning score

      130  Sets players' scores to zero

      150  As the paper colour keeps changing, this command ensures

           that anything printed can still be read. If the paper is

           dark, the ink will be white; if it is light, the ink will

           be black. See page 111 [page 83. JimG] of the manual.

 170- 180  Picks random paper and border colours and clears the screen

           to those colours

 190- 200  Prints the players' names and scores

      210  Pause for a random amount of time

 220- 250  If either player is pressing a key and the colours are the

           same, their score is increased and printed. If the colours

           are not the same, their opponent's score is increased.

      260  Clears the message printed in lines 220-250

 270- 280  Alters the value of n and limits it to 13

 290- 300  If either of the players has reached the winning score,

           print it and GOTO the end of game routine

      310  GOTO start of game

 500- 530  Print instructions to play again

      540  Wait for key to be pressed

 550- 560  If you have chosen either option, GOTO the correct line.

           If not, the program will run out of lines and STOP.



This is a fairly straightforward game but as it might be used by

people who know nothing about computers it should be error-trapped -

that is the program should not stop if an incorrect key is pressed.

When one player presses a key in lines 220-250, if that is the winning

press the program goes to line 500 and waits for another keypress, if

the player has not released the key quickly enough the program stops.

By adding the new line 500, the program waits for the key to be

released before continuing.



500 IF INKEY$ <> "" THEN GOTO 500

505 CLS



Lines 100-120 can also be error-trapped, for example:



100 INPUT "1st player's name?";a$:

    IF a$="" THEN PRINT AT 20,4;"You must enter something": GOTO 100

105 CLS



There is more error-trapping you can do - that is for you to decide.



If the program is to be used by very young children it would be useful

if they had to press only their half of the keyboard rather than one

key. For example, add:



210 PAUSE 50+RND*50

212 LET st=(IN 65278<>255 OR IN 65022<>255 OR IN 64510<>255 OR IN 63486<>255)

214 LET nd=(IN 61438<>255 OR IN 57342<>255 OR IN 49150<>295 OR IN 32766<>255)

216 IF st=1 AND nd=1 THEN PRINT AT 10,12;"TIE":

    FOR t=1 TO 100: NEXT t: CLS: GOTO 160



If you have an Issue 3 Spectrum, alter all the 255s to 191.



Alter the beginning of the following lines to:



220 IF st=1 AND ...

230 IF nd=1 AND ...

240 IF st=1 AND ...

250 IF nd=1 AND ...

