home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
RBBS in a Box Volume 1 #3.1
/
RBBSIABOX31.cdr
/
pcpo
/
pcmaze.bas
< prev
next >
Wrap
BASIC Source File
|
1985-04-17
|
7KB
|
204 lines
0 REM MODIFIED FOR USE ON THE IBM-PC
1 REM BY GARY & DONNA MCCOY
2 KEY OFF
3 CLEAR,,20000
4 SCREEN 0:WIDTH 40
200 CLS : GOTO 6400
800 N = 2:A = H:B = V:FF = 2 ^ (F - 1)
900 SCREEN 1:COLOR 0,1:CLS
1000 Z = M(A,B) * FF
1200 IF FN M(Z / 16) = 0 THEN 1600
1300 RL = - 1: GOSUB 5400
1400 GOTO 2000
1600 W = M(A + S,B - R) * FF
1700 IF FN M(W / 128) = 0 THEN 2000
1800 RL = - 1: GOSUB 4600
2000 IF FN M(Z / 64) = 0 THEN 2400
2100 RL = 1: GOSUB 5400
2200 GOTO 2800
2400 W = M(A - S,B + R) * FF
2500 IF FN M(W / 128) = 0 THEN 2800
2600 RL = 1: GOSUB 4600
2800 IF FN M(Z / 128) = 1 THEN 3400
3000 N = N + 1: IF N > 8 THEN 3500
3100 A = A + R:B = B + S: IF B < 2 THEN 3500
3200 GOTO 1000
3400 GOSUB 3800
3500 RETURN
3800 PSET (VX + DX(N),YU(N)),2
3900 LINE (VX + DX(N),YU(N))-(VX + DX(N),YD(N)),2
4000 LINE (VX + DX(N),YD(N))-(VX - DX(N),YD(N)),2
4100 LINE (VX - DX(N),YD(N))-(VX - DX(N),YU(N)),2
4200 LINE (VX - DX(N),YU(N))-(VX + DX(N),YU(N)),2
4300 RETURN
4600 PSET (VX + RL * DX(N - 1),YU(N)),2
4700 LINE (VX + RL * DX(N - 1),YU(N))-(VX + RL * DX(N),YU(N)),2
4800 LINE (VX + RL * DX(N),YU(N))-(VX + RL * DX(N),YD(N)),2
4900 LINE (VX + RL * DX(N),YD(N))-(VX + RL * DX(N - 1),YD(N)),2
5000 RETURN
5400 PSET(VX + RL * DX(N - 1),YU(N - 1)),2
5500 LINE (VX + RL * DX(N-1),YU(N-1))-(VX + RL * DX(N),YU(N)),2
5600 LINE (VX + RL * DX(N),YU(N))-(VX + RL * DX(N),YD(N)),2
5700 LINE (VX + RL * DX(N),YD(N))-(VX + RL * DX(N - 1),YD(N - 1)),2
5800 IF N > 2 THEN LINE (VX + RL * DX(N-1),YD(N-1))-(VX + RL * DX(N - 1),YU(N - 1)),2
5900 RETURN
6400 CLS:COLOR 9,0:LOCATE 6,12: PRINT "YOU ARE THE RAT!": PRINT : LOCATE 4,4: PRINT "A DIFFERENT PERSPECTIVE ON MAZES."
6405 CH = 0
6410 PRINT : LOCATE 1,1: PRINT "FROM THE COMPUSERVE APPLE USER'S GROUP"
6420 LOCATE 2,9: PRINT "PUBLIC ACCESS DATABASE"
6425 LOCATE 17,1: PRINT "----------------------------------------"
6430 LOCATE 18,9: PRINT "USE <- AND -> TO TURN"
6440 PRINT : LOCATE 19,6: PRINT "<SPACE BAR> TO MOVE FORWARD"
6450 PRINT : LOCATE 20,3: PRINT "<ESCAPE> FOR A TOP VIEW (TO CHEAT)"
6500 DEF FN M(X) = INT (X) - INT ( INT (X) / 2) * 2
6600 LOCATE 15,1:FX = 36: INPUT "PLEASE ENTER MAZE SIZE (H,V) ";H,V
6700 H = INT (H):V = INT (V)
6800 IF H > 2 AND H < 51 AND V > 2 AND V < 51 THEN 7000
6900 PRINT "2<H<51 -- 2<V<51": GOTO 6600
7000 N = H * V - 1:H = H + 1:V = V + 1:D = 1
7100 DIM M(52,52),W(400)
7200 FOR J = 1 TO V + 1:M(1,J) = 4:M(H + 1,J) = 1: NEXT J
7300 MX = 278:MY = 190:VX = INT (MX / 2):VY = INT (MY / 2):X = VX
7500 FOR J = 1 TO 8:DX(J) = X:YU(J) = INT (VY - X * VY / VX)
7600 YD(J) = INT (VY + X * (MY - VY) / VX):X = INT (X * 7 / 10): NEXT J
7700 FOR I = 2 TO H:M(I,V + 1) = 8:M(I,1) = 2
7800 FOR J = 2 TO V:M(I,J) = 15: NEXT J,I
8500 R = INT (H / 2 + 1):S = INT (V / 2 + 1):M(R,S) = 15
8550 COLOR 23
8600 PRINT " GENERATING MAZE."
8650 COLOR 9
8900 FOR IW = 1 TO N
9000 I = 0
9100 IF M(R - 1,S) < 15 THEN 9300
9200 I = I + 1:C(I) = 1
9300 IF M(R,S - 1) < 15 THEN 9500
9400 I = I + 1:C(I) = 2
9500 IF M(R + 1,S) < 15 THEN 9700
9600 I = I + 1:C(I) = 3
9700 IF M(R,S + 1) < 15 THEN 9900
9800 I = I + 1:C(I) = 4
9900 IF I = 0 THEN 12300
10000 IF I < > 1 THEN I = INT ( RND (1) * I) + 1
10100 ON C(I) GOTO 10300,10800,11300,11800
10300 M(R,S) = M(R,S) - FN M(M(R,S))
10400 R = R - 1
10500 M(R,S) = M(R,S) - FN M(M(R,S) / 4) * 4
10600 GOTO 13400
10800 M(R,S) = M(R,S) - FN M(M(R,S) / 8) * 8
10900 S = S - 1
11000 M(R,S) = M(R,S) - FN M(M(R,S) / 2) * 2
11100 GOTO 13400
11300 M(R,S) = M(R,S) - FN M(M(R,S) / 4) * 4
11400 R = R + 1
11500 M(R,S) = M(R,S) - FN M(M(R,S))
11600 GOTO 13400
11800 M(R,S) = M(R,S) - FN M(M(R,S) / 2) * 2
11900 S = S + 1
12000 M(R,S) = M(R,S) - FN M(M(R,S) / 8) * 8
12100 GOTO 13400
12300 IF D = - 1 THEN 12700
12400 IF R < > H THEN 13100
12500 IF S < > V THEN 13000
12600 R = 2:S = 2: GOTO 13200
12700 IF R < > 2 THEN 13100
12800 IF S < > V THEN 13000
12900 R = H:S = 2: GOTO 13200
13000 S = S + 1:D = - D: GOTO 13200
13100 R = R + D
13200 IF M(R,S) = 15 THEN 12300
13300 GOTO 9000
13400 NEXT IW
13500 MH = H:MV = V
13700 I = INT ( RND (1) * (MH - 1)) + 2
13800 M(I,1) = 0
13900 M(I,2) = M(I,2) - FN M(M(I,2) / 8) * 8
14000 H = INT ( RND (1) * (MH - 1)) + 2
14100 H1 = H:V1 = V
14300 COLOR 23: LOCATE 23,12: PRINT "MAZE COMPLETED.": COLOR 9
14400 GOTO 17000
14700 HZ = INT (MX / MH):VZ = INT (MY / MV)
14750 CH = CH + 1
14800 SCREEN 1:COLOR 0,1:CLS
14900 PSET (1 + HZ,1 + VZ),2
15000 LINE (1 + HZ,1 + VZ)-(1 + HZ,MV * VZ + 1),2
15100 FOR J = 1 TO MV: FOR I = 2 TO MH
15200 N = M(I,J):X = I * HZ + 1:Y = J * VZ + 1
15300 IF FN M(N / 2) = 0 THEN 15700
15500 PSET (X,Y),2
15600 LINE (X,Y)-(X - HZ,Y),2
15700 IF FN M(N / 4) = 0 THEN 16100
15900 PSET (X,Y),2
16000 LINE (X,Y)-(X,Y - VZ),2
16100 NEXT I,J
16300 X = H * HZ - 1:Y = V * VZ - 1
16400 PSET (X + 1,Y + 1),2
16500 LINE (X + 1,Y + 1)-(X - HZ + 2,Y - VZ + 2),2
16600 PSET (X - HZ + 2,Y + 1),2
16700 LINE (X - HZ + 2,Y + 1)-(X + 1,Y - VZ + 2),2
16800 RETURN
17000 FOR X = 1 TO MH: FOR Y = 1 TO MV
17100 M(X,Y) = M(X,Y) + M(X,Y) * 16
17200 NEXT Y,X
17500 F = INT ( RND (1) * 4) + 1
17600 ON F GOTO 17700,17800,17900,18000
17700 R = 0:S = - 1: GOTO 18100
17800 R = 1:S = 0: GOTO 18100
17900 R = 0:S = 1: GOTO 18100
18000 R = - 1:S = 0
18100 GOSUB 800
18300 DEF SEG : POKE 106,0
18400 IK$=INKEY$
18410 KEY(12) ON
18420 KEY(13) ON
18500 ON KEY(12) GOSUB 19100
18600 ON KEY(13) GOSUB 19400
18700 IF IK$ = " " THEN 20100
18800 IF IK$ = CHR$(27) THEN 21300
18900 GOTO 18400
19100 F = F - 1: IF F < 1 THEN F = 4
19200 GOTO 19500
19400 F = F + 1: IF F > 4 THEN F = 1
19500 ON F GOTO 19600,19700,19800,19900
19600 R = 0:S = - 1: GOTO 21000
19700 R = 1:S = 0: GOTO 21000
19800 R = 0:S = 1: GOTO 21000
19900 R = - 1:S = 0: GOTO 21000
20100 Z = M(H,V)
20200 T = Z * 2 ^ (F - 1):T = FN M(T / 128)
20300 IF T = 0 THEN 20600
20500 GOTO 18300
20600 NM = NM + 1: LOCATE 22,24: PRINT "MOVE "NM
20650 FOR Q=1 TO 500:NEXT
20700 IF NM < 400 THEN W(NM) = F
20800 H = H + R:V = V + S
20900 IF V < 2 THEN 21500
21000 GOSUB 800
21100 GOTO 18300
21300 GOSUB 14700
21400 GOTO 18300
21500 CLS : LOCATE 12,5: PRINT "CONGRATS, IT TOOK YOU "NM" STEPS."
21540 IF CH = 1 THEN LOCATE 14,8: PRINT "(BUT YOU CHEATED ONCE.)
21550 IF CH > 1 THEN LOCATE 14,6: PRINT " (BUT YOU CHEATED ";CH;" TIMES.)"
21560 FOR I=1 TO 5000:NEXT
21700 V = V1:H = H1: GOSUB 14700
21900 X = INT (H * HZ - HZ / 2) + 1:Y = INT (V * VZ - VZ / 2) + 1
22000 PSET (X,Y),1
22100 FOR N = 1 TO NM
22200 IF N > 400 THEN 22900
22300 F = W(N)
22400 IF F = 1 THEN V = V - 1
22500 IF F = 2 THEN H = H + 1
22600 IF F = 3 THEN V = V + 1
22700 IF F = 4 THEN H = H - 1
22800 LINE (X,Y)-(INT (H * HZ - HZ / 2) + 1, INT (V * VZ - VZ / 2) + 1),1
22850 X=INT(H * HZ - HZ/2) + 1:Y=INT(V * VZ -VZ/2) + 1
22900 NEXT N
22920 LOCATE 1,1:PRINT "PRESS ANY KEY TO CONTINUE"
22950 IK$=INKEY$
23000 KEY(12) OFF:KEY(13) OFF: IF IK$ = "" THEN 22950
23100 CLEAR:GOTO 3
50000 REM
Y KEY TO CONTINUE"
22950 IK$=INKEY$
23000 KEY(12) OFF:KEY(13) OFF: IF IK$ = "" THEN 22950
23100 CLEAR:GOT