You’ll have to refer to the documentation for how to do it.
Basically you’d access the runtime object, find the list of object types from that, then a list of each instance for each type. Then you can either compare the x y or calculate the distance with:
var dx=x1-x0, dy=y1-y0
Math.sqrt(dx*dx+dy*dy)
Or maybe the sdk has a distance function you can use. Anyways that’s the gist of it.