Hi there. You could use Sparky's that is free and goes super...if you prefer to do it with code, there are several ways...take a look to this intersect collision. just execute this code with your level.
ink rgb(0,100,0),0
box 0,0,30,30
ink rgb(0,255,0),0
box 5,5,25,25
get image 1,0,0,30,30,1
sync on:autocam off:set global collision off
esn=1:pj=2
x as float :y as float :z as float :v as float
c#=0.2 `speed
x=10
y=10
z=10
set ambient light 100
` Loading level
load object "demoworld.x",esn
scale object esn,2800,2800,2800
position object 1,0,0,0
texture object 1,1:scale object texture 1,10,10
` Player object
make object sphere pj,150
v=object size(pj)/5
position object pj,x,y,z
hide object pj
do
set cursor 0,0
print screen fps()
x=object position x(pj):y=object position y(pj):z=object position z(pj)
` collision with X
if INTERSECT OBJECT(esn,x,y,z,x+v,y,z)>0 then x=x-(v-INTERSECT OBJECT(esn,x,y,z,x+v,y,z))
if INTERSECT OBJECT(esn,x,y,z,x-v,y,z)>0 then x=x+(v-INTERSECT OBJECT(esn,x,y,z,x-v,y,z))
` collision with Z
if INTERSECT OBJECT(esn,x,y,z,x,y,z+v)>0 then z=z-(v-INTERSECT OBJECT(esn,x,y,z,x,y,z+v))
if INTERSECT OBJECT(esn,x,y,z,x,y,z-v)>0 then z=z+(v-INTERSECT OBJECT(esn,x,y,z,x,y,z-v))
`collision with Y
if INTERSECT OBJECT(esn,x,y,z,x,y-v,z)>0 then y=y+(v-INTERSECT OBJECT(esn,x,y,z,x,y-v,z))/3
`Gravity
if INTERSECT OBJECT(esn,x,y,z,x,y-v,z)=0 then gravedad#=2 else gravedad#=1
`camera movements
gr=wrapvalue(gr+mousemovex()/2)
gr2=wrapvalue(gr2+mousemovey()/2)
rotate camera gr2,0,0
yrotate camera gr
`camera rotation limits
if gr2<=290 and gr2>180 then gr2=290
if gr2>=70 and gr2<180 then gr2=70
`player movements
if upkey()=1 THEN x=NEWXVALUE(x,gr,c#):if upkey()=1 then z=NEWZVALUE(z,gr,c#)
if downkey()=1 THEN x=NEWXVALUE(x,gr,-c#):if downkey()=1 then z=NEWZVALUE(z,gr,-c#)
`slide left
if leftkey()=1 THEN x=NEWXVALUE(x,gr-90,c#):if leftkey()=1 then z=NEWZVALUE(z,gr-90,c#)
`slide right
if rightkey()=1 THEN x=NEWXVALUE(x,gr-90,-c#):if rightkey()=1 then z=NEWZVALUE(z,gr-90,-c#)
`camera and player position
position object pj, x, y-gravedad#, z
position camera x,22+y-gravedad#,z
sync
loop
I'm not a grumpy grandpa