move_towards_point() is only responsible for starting the movement, it is not responsible for stopping the movement. You need to do it another way.
In your Create event, you should set a target coordinate and a stepping increment:
Code:
target_x = x;
target_y = y;
step_size = 4;
And in the Step event, it should make one unit of action towards reaching the target coordinate, if it isn't already there:
Code:
if (x != target_x || y != target_y) {
if (point_distance(x, y, target_x, target_y) <= step_size) {
x = target_x;
y = target_y;
} else {
mp_linear_step(target_x, target_y, step_size, false);
}
}
Then you simply set
target_x and
target_y and leave the code time to work. DO NOT use a blocking loop for this, and DO NOT be a start-to-end control freak again the way you did by attempting a
while loop. Set yourself a touch-and-go interface and give it leeway to run. You are only supposed to put in food and enter the time on a microwave oven. You are NOT supposed to be the one turning the dish or counting down the timer, the microwave oven is.
It's absolutely essential for rookies to get a grip on
the difference between loop-based repetition and step-based repetition. Anything that needs to repeat over time should NEVER be done using blocking loops (e.g.
for,
while,
do-until,
repeat). It needs to have bite-sized units of action in a repeating event that does it gradually for you, not a blocking loop that does everything at once.