SetUp: CLEAR SCREEN 1,320,200,3,1 WINDOW 1,"",(0,0)-(170,85),16,1 WINDOW 3,"",,16,1 WINDOW 2,"",,16,1 PALETTE 0,.5,.5,.5 'Screen PALETTE 1,0,0,0 'Border PALETTE 2,.35,.2,.5 'c1 PALETTE 3,.4,.3,.6 'c2 PALETTE 4,.45,.4,.7 'c3 PALETTE 5,.5,.5,.8 'c4 'PALETTE 6,.4,.6,1 'Sky PALETTE 7,.5,.5,.4 'Ground DEFINT a-y DIM z(1403) FOR l=1 TO 7:READ Na(l),Ca(l):NEXT DATA 0,2, 1,5, 0,4, -1,3, 0,2, 1,5, 0,4 RANDOMIZE TIMER:ch=0 Begin: IF ch=1 THEN ERASE p WINDOW 2:CLS LOCATE 2,1:COLOR 1 PRINT " A m i g a M a z e ! " PRINT " ~~~~~~~~~~~~~~~~~~~ " PRINT " © 1988 by David Rollinson " PRINT PRINT " Find your way out of the maze " PRINT " as quickly as possible using " PRINT " the cursor keys to move. " PRINT " Press the help key to view " PRINT " the map. Press the delete key " PRINT " to abort. Have fun! " PRINT PRINT " Please Enter Maze Dimensions: " Xin: LOCATE 14,3 INPUT "X axis (1-36)...>",Xmax IF Xmax<1 OR Xmax>36 THEN Xin Yin: LOCATE 16,3 INPUT "Y axis (1-20)...>",Ymax IF Ymax<1 OR Ymax>20 THEN Yin Ymax=Ymax*2+2:Xmax=Xmax*2+2 DIM p(Ymax,Xmax) FOR x=0 TO Xmax:p(0,x)=-1:p(Ymax,x)=-1:NEXT FOR y=0 TO Ymax:p(y,0)=-1:p(y,Xmax)=-1:NEXT CreateMaze: WINDOW 3:CLS PRINT "Generating Maze..."; LINE (12,12)-(Xmax*4+7,Ymax*4+7),2,bf LINE (11,11)-(Xmax*4+8,Ymax*4+8),1,b x=2:y=2 p(y,x)=1:COLOR 7:GOSUB box complete=0 WHILE complete=0 pstop=0 WHILE pstop=0:GOSUB FindRoute:WEND SOUND 700,.5,255,0 WHILE pstop=1:GOSUB StepBack:WEND IF x=2 AND y=2 THEN complete=1 WEND LOCATE 1,1:PRINT " " x=Xmax-1:y=INT(RND(1)*(Ymax/2-1))*2+2 p(y,x)=3 COLOR 0:GOSUB box:x=x+1:GOSUB box x=2:y=INT(RND(1)*(Ymax/2-1))*2+2 GOTO Start FindRoute: IF p(y-2,x)<>0 AND p(y,x+2)<>0 AND p(y+2,x)<>0 AND p(y,x-2)<>0 THEN pstop=1 ELSE d=INT(RND(1)*4)+1:ax=0:ay=0 IF p(y+Na(d+3)+Na(d+3),x+Na(d)+Na(d))=0 THEN ay=Na(d+3):ax=Na(d) x=x+ax:y=y+ay:p(y,x)=1:GOSUB box1 x=x+ax:y=y+ay:p(y,x)=1:GOSUB box1 END IF RETURN StepBack: p(y,x)=2:ax=0:ay=0 IF p(y-1,x)=1 AND p(y-2,x)=1 THEN ay=-1 ELSEIF p(y,x+1)=1 AND p(y,x+2)=1 THEN ax=1 ELSEIF p(y+1,x)=1 AND p(y+2,x)=1 THEN ay=1 ELSEIF p(y,x-1)=1 AND p(y,x-2)=1 THEN ax=-1 END IF GOSUB box:x=x+ax:y=y+ay GOSUB box:x=x+ax:y=y+ay IF p(y-2,x)=0 OR p(y,x+2)=0 OR p(y+2,x)=0 OR p(y,x-2)=0 THEN pstop=0 ELSEIF x=2 AND y=2 THEN pstop=0 END IF RETURN box: LINE (x*4+8,y*4+8)-(x*4+11,y*4+11),,bf:RETURN box1: LINE (x*4+8,y*4+8)-(x*4+11,y*4+11),,b:RETURN Start: WINDOW OUTPUT 2:CLS d=1:xm=0:ym=-1 d$(1)="North":d$(2)=" East" d$(3)="South":d$(4)=" West" quit=0 GOSUB Direction:GOSUB Draw LINE (75,17)-(245,103),1,b LINE (119,125)-(195,169),1,b LINE (120,126)-(194,168),7,bf LINE (120,126)-(120+Xmax,126+Ymax),2,bf PSET (120+x,126+y),6 WINDOW 2 WHILE (quit=0) k$="":WHILE k$="":k$=INKEY$:WEND IF ASC(k$)=127 THEN quit=1 ELSEIF ASC(k$)=139 THEN WINDOW 3:COLOR 1:GOSUB box FOR t=1 TO 20000:NEXT COLOR 0:GOSUB box:WINDOW 2 ELSEIF ASC(k$)=31 THEN d=d-1:IF d<1 THEN d=4 GOSUB Direction GOSUB Draw:SOUND 1000,1,255 ELSEIF ASC(k$)=30 THEN d=d+1:IF d>4 THEN d=1 GOSUB Direction GOSUB Draw:SOUND 1000,1,255 ELSEIF ASC(k$)=28 AND p(y+ym,x+xm)>0 THEN PSET (120+x,126+y),7 x=x+xm:y=y+ym GOSUB Draw:SOUND 500,1,255 PSET (120+x,126+y),6 IF p(y,x)=3 THEN quit=2 ELSEIF ASC(k$)=29 AND p(y-ym,x-xm)>0 THEN PSET (120+x,126+y),7 x=x-xm:y=y-ym GOSUB Draw:SOUND 500,1,255 PSET (120+x,126+y),6 END IF WEND COLOR 1 IF quit = 2 THEN LOCATE 13,8 PRINT "Congratulations!!!" LOCATE 21,6 PRINT "Hit a key to Re-Start!" k$="":WHILE k$="":k$=INKEY$:WEND END IF ch=1:GOTO Begin Direction: Xadd1=Na(d+3):Yadd1=Na(d+2) Xadd2=Na(d+1):Yadd2=Na(d) xm=Na(d):ym=Na(d+3) RETURN Draw: WINDOW OUTPUT 1 COLOR 6:LINE (0,0)-(168,42),,bf COLOR 7:LINE (0,42)-(168,84),,bf tx=x:ty=y:s=6 WHILE (p(ty,tx)>0 AND p(ty,tx)<3 AND s>1) ty=ty+ym:tx=tx+xm:s=s-1 WEND WHILE(s<7) a=0:FOR c=s-1 TO 1 STEP-1:a=a+c:NEXT:b=a+s IF p(ty,tx) <1 THEN GOSUB wall ELSE IF p(ty+Yadd1,tx+Xadd1) <1 THEN GOSUB Lside:ELSE GOSUB Lpath IF p(ty+Yadd2,tx+Xadd2) <1 THEN GOSUB Rside:ELSE GOSUB Rpath END IF ty=ty-ym:tx=tx-xm:s=s+1 WEND GET (0,0)-(168,84),z WINDOW 2:PUT (76,18),z,PSET COLOR 1:LOCATE 13,11:PRINT "Facing:";d$(d) RETURN Rside: COLOR Ca(d+1) AREA (84+(a*4),42-(a*2)) AREA STEP(s*4,-s*2) AREA STEP(0,b*4) AREA STEP(-s*4,-s*2) AREA STEP(0,-a*4) AREAFILL RETURN Lside: COLOR Ca(d+3) AREA(84-(a*4),42-(a*2)) AREA STEP(-s*4,-s*2) AREA STEP(0,b*4) AREA STEP(s*4,-s*2) AREA STEP(0,-a*4) AREAFILL RETURN Rpath: COLOR Ca(d) x1=84+(a*4):y1=42-(a*2) x2=84+(b*4):y2=42+(a*2) LINE(x1,y1)-(x2,y2),,bf RETURN Lpath: COLOR Ca(d) x1=84-(a*4):y1=42-(a*2) x2=84-(b*4):y2=42+(a*2) LINE(x1,y1)-(x2,y2),,bf RETURN wall: COLOR Ca(d) x1=84-(b*4):y1=42-(b*2) x2=84+(b*4):y2=42+(b*2) LINE(x1,y1)-(x2,y2),,bf RETURN