Compucolor.org – Virtual Media

Listing of file='SNAKE.BAS;01' on disk='vmedia/BASIC_compiler_v12.25-sector.ccvf'

5 PLOT 12,3,16,6:PRINT "C R O S S    S N A K E S"
6 PLOT 3,4,12:PRINT "YOUR SNAKE MUST NEVER CROSS THE PATH OF EITHER SNAKE"
7 PRINT :PRINT "CONTROL IS ..... 8 - UP"
8 PRINT "            .... 6 - >"
9 PRINT "             ... 4 - <"
10 REM
______________  PROGRAM  CROSS-SNAKES  _______________K
11 PRINT "              .. 2 - DOWN"
12 PRINT :PRINT :PRINT :PRINT :INPUT "PRESS RETURN TO START.... ";W
15 REM


16 P= 1:SS= 0:YS= 0
18 SE= PEEK (33209):FOR Q= 0TO SE+ 11:DI= RND (1):NEXT
20 OUT 100,33:OUT 101,34
25 N= 0
30 PLOT 6,0,12,27,24
32 DIM SC(64,32)
33 PLOT 14:PRINT "WAIT TO START"
36 FOR I= 0TO 31:FOR J= 0TO 63:SC(J,I)= 0:NEXT :PLOT 3,2,2,14:PRINT 32- I" ":NEXT
38 PRINT "READY"
39 PLOT 12,3,32,0,14:PRINT "SNAKE.."SS"   YOU.."YS"  "
40 D= 6:X1= 31:Y1= 15:C= 40
41 F= 6:G= 29:H= 17
42 POKE 33278,0
45 C= 47
50 GOSUB 1000:GOSUB 2000:GOSUB 3000
60 FOR I= 1TO N:NEXT
70 A= X1:B= Y1:M= D
75 X1= G:Y1= H:C= 24:D= F:P= 2
80 GOSUB 4000:GOSUB 2000:GOSUB 3000
85 G= X1:H= Y1:F= D
90 X1= A:Y1= B:C= 47:D= M:P= 1
95 GOTO 50
1000 REM
............INPUT DIRECTION............


1010 DR= PEEK (33278)
1020 IF DR= 0THEN RETURN
1025 IF INT ((DR- 48)/ 2)< > (DR- 48)/ 2GOTO 1035
1030 D= DR- 48
1035 POKE 33278,0
1040 RETURN
2000 REM
...............CHANGE DIRECTION...........


2005 X= X1:Y= Y1
2010 IF D= 2THEN Y1= Y+ 1:IF Y1> 31THEN Y1= Y1- 32
2020 IF D= 6THEN X1= X+ 1:IF X1> 63THEN X1= X1- 64
2030 IF D= 8THEN Y1= Y- 1:IF Y1< 0THEN Y1= Y1+ 32
2040 IF D= 4THEN X1= X- 1:IF X1< 0THEN X1= X1+ 64
2060 IF SC(X1,Y1)> 0GOTO 2200
2100 SC(X1,Y1)= P
2199 RETURN
2200 PLOT 14,6,17
2205 IF P= 1THEN SS= SS+ 1:PRINT :PRINT :PRINT "SNAKE WINS"
2210 IF P= 2THEN YS= YS+ 1:PRINT :PRINT :PRINT "YOU BEAT THE SNAKE"
2220 PRINT ""
2230 PLOT 6,6,8:GOTO 33
2999 RETURN
3000 REM
  ............DRAW SNAKE................



3010 PLOT 3,X,Y,6,C
3020 PRINT "X";
3025 PLOT 3,X1,Y1
3030 PRINT " ";
3040 PLOT 8:PRINT ""
3045 RETURN
4000 REM
.................SEE AHEAD..........
4020 X2= X1+ 1:IF X2> 63THEN X2= 0:X3= 1:GOTO 4025
4022 X3= X1+ 2:IF X3> 63THEN X3= 0
4025 X4= X1- 1:IF X4< 0THEN X4= 63:X5= 62:GOTO 4030
4028 X5= X1- 2:IF X5< 0THEN X5= 63
4030 Y2= Y1+ 1:IF Y2> 31THEN Y2= 0:Y3= 1:GOTO 4035
4032 Y3= Y1+ 2:IF Y3> 31THEN Y3= 0
4035 Y4= Y1- 1:IF Y4< 0THEN Y4= 31:Y5= 30:GOTO 4040
4038 Y5= Y1- 2:IF Y5< 0THEN Y5= 31
4040 DI= RND (1)* 10:IF DI> 7THEN GOSUB 5000
4050 IF D= 6THEN IF SC(X2,Y1)> 0OR SC(X3,Y1)> 0THEN GOSUB 5000:CT= CT+ 1:GOTO 4060
4055 IF D= 6GOTO 4280
4060 IF D= 8THEN IF SC(X1,Y4)> 0OR SC(X1,Y5)> 0THEN GOSUB 5000:CT= CT+ 1:GOTO 4070
4065 IF D= 8GOTO 4280
4070 IF D= 2THEN IF SC(X1,Y2)> 0OR SC(X1,Y3)> 0THEN GOSUB 5000:CT= CT+ 1:GOTO 4080
4075 IF D= 2GOTO 4280
4080 IF D= 4THEN IF SC(X4,Y1)> 0OR SC(X5,Y1)> 0THEN GOSUB 5000:CT= CT+ 1:GOTO 4090
4085 IF D= 4GOTO 4280
4090 IF CT> 20GOTO 4700
4100 GOTO 4050
4280 CT= 0:RETURN
4699 RETURN
4700 CT= 0
4750 IF D= 6THEN IF SC(X2,Y1)> 0THEN GOSUB 5000:CT= CT+ 1:GOTO 4760
4755 IF D= 6GOTO 4280
4760 IF D= 8THEN IF SC(X1,Y4)> 0THEN GOSUB 5000:CT= CT+ 1:GOTO 4770
4765 IF D= 8GOTO 4280
4770 IF D= 2THEN IF SC(X1,Y2)> 0THEN GOSUB 5000:CT= CT+ 1:GOTO 4780
4775 IF D= 2GOTO 4280
4780 IF D= 4THEN IF SC(X4,Y1)> 0THEN GOSUB 5000:CT= CT+ 1:GOTO 4790
4785 IF D= 4GOTO 4280
4790 IF CT> 50GOTO 4900
4800 GOTO 4750
4900 D= 2:RETURN
4999 RETURN
5000 D= INT (RND (1)* 4+ 1)* 2
5020 RETURN
5050 D= D+ DI
5060 PLOT 3,CT* 3,0:PRINT D
5070 PLOT 3,CT* 3,1:PRINT DI
5100 IF D> 8THEN D= D- 6:GOTO 5100
5200 RETURN