A couple of problems here:
1-You are using integers for checking the object positions
2-You are only checking the position in "X"
Change it to this and it might help:
sync on : sync rate 60
autocam off
color backdrop 0
randomize 2
SX=screen width()/2
SY= screen height()/2
AI start
make object sphere 1, 2
make object cone 2, 5
xrotate object 2, 90
fix object pivot 2
position object 2,0,2.5 , 40
AI add enemy 2
ai set entity speed 2, 120
for x = 3 to 33
make object box x, rnd(10)+5, 5 + RND(10)/10, RND(10) + 5
position object x, rnd(100) - 50, 2.5, rnd(100) - 50
yrotate object x, rnd(360)
color object x,rgb(rnd(255),rnd(255),rnd(255))
AI add static obstacle x
next i
AI complete obstacles
position camera 0, 100, -30
point camera 0,0,0
do
pos1x# = object position x(1)
pos1z# = object position z(1)
pos2x# = object position x(2)
pos2z# = object position z(2)
print pos1
print pos2
pick screen mousex(), mousey(), 1000
vx# = get pick vector x()
vy# = get pick vector y()
vz# = get pick vector z()
dy# = - camera position y()/vy#
vx# = vx#*dy# + camera position x()
vz# = vz#*dy# + camera position z()
position object 1 , vx#, 1, vz#
d#=sqrt((pos1x#-pos2x#)^2+(pos1z#-pos2z#)^2)
if d#<4 then gosub Lose
if mouseclick() = 1 then AI entity go to position 2, object position x(1),object position z(1)
ai update
sync
loop
Lose:
set text size 50
repeat
cls
Center text SX,SY,"YOU LOSE"
sync
until leftkey() = 1
set text size 20
return
