This is a completely random 3d maze you have to escape!
Also has an overhead map view and a sky-sphere.
All in 20 lines!
remstart
My entry for 20 line compo
Random 3D maze generator which you have to escape using cursor keys
Also utilising 2nd overhead camera map view and a basic scrolling sky-sphere!
Variables you can play with:
s = size of maze, i.e. 5 will generate a 5 by 5 maze. High numbers = more complex maze
w = corridor unit width
h = height of walls
I ran out of lines but with a few more lines it is easy to improve no-end:
1) Need to light sky-sphere correctly, currently too dark
2) Need to merge long walls into one plain as auto-collision gets stuck sometimes where walls join.
It will also seriously cut number of 3d objects, improving frame rate drastically
Compilation tips:
Do not run using 'Fullscreen Exclusive Mode' as this is locked to monitor refresh rate (in my case 60fps!) and
makes everything very sluggish.
Best to click on settings button in editor, click on 'Pick' button next to 'Windowed' option and select a decent
resolution you are happy with, then select 'Windowed - Full Screen'.
remend
s=10 : w=100 : h=70 : sync on : hide mouse
randomize val(left$(get time$(),2)+mid$(get time$(),4)+mid$(get time$(),5)+right$(get time$(),2)) : x=3 : y=3 : dim d(4,2) : d(1,1)=-1
d(2,2)=1 : d(3,1)=1 : d(4,2)=-1 : dim maze(s*2+3,s*2+3) : for f=1 to s*2+3
maze(f,1)=3 : maze(f,s*2+3)=3 : maze(s*2+3,f)=3 : maze(1,f)=3 : next f
m: : for r=1 to 10 : r1=rnd(3)+1 : r2=rnd(3)+1 : t1=d(r1,1)
t2=d(r1,2) : d(r1,1)=d(r2,1) : d(r1,2)=d(r2,2) : d(r2,1)=t1 : d(r2,2)=t2
next r : for f=1 to 4 : if maze(x+(2*d(f,1)),y+(2*d(f,2)))=0 : maze(x,y)=1 : maze(x+d(f,1),y+d(f,2))=1
x=x+(2*d(f,1)) : y=y+(2*d(f,2)) : inc z : if z > zm : zm=z
x1=x : y1=y : endif : goto m : endif
next f : for f=1 to 4 : if maze(x+d(f,1),y+d(f,2))=1 : maze(x,y)=2 : maze(x+d(f,1),y+d(f,2))=2
x=x+(2*d(f,1)) : y=y+(2*d(f,2)) : dec z : goto m : endif
next f : maze(2,3)=3 : load image "brick.jpg",1 : load image "floor.jpg",2 : load image "clouds.jpg",3
o=9 : make object sphere 3,-3000 : texture object 3,3 : scale object texture 3,5,5
make object plain 1,(s+2)*w,(s+2)*w : texture object 1,2 : scale object texture 1,s+2,s+2 : xrotate object 1,90 : position object 1,(s+2)*w/2,0,(s+2)*w/2
make object sphere 2,w/4,10,10 : color object 2,rgb(0,255,0) : position object 2,y1*w/2,0,(s-((x1-1)/2)+1)*w+(w/2) : for f=1 to s+1 : for g=1 to s
if maze(f*2,g*2+1)=0 then inc o : make object plain o,w,h : position object o,g*w+(w/2),h/2,(s-f+2)*w : texture object o,1
if maze(g*2+1,f*2)=0 then inc o : make object plain o,w,h : position object o,f*w,h/2,(s-g+1)*w+(w/2) : texture object o,1 : yrotate object o,90
next g : next f : automatic camera collision 0,5,0 : position camera y1*w/2,h/2,(s-((x1-1)/2)+1)*w+(w/2) : make camera 2
set camera view 2,0,0,200,200 : position camera 2,camera position x(),h*10,camera position z() : point camera 2,camera position x(),0,camera position z() : do : control camera using arrowkeys 0,1.5,1.5
position camera 2,camera position x(),h*6,camera position z() : position object 3,camera position x(),camera position y(),camera position z() : yrotate object 3,object angle y(3)+0.01 : sync : loop
Source code and images in zip file (only 51Kb) below:
http://www.dbhut.com/maze.zipI love it when a plan comes together