Euclidean distante = sqrt (dx * dx + dy * dy), for your distance you need to define dx as min(abs(x2-x1),screenwidth-abs(x2-x1)) same thing for dy.
Usualy the direction vector is Pt - Pm (Position vector target - Position vector missile). In your case you can define Direction vector x component as
if (x2-x1)>=0
DirX= min(x2-x1 , width -(x2-x1))
else
DirX= max(x2-x1 , width + (x2-x1))
In the same way (using HEIGTH) you can DirY.