i think you can do this:

let frac(x) be the fractional part of x (for example if x = 6.25, frac(x) = 0.25). this can also be calculated as x - floor(x).

assign all your coordinates on your "screen" (world) values between 0 and 1. then define:

(a,b) + (c,d) = (frac(a+c), frac(b+d)).

if you want "on-screen" distances, apply frac before you calculate the distance. if you want "off-screen distances" (like you shoot at the right end of the screen, and it hits something on the left side) don't apply frac at all (note: this means two objects can be "multiple distances away from each other"...could get confusing).

using a map of your "world" to a sphere will identify all 4 corners (and edges) as the same point...what i think you want to do to achieve left/right wrap-around and up/down wrap-around is to map your world to a torus (doughnut). while you could parameterize such a surface in 2 variables like so:

x = Rcos(s) + rcos(s)cos(t)

y = Rsin(s) + rsin(s)cos(t)

z = rsin(t)

and calculate distance using arc-length, i think the "frac" approach above would be easier to implement (basically, we are identifying neighboring worlds (off-screen) with the one you can see (on-screen)).