Little wrinkles in PICO-8's language implementation.
Overflow and Distance Calculations Edit
Pico-8's numbers are 16.16 fixed point, with a maximum integer value of 32767. This means it's quite easy to overflow numbers when squaring for distance calculations: 181^2==32761, almost overflowing, so even pixels two screens away will overflow a naive distance calculation. One workaround is to use different units like this:
function distk(x0,y0,x1,y1) local dx=x0/1000-x1/1000 local dy=y0/1000-y1/1000 local dsq=dx^2+dy^2 if dsq>0 then return sqrt(dsq) elseif dsq==0 then return 0 else --shouldn't happen return 32727 end end