8-Bit Software Online Conversion
Caterpillar - Listing
10 REM "CATERPILLAR" for the BBC COMP
UTER and Acorn ELECTRON
20 REM Ch.W. Brederode, LISSE,
The Netherlands; Version 4, apr 1988
30 REM This is Public Domain.
40 IF PAGE>&1100 THEN PAGE=&1100:CHAI
N"CATER"
50:
60 PROCarrays:PROCvdu23
80 G=0:SC=2:STUUR=5:anders=-1:*FX4,1
90 D%=0:P=31:M=0:REM startdata automa
at (!=autom.piloot)
100 IF S% THEN 120
110 MODE6:PROCspelregels
120 MODE1:PROCkleuren:PROCtekening:PRO
Cstart
160 :
170 REPEAT PROCstuur:PROCloop:G=G+1:UN
TIL FALSE
220 END
230 :
240 DEF PROCautpiloot
250 IF X%(K%)=P THEN READ M:STUUR=M:RE
AD P
270 DATA 0,14,2,14,0,11,2,11,0,10,2,10
,2,10,2,10,1,12,2,12
280 DATA 0,6,2,6,1,10,2,10,0,6,2,6,1,1
3,2,13,0,7,2,7,1,13
290 DATA 2,13,0,9,2,9,0,5,2,5,1,9,2,9,
0,5,2,5,1
300 DATA 16,2,16,0,8,2,8,1,17,2,17,2,1
7,2,17,2,17,2,17,2,17
310 DATA 0,9,3,9,1,16,3,16,0,4,3,4,1,1
6,3,16,0,8,3,8
320 DATA 1,11,3,11,1,13,2,13,1,18,3
330 ENDPROC
340 :
350 DEF PROCvlinder
360 PRINTTAB(3,3)"TIME IS UP!"
370 FOR N=1TO100:SOUND1,-1,100+RND(200
),1:NEXT
390 COLOUR0:N%=S%:PRINTTAB(X%(N%),Y%(N
%))" "
400 REPEAT:N%=(N%+1)MOD16:PRINTTAB(X%(
N%),Y%(N%))" " :UNTIL N%=K%:COLOUR1
430 VDU19,2,3,0,0,0:GCOL0,2:RESTORE 46
0
450 FORN=1 TO 26:READA%,B%,C%:PLOTA%,B
%*32,C%*32:NEXT
460 DATA 4,30,25,21,27,20,5,27,15,85,2
0,17,85,25,12
470 DATA 85,19,14,85,21,12,4,30,18,5,1
9,18,85,21,25
480 DATA 85,17,21,85,18,25,85,17,24
490 DATA 4,25,25,21,28,20,5,28,15,85,3
5,17,85,30,12
500 DATA 85,36,14,85,34,12,4,25,18,5,3
6,18,85,34,25
510 DATA 85,38,21,85,37,25,85,38,24
520 VDU5:GCOL0,3:MOVE832,672:VDU138,14
0,132:GCOL0,1
530 VDU10,8,8,137,10,8,137,10,8,137,10
,8,137,10,8,137
540 MOVE640,718:VDU136,142,10,8,8,133,
139
550 MOVE1056,718:VDU136,142,10,8,8,133
,139
560 MOVE 655,530:VDU137:MOVE690,500:VD
U137
570 MOVE730,480:VDU137:MOVE990,480:VDU
137
580 MOVE1030,500:VDU137:MOVE1065,530:V
DU137
590 MOVE 960,800:DRAW880,666:DRAW800,8
00
600 VDU4:COLOUR1
610 ENDPROC
620 :
630 DEF PROCspelregels
640 VDU19,0,4,0,0,0
650 PRINT''" CATERPILLAR"''
655 PRINT" You can move the caterpilla
r with the"
660 PRINT" keys HJUN or the cursor-key
s."
670 PRINT" You get 100 seconds to eat
as many"
680 PRINT" leaves as possible."
690 PRINT" You collect points with tha
t!"
700 PRINT" But take care:"'" the flowe
rs are POISONED!"
710 PRINT" The caterpillar is not allo
wed to pass"
720 PRINT" the border and he should no
t bite"'" himself."
730 PRINT" GOOD LUCK !"'''
735 PRINT" Press spacebar ";:Q=GET
740 ENDPROC
750 :
760 DEF PROCkleuren
770 VDU19,0,7,0,0,0 ,19,2,2,0,0,0 ,19,
3,4,0,0,0
800 VDU23,1,0;0;0;0;
810 ENDPROC
820 :
830 DEF PROCvdu23
840 VDU23,131,0,0,0,0,60,102,219,189
850 VDU23,132,192,96,176,208,208,176,9
6,192
860 VDU23,133,189,218,101,59,11,13,6,3
870 VDU23,134,189,219,102,60,0,0,0,0
880 VDU23,135,189,219,102,60,60,102,21
9,189
890 VDU23,136,3,6,13,11,59,101,218,189
900 VDU23,137,60,102,219,189,189,219,1
02,60
910 VDU23,138,3,6,13,11,11,13,6,3
920 VDU23,139,189,91,166,220,216,176,9
6,192
930 VDU23,140,195,102,189,219,219,189,
102,195
940 VDU23,142,192,96,176,216,220,166,9
1,189
950 ENDPROC
960 :
970 DEF PROCtekening
980 GCOL0,2:RESTORE 1000
990 FORN=1TO58:READA%,B%,C%:PLOTA%,32*
B%,32*C%:NEXT
1000 DATA 4,18,6,5,16,4,85,16,7,85,12,5
,5,6,4,85,6,6
1010 DATA 85,4,5,4,14,2,5,14,4,85,12,3,
85,12,5,5,10,7
1020 DATA 85,8,6,85,8,7,4,9,2,5,11,3,85
,9,4,85,12,5
1030 DATA 5,17,9,85,14,10,85,16,11,4,12
,5,5,11,7,5
1040 DATA 7,8,4,13,10,5,13,9,85,12,10,8
5,11,7,5,10,9,5
1050 DATA 12,12,4,5,13,5,5,11,85,7,13,8
5,10,9,5,9,14,5,6,16
1060 DATA 4,14,17,5,13,15,85,12,17,85,9
,14,5,9,16,5,12,19
1070 DATA 4,6,20,5,6,18,85,8,19,85,9,16
,5,9,18,5,7,22
1080 DATA 4,13,21,5,11,21,85,12,19,85,9
,18,5,10,21,5,12,23
1090 DATA 4,9,25,5,10,21,5,11,24,5,13,2
7
1100 MOVE30,60:DRAW1250,60:DRAW1250,994
:DRAW30,994:DRAW30,60
1110 COLOUR3
1120 FORN=1TO9:READA%,B%,C%:PRINTTAB(A%
,B%);:PROCbloem(C%):NEXT
1130 DATA 12,24,1160,5,23,1180,11,19,11
80,4,15,1180,11,12,1170
1140 DATA 6,9,1170,11,9,1160,9,7,1160,1
2,5,1160
1150 COLOUR1
1160 S%=2:K%=6
1170 FORN=S%TOK%:PRINTTAB(X%(N),Y%(N))C
HR$(137):NEXT:REM rups
1180 PRINTTAB(3,3)"FOR RULES: PRESS R"
1190 ENDPROC
1200 :
1210 DEF PROCbloem(C%)
1220 IF C%=1160 VDU137
1230 IF C%=1170 VDU136,142,10,8,8,133,1
39
1240 IF C%=1180 VDU136,140,142,10,8,8,8
,133,140,139
1250 ENDPROC
1260 :
1270 DEF PROCarrays
1280 DIM V%(15),N%(15),R%(15),X%(15),Y%
(15),v%(3),n%(3),x%(3),y%(3)
1290 REM Van,Naar,Richting:1=NOORD,2=OO
ST,4=ZUID,8=WEST:x%,y%COORD.RUPS
1300 RESTORE 1330 :FORN=0 TO 3
1320 READv%(N):READn%(N):READx%(N):READ
y%(N):NEXT:REM besturing
1330 DATA 2,8,-1,0,8,2,1,0,1,4,0,1,4,1,
0,-1
1340 FORN=2TO6 :READV%(N):READN%(N):REA
DR%(N):READX%(N):READY%(N):NEXT
1360 REM tekengegevens rups
1370 DATA 4,1,5,33,7,4,1,5,33,6,4,8,12,
33,5,2,8,10,32,5,2,8,10,31,5
1380 ENDPROC
1390 :
1400 DEF PROCvergif
1410 FOR N=200TO10STEP-4:SOUND1,-1,N,1:
NEXT
1420 VDU19,1,5,0,0,0:PRINTTAB(3,3)"ATE
POISON !"
1430 PRINTTAB(X%(K%),Y%(K%))CHR$(137)
1440 ENDPROC
1450 :
1460 DEF PROCbijt
1470 SOUND0,-1,20,5
1480 VDU19,1,9,0,0,0:PRINTTAB(3,3)"CATE
RPILLAR BITES ITSELF!"
1490 PRINTTAB(X%(K%),Y%(K%))"O"
1500 ENDPROC
1510 :
1520 DEF PROCrand
1530 FOR N=1TO20:SOUND0,-1,N,2:NEXT
1540 PRINTTAB(3,3)"AI!! PAST THE BORDER
!"
1550 ENDPROC
1560 :
1570 DEF PROCeinde
1580 GCOL0,1:MOVE30,60:DRAW1250,60:DRAW
1250,994
1590 DRAW30,994:DRAW30,60
1600 PRINTTAB(22,24);SC;" POINTS"
1610 PRINTTAB(9,30)" PRESS SPACEBAR "
1620 REPEAT UNTIL GET=32:RUN
1630 ENDPROC
1640 :
1650 DEF PROCstuur
1660 IF D% THEN PROCautpiloot:GOTO 1700
1665 Q=INKEY(0):*FX21,0
1666 IF Q>135 anders=Q-136:GOTO1680
1670 IF Q=72 THEN anders=0:GOTO1680
1671 IF Q=74 THEN anders=1:GOTO1680
1672 IF Q=78 THEN anders=2:GOTO1680
1673 IF Q=85 THEN anders=3
1680 IF (anders>-1)AND(anders<4)THEN ST
UUR=anders
1690 IF STUUR=5 THEN 1660
1700 R%(K%)=V%(K%)+n%(STUUR)
1710 V%((K%+1)MOD16)=v%(STUUR)
1720 N%((K%+1)MOD16)=n%(STUUR)
1730 X%((K%+1)MOD16)=X%(K%)+x%(STUUR)
1740 Y%((K%+1)MOD16)=Y%(K%)+y%(STUUR)
1750 ENDPROC
1760 :
1770 DEF PROCloop
1780 REM --- BEWEGING FASE 1 ---
1790 TIME=0
1800 N%=S%:PRINTTAB(X%(N%),Y%(N%))CHR$(
130+V%((N%+1)MOD16))
1810 REPEAT
1820 N%=(N%+1)MOD16
1830 PRINTTAB(X%(N%),Y%(N%))CHR$(130+R%
(N%))
1840 UNTIL N%=K%
1850 K%=(K%+1)MOD16
1860 PRINTTAB(22,24)SPC(9)
1870 X=32*X%(K%)+16:Y=1024-32*Y%(K%)-16
1880 IF POINT(X,Y)=3 PROCvergif:PROCein
de
1890 IF POINT(X,Y)=1 PROCbijt:PROCeinde
1900 IF POINT(X,Y)=2 SC=SC+1:SOUND0,-1,
20,3
1910 PRINTTAB(22,24);SC;" POINTS"
1920 PRINTTAB(X%(K%),Y%(K%))CHR$(137)
1930 IF G=200 AND SC>50 THEN PROCvlinde
r:PROCeinde
1940 IF G=200 PRINTTAB(3,3)"TIME IS UP"
:PROCeinde
1950 REPEATUNTILTIME>15
1960 REM --- BEWEGING FASE 2 ---
1970 TIME=0
1980 PRINTTAB(X%(S%),Y%(S%));" "
1990 IF(SC MOD 10)=0THEN SC=SC+1:GOTO20
10
2000 S%=(S%+1)MOD16 :REM staart niet v
erhogen = groeien
2010 N%=S%
2020 REPEAT
2030 PRINTTAB(X%(N%),Y%(N%))CHR$(137):N
%=(N%+1)MOD16
2040 UNTILN%=K%
2050 IF (X%(K%)=0)OR(X%(K%)=39)OR(Y%(K%
)=0)OR(Y%(K%)=30) PROCrand:PROCeinde
2060 REPEATUNTILTIME>15
2070 ENDPROC
2080 :
2090 DEF PROCstart
2100 Q=GET
2110 IF Q=82 OR Q=114 THEN S%=0:D%=0:RU
N:REM R = spelregels tonen
2120 IF Q=33 THEN D%=1
:REM ! = autom.piloot
2130 PRINTTAB(3,3)SPC(23)
:REM tekst wissen
2140 RESTORE 270
2150 ENDPROC