sync on randomize timer() type cll up as boolean right as boolean down as boolean left as boolean above as boolean below as boolean visit as boolean endtype top: global OBJC=0 global WIDTH=5 global HEIGHT=5 global DEPTH=5 global CX=1 global CY=1 global CZ=1 global dim cell(WIDTH,HEIGHT,DEPTH) as cll dim posx(0) dim posy(0) dim posz(0) dim move(0) `1=up,2=right,3=down,4=left,5=down,6=above ink rgb(0,255,0),0 for x=0 to 20 for y=0 to 20 dot x,y,rgb(0,rnd(255),0) next y next x get image 1,0,0,20,20 ink rgb(255,0,0),0 box 0,0,10,10 get image 2,0,0,10,10,1 for x=1 to WIDTH for y=1 to HEIGHT for z=1 to DEPTH cell(x,y,z).up=1 cell(x,y,z).right=1 cell(x,y,z).down=1 cell(x,y,z).left=1 cell(x,y,z).above=1 cell(x,y,z).below=1 cell(x,y,z).visit=0 next z next y next x f=0 repeat line CX*5,CY*5,posx(array count(posx(0)))*5,posy(array count(posy(0)))*5 sync `wait 100 cell(CX,CY,CZ).visit=1 if f=0 array insert at bottom posx(0) array insert at bottom posy(0) array insert at bottom posz(0) posx(array count(posx(0)))=CX posy(array count(posy(0)))=CY posz(array count(posz(0)))=CZ endif dim move(0) if CY>1 if cell(CX,CY-1,CZ).visit=0 array insert at bottom move(0) move(array count(move(0)))=1 endif endif if CX<WIDTH if cell(CX+1,CY,CZ).visit=0 array insert at bottom move(0) move(array count(move(0)))=2 endif endif if CY<HEIGHT if cell(CX,CY+1,CZ).visit=0 array insert at bottom move(0) move(array count(move(0)))=3 endif endif if CX>1 if cell(CX-1,CY,CZ).visit=0 array insert at bottom move(0) move(array count(move(0)))=4 endif endif if CZ>1 if cell(CX,CY,CZ-1).visit=0 array insert at bottom move(0) move(array count(move(0)))=5 endif endif if CZ<DEPTH if cell(CX,CY,CZ+1).visit=0 array insert at bottom move(0) move(array count(move(0)))=6 endif endif if array count(move(0))>0 m=rnd(array count(move(0))-1)+1 if move(m)=1 cell(CX,CY,CZ).up=0 cell(CX,CY-1,CZ).down=0 CY=CY-1 endif if move(m)=2 cell(CX,CY,CZ).right=0 cell(CX+1,CY,CZ).left=0 CX=CX+1 endif if move(m)=3 cell(CX,CY,CZ).down=0 cell(CX,CY+1,CZ).up=0 CY=CY+1 endif if move(m)=4 cell(CX,CY,CZ).left=0 cell(CX-1,CY,CZ).right=0 CX=CX-1 endif if move(m)=5 cell(CX,CY,CZ).below=0 cell(CX,CY,CZ-1).above=0 CZ=CZ-1 endif if move(m)=6 cell(CX,CY,CZ).above=0 cell(CX,CY,CZ+1).below=0 CZ=CZ+1 endif f=0 else f=1 if array count(posx(0))>1 CX=posx(array count(posx(0))-1) CY=posy(array count(posy(0))-1) CZ=posz(array count(posz(0))-1) endif Array delete element posx(0),array count(posx(0)) array delete element posy(0),array count(posy(0)) array delete element posz(0),array count(posz(0)) endif until array count(posx(0))=0 autocam off color backdrop rgb(0,0,0) for x=1 to WIDTH for y=1 to HEIGHT for z=1 to DEPTH if y=1 if cell(x,y,z).up=1 new=nobj() make object box new,10.0,10.0,1.0 position object new,5+(x-1)*10,5.0+(z-1)*10,0.0 gosub graphics endif endif if x=1 if cell(x,y,z).left=1 new=nobj() make object box new,1.0,10.0,10.0 position object new,0.0,5.0+(z-1)*10,5+(y-1)*10 gosub graphics endif endif if z=1 if cell(x,y,z).below=1 new=nobj() make object box new,10.0,1.0,10.0 position object new,(x-1)*10+5,0.0,(y-1)*10+5 gosub graphics endif endif if cell(x,y,z).above=1 new=nobj() make object box new,10.0,1.0,10.0 position object new,(x-1)*10+5,10.0*z,(y-1)*10+5 gosub graphics endif if cell(x,y,z).right=1 new=nobj() make object box new,1.0,10.0,10.0 position object new,x*10,5.0+(z-1)*10,y*10-5 gosub graphics endif if cell(x,y,z).down=1 new=nobj() make object box new,10.0,10.0,1.0 position object new,x*10-5,5.0+(z-1)*10,y*10 gosub graphics endif next z next y next x dist#=60.0 px#=(WIDTH/2)*10.0 py#=(DEPTH/2)*10.0 pz#=(HEIGHT/2)*10.0 hide mouse new=nobj() make object sphere new,3 position object new,5.0,5.0,5.0 color object new,rgb(0,255,0) ghost object on new new=nobj() make object sphere new,2 position object new,WIDTH*10-5.0,DEPTH*10-5.0,HEIGHT*10-5.0 color object new,rgb(255,0,0) ghost object on new new=nobj() make object cube new,3 position object new,WIDTH*10-5.0,DEPTH*10-5.0,HEIGHT*10-5.0 `color object new,rgb(255,0,0) ghost object on new position camera 5,5,5 move camera 4 automatic camera collision 0,.25,0 set camera range .24,3000 otime#=timer() ink rgb(255,255,255),0 Do remstart position mouse screen width()/2,screen height()/2 if mouseclick()=0 tmp=mousemovex() tmp=mousemovey() endif if mouseclick()=1 rotate camera camera angle x(0)+mousemovey()/3.0,camera angle y(0)+mousemovex()/3.0,0.0 endif if mouseclick()=2 inc dist#,mousemovey()/3.0 endif position camera px#,py#,pz# move camera -dist# remend center text screen width()/2,20,"Time: "+str$((timer()-otime#)/1000.0,2) rotate object new,object angle x(new)+.01,object angle y(new)+.003,0 xrotate camera 0,camera angle x(0)+mousemovey()/5.0 yrotate camera 0,camera angle y(0)+mousemovex()/5.0 if upkey()=1 move camera 0,.02 endif if downkey()=1 move camera 0,-.02 endif if leftkey()=1 yrotate camera 0,camera angle y(0)-90 move camera 0,.02 yrotate camera 0,camera angle y(0)+90 endif if rightkey()=1 yrotate camera 0,camera angle y(0)+90 move camera 0,.02 yrotate camera 0,camera angle y(0)-90 endif if sqrt((object position x(new)-camera position x(0))^2+(object position y(new)-camera position y(0))^2+(object position z(new)-camera position z(0))^2)<5.0 goto restart endif if inkey$()="r" then goto restart sync loop restart: for x=1 to OBJC delete object x next x set text font "Arial" set text size 42 final#=(timer()-otime#)/1000.0 ink rgb(255,255,255),0 center text screen width()/2,screen height()/2,"Level Complete! (Time="+str$(final#,2)+")" sync wait key goto top return graphics: `texture object new,1 n=rgb(rnd(128)+26,rnd(128)+26,rnd(128)+26) color object new,n set object emissive new,rgb(rgbr(n)-25,rgbg(n)-25,rgbb(n)-25) return function nobj() inc OBJC,1 endfunction OBJC