i wouldnt reccomend using solely x for distance. i would get used to using
(x2 - x1)^2 + (y2 - y1)^2 = distance^2
distance = sqrt((x2 - x1)^2 + (y2 - y1)^2)
even if you didnt know about abs(), you coulda done some simple math to figure it out.
if you take a number and raise it to the power of 2, if its negative it becomes positive (negative * negative = positive). then all you have to do is take the radical (square root) of that and you end up with your original number, but positive.