How to make the ball take one straight line and not two paths?
The question is: how do I make the ball move to my mouse position in one straight path?
Usually, the ball moves in one diagonal path and then one horizontal or vertical line to reach my mouse position. How do I make it so it only takes one path instead of two?
So, you'll calculate the distance and round it to a whole number. Then, find out the ratio of X distance to whole distance, and Y distance to whole distance. Loop whole distance times, and for each iteration, move by their respective ratios. That likely made no sense, so I'll put it into pseudocode form:
dist = distance between current position and target position xRatio = (target x - current x) / dist yRatio = (target y - current y) / dist repeat dist amount of times: move right by xRatio move down by yRatio wait a little bit