randomize timer() sync on hide mouse cls rgb(0,127,0) generate_noise(100.0,0,255,0) set current bitmap 0 get image 1,0,0,256,256 cls 0 make matrix 1,10000,10000,50,50 randomize matrix 1,100 set matrix 1,1,0,1,1,1,1,1 prepare matrix texture 1,1,1,1 autocam off make object box 6,30,15,40 color object 6,rgb(10,10,200) position object 6,object position x(6)+5000,20,object position z(6)+5000 set object collision to boxes 6 make object sphere 7,1 position object 7,object position x(6),object position y(6),object position z(6) make mesh from object 1,7 add limb 6,1,1 offset limb 6,1,0,-20,0 delete object 7 for i=2 to 5 make object cube i,5 color object i,0 set object collision to boxes i next i position object 2,-30,10,-30 position object 3,30,10,-30 position object 4,30,10,30 position object 5,-30,10,30 position camera 5000,500,5000 set camera range 1,10000 if fog available()=1 fog on fog color rgb(127,127,127) fog distance 1000 color backdrop rgb(127,127,127) endif set matrix 1,1,1,1,1,1,1,1 do hx#=(object size x(6)/2) hy#=(object size y(6)/2) hz#=(object size z(6)/2) `position back left feeler pos object(2,6) set object to object orientation 2,6 turn left(2,90) move object 2,hx# turn left(2,90) move object 2,hz# `position back right feeler pos object(3,6) set object to object orientation 3,6 turn right(3,90) move object 3,hx# turn right(3,90) move object 3,hz# `position front left feeler pos object(5,6) set object to object orientation 5,6 turn left(5,90) move object 5,hx# turn right(5,90) move object 5,hz# `position front right feeler pos object(4,6) set object to object orientation 4,6 turn right(4,90) move object 4,hx# turn left(4,90) move object 4,hz# max=25 angle#=wrapvalue(angle#+mousemovex()) set camera to follow object position x(6),object position y(6),object position z(6),angle#,100,object position y(6)+30,1,1 if upkey()=1 inc speed,1 if speed>=max speed=max endif endif if downkey()=1 dec speed,1 if speed<=5 speed=5 endif endif if rightkey()=1 position matrix 1,matrix position x(1)-5,matrix position y(1),matrix position z(1) update matrix 1 inc xposition,5 if xposition>=200 position matrix 1,matrix position x(1)+200,matrix position y(1),matrix position z(1) shift matrix left 1 xposition=0 endif endif if leftkey()=1 position matrix 1,matrix position x(1)+5,matrix position y(1),matrix position z(1) update matrix 1 dec xposition,5 if xposition<=0 position matrix 1,matrix position x(1)-200,matrix position y(1),matrix position z(1) shift matrix right 1 xposition=200 endif endif position matrix 1,matrix position x(1),matrix position y(1),matrix position z(1)-speed update matrix 1 inc position,speed if position>=200 position matrix 1,matrix position x(1),matrix position y(1),matrix position z(1)+position shift matrix up 1 position=0 endif for i=2 to 5 position object i,object position x(i),get ground height(1,object position x(i)+xposition,object position z(i)+position),object position z(i) next i placeobj(6,2,3,4,5) `if object collision(6,0)<>1 position object 6,object position x(6),get ground height(1,object position x(6)+xposition,object position z(6)+position)+9,object position z(6) `grav(6,1) `endif text 0,0,str$(object position z(6)) text 0,20,str$(object angle y(6)) text 0,40,str$(object angle z(6)) text 0,60,str$(object position y(5)) y#=get ground height(1,object position x(6),object position z(6)) text 0,80,str$(y#) sync loop function grav(obj,acc) if object position y(obj)>get ground height(1,object position x(obj),object position z(obj))+(object size y(obj)/2) else position object obj,object position x(obj),get ground height(1,object position x(obj),object position z(obj)),object position z(obj) endif endfunction function calcx#(obj1,obj2) ydiff#=object position y(obj1)-object position y(obj2) zdiff#=object position z(obj1)-object position z(obj2) if zdiff#=0 then zdiff#=1 theta#=atan(ydiff#/zdiff#) theta#=wrapvalue(theta#) endfunction theta# function calcz#(obj1,obj2) ydiff#=object position y(obj1)-object position y(obj2) xdiff#=object position x(obj1)-object position x(obj2) if xdiff#=0 then xdiff#=1 theta#=atan(ydiff#/xdiff#) theta#=wrapvalue(theta#) endfunction theta# function placeobj(obj,p1,p2,p3,p4) rotate object obj,0,0,0 pitch object up obj,object angle x(obj)+calcx#(p1,p4) roll object right obj,object angle z(obj)-calcz#(p1,p2) endfunction function pos object(obj1,obj2) position object obj1,object position x(obj2),object position y(obj2),object position z(obj2) endfunction function turn right(obj,val) yrotate object obj,wrapvalue(object angle y(obj)+val) endfunction function turn left(obj,val) yrotate object obj,wrapvalue(object angle y(obj)-val) endfunction function strafe left(obj,val) turn left(obj,90) move object obj,val turn right(obj,90) endfunction function strafe right(obj,val) turn right(obj,90) move object obj,val turn left(obj,90) endfunction function generate_noise(level#,r,g,b) count#=screen width()*screen height()*(level#/100) for i=1 to count# ink rgb(rnd(r),rnd(g),rnd(b)),0 dot rnd(screen width()),rnd(screen height()) next i endfunction