Someone had asked for this about a week ago, and I don't recall them get a satisfactory response.
If they did, post a link to the response so I can tweak this code; it's still very rough.
. . . As long as you click the middle of the object, you're good to go.
Once it gets closer to the camera, the further edges are not clickable, but probably 50-70% of the middle will be.
Use the arrow keys to move the object.
+ Code Snippet`(c) 2003 J.C. Crawford
`http://jcprogs.50megs.com
`eighttruths@yahoo.com
` Please note a credit for any use of the code in any program where it has been used.
`Thank you.
sync on
make object sphere 2, 100
position camera 0,100,500
point camera 0,0,0
do
a=mousex()
b=mousey()
osx=object screen x(2)
osy=object screen y(2)
set cursor object screen x(2),object screen y(2)
print object screen x(2)
set cursor object screen x(2),object screen y(2)+15
print object screen y(2)
if downkey()=1 then move object 2, -2
if upkey()=1 then move object 2,2
if rightkey()=1 then turn object right 2,2
if leftkey()=1 then turn object left 2,-2
tag=0
`Calculate the onscreen size, roughly, of the 3D.
r=(object position z(2))
if r>0
r=sqrt(r)
ss=object size(2)+r
tag=1
endif
if r<0
r=sqrt(abs(r))
ss=object size(2)-r
tag=1
endif
`A check to avoid a div by zero error.
if tag=0 then ss=object size(2)
`Done with that.
`Allows you to still have something click on when the obj becomes
`a dot.
if ss<1 then ss=1
`ZONECLICKED
`Basically, it's screen size - the size of the object,
`With an earlier tweak for distance.
`You will have to adjust this if you get frisky about moving the camera.
if zoneclicked(osx-ss,osy-ss,osx+ss,osy+ss)=1
ink rgb(255,0,rnd(155)),0
set cursor 180,180
print "Clicked the left button!"
endif
print ss
print object position z(2)
print r
sync
loop
function zoneclicked(x1,y1,x2,y2)
clicked=0
if mousex()>x1 and mousex()<x2
if mousey()>y1 and mousey()<y2
if mouseclick()=1
clicked=1
endif
endif
endif
endfunction clicked