##### How to make the ball take one straight line and not two paths?

### If you click on the grey background in the program, the ball will move to your mouse position.

**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?

How familiar are you with trigonometry?

@SixBeeps Not really

@HackingGo306 Do you know the distance formula at least?

@SixBeeps

var dist = function(x1,y1,x2,y2){

var x_diff = x1 -x2

var y_diff = y1 - y2

distance = sqrt((x_diff · x_diff) + (y_diff · y_diff))

return distance

};

Are you talking about this?

@HackingGo306 Yeah.

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:

@SixBeeps

Thanks!