hdist = distance_to_point(homex - 5, homey); hdir = point_direction(x, y, homex - 5, homey); speed = hdist / 5; direction = hdir;