yay!
I think i got it
check this:
sync on : sync rate 25
set display mode 800,600,32
disable escapekey
dim nodes(128,128)
dim node_movex(9)
dim node_movez(9)
`N=1, Ne=2, E=3, Se=4, S=5, Sw=6, W=7, Nw=8
node_movex(1)=0 : node_movez(1)=0
node_movex(1)=0 : node_movez(1)=1
node_movex(2)=1 : node_movez(2)=1
node_movex(3)=1 : node_movez(3)=0
node_movex(4)=1 : node_movez(4)=-1
node_movex(5)=0 : node_movez(5)=-1
node_movex(6)=-1 : node_movez(6)=-1
node_movex(7)=-1 : node_movez(7)=0
node_movex(8)=-1 : node_movez(8)=1
clear_nodes()
random_nodes()
nodes(1,1)=0
nodes(2,1)=0
nodes(3,1)=0
nodes(4,1)=0
nodes(5,1)=0
nodes(6,1)=0
chk_x=1
chk_z=1
for z=0 to 127
for x=0 to 127
if nodes(x,z)=-1
obj=obj+1
if object exist(obj) then delete object obj
make object cube obj,10
position object obj,x*10,5,z*10
endif
next x
next z
`get image 1,0,0,512,512
gosub random_dest
ink rgb(255,0,0),0
make object cube 50000,10
do
set cursor 0,0
chk_d=safe_node(chk_x,chk_z)
if chk_d>0 and chk_d<10
chk_x=chk_x+node_movex(chk_d)
chk_z=chk_z+node_movez(chk_d)
else
gosub random_dest
endif
position object 50000,chk_x*10,5,chk_z*10
position camera (127*10)/2,700,(127*10)/2
point camera chk_x*10,5,chk_z*10
sync
if controlkey()=1 then end
loop
random_dest:
clean_nodes()
dest_x=rnd(124)+2
dest_z=rnd(124)+2
while nodes(dest_x,dest_z)<>0
dest_x=rnd(124)+2
dest_z=rnd(124)+2
endwhile
nodes(dest_x,dest_z)=10
xs=dest_x
xe=dest_x
zs=dest_z
ze=dest_z
while safe_node(chk_x,chk_z)=0
inc xe,1 : inc ze,1
dec xs,1 : dec zs,1
if xs<1 then xs=1
if zs<1 then zs=1
if xs>126 then xs=126
if zs>126 then zs=126
if xe<1 then xe=1
if ze<1 then ze=1
if xe>126 then xe=126
if ze>126 then ze=126
for xx=xs to xe
for zz=zs to ze
if nodes(xx,zz)=0
for compass=1 to 8
if safe_node(node_movex(compass)+xx,node_movez(compass)+zz)>0 and node_movez(compass)>-1 then nodes(xx,zz)=compass
next compass
endif
next zz
next xx
for zz=ze to zs step -1
for xx=xe to xs step -1
if nodes(xx,zz)=0
for compass=1 to 8
if safe_node(node_movex(compass)+xx,node_movez(compass)+zz)>0 and node_movex(compass)<1 then nodes(xx,zz)=compass
next compass
endif
next xx
next zz
endwhile
return
function clear_nodes()
for zz=0 to 127
for xx=0 to 127
nodes(xx,zz)=0
next xx
next zz
endfunction
function clean_nodes()
for zz=0 to 127
for xx=0 to 127
if nodes(xx,zz)>0 then nodes(xx,zz)=0
next xx
next zz
endfunction
function random_nodes()
for zz=0 to 127
for xx=0 to 127
if xx=0 or zz=0 or xx=127 or zz=127 or rnd(5)=1
nodes(xx,zz)=-1
obj=obj+1
if object exist(obj)=1 then delete object obj
make object cube obj,10
position object obj,xx*10,5,zz*10
endif
next xx
next zz
for zz=2 to 125
for xx=2 to 125
if nodes(xx,zz)=0 and nodes(xx+1,zz)=-1 and nodes(xx,zz+1)=-1 then nodes(xx,zz)=-1
if nodes(xx,zz)=0 and nodes(xx-1,zz)=-1 and nodes(xx,zz+1)=-1 then nodes(xx,zz)=-1
if nodes(xx,zz)=0 and nodes(xx+1,zz)=-1 and nodes(xx,zz-1)=-1 then nodes(xx,zz)=-1
if nodes(xx,zz)=0 and nodes(xx-1,zz)=-1 and nodes(xx,zz-1)=-1 then nodes(xx,zz)=-1
next xx
next zz
endfunction
function safe_node(xx,zz)
safenode=-1
if xx<128 and zz<128 and xx>-1 and zz>-1 then safenode=nodes(xx,zz)
endfunction safenode
It takes a while before you see something, because he creates a lot of boxes..
thanks Van-B
Do you need a complete FPS,3rdPS engine
?? Or a collision command libary?? well here it is:
http://forum.thegamecreators.com/?m=forum_view&t=38869&b=6&p=0