i am making a RTS game, and i've been writing my code for the select unit
function selectUnit(obj, size)
x1 = object position x(1000)
x2 = object position x(obj)
z1 = object position z(1000)
z2 = object position z(obj)
x = object screen x(obj)
y = object screen y(obj)
distance = sqrt(((x1 - x2) * (x1 - x2)) + ((z1 - z2) * (z1 - z2)))
if distance < 5
intercept = 1
else
intercept = 0
endif
text 1,1,"1: " +str$(distance)
if intercept = 1
`////echos\\\\
text 40,1,"INTERCEPT "
`\\\\echos////
`If mouseclick, then select that object
if mouseclick() = 1
objectselected = 1
endif
endif
`if object is selected, then give player control
if objectselected = 1
`Make a box
line x-size,y-size,x+size,y-size : `Top Line
line x-size,y+size,x+size,y+size : `Bottom Line
line x+size,y+size,x+size,y-size : `Right Line
line x-size,y-size,x-size,y+size : `Left Line
if mouseclick() = 2 : objectselected = 0 : endif
endif
endfunction
and heres how i call it:
`//////////Unit control\\\\\\\\\\
unit_control:
selectUnit(1, 7)
selectUnit(2, 7)
return
`\\\\\\\\\\\\\\\\////////////////
the code seem to work fine when i look thru it, but when i click on an object ( i have two on the matrix, 1 and 2, and they are in two differnt places

) it selects both of them.
in the function 'size' is the radius of the imaginary circle that is around the circle, you have to click inside of that "circle" to select an object. obj is the object number.
if you need me to post the entire program i could, i only have one texture for the matrix. other than that, i have no media what so ever