Tak na szybko.
GML
cx = room_width / 2;
cy = room_height / 2;
tx = mouse_x;
ty = mouse_y;
dir = point_direction( cx, cy, tx, ty );
dis = point_distance( cx, cy, tx, ty );
draw_sprite( sprite, 0,
cx + max( -cx, min( cx, lengthdir_x( dis, dir ) ) ),
cy + max( -cy, min(cy, lengthdir_y( dis, dir ) ) ),
);