You actually want:
while x > 10 do x -= 10
while x < 0 do x += 10
while y > 10 do y -= 10
while y < 0 do y += 10
What you have will discard some position information every time it wraps. Also, it won't correctly handle changes in position per frame that are larger than 10.