That only works if you want the characters to move at the same speed
use x, y to track object location like objX, objY
then use dx to track object "speeds" along x axis and dy to track object speed on y axis (per frame or drawing loop)
dx, dy = change of x, y on respective axis like objDX, objDY
Use the x, y for drawing obj, and dx, dy for updating the location ie
x = x + dx
y = y + dy
so
objX = objX + objDX
objY = objY = objDY
then check if x, y still inbounds correcting x, y and dx, dy when not.