Slope Help!

Hi, im making a game and i need some help in calculating some slope stuff.

i basically have two points, and i want to draw a ball travelling between the two. I used Y = mX + b…But when the X points start becoming similar this method goes to pot. It also has differnet speeds depending on where you shoot. Any help is appreciated, thanks.

Your question is not so clear, but let me give it a try!

Let’s assume your 2 points are given as (x0, y0) and (x1, y1).
The x and y distances are given as:
dx = x1 - x0;
dy = y1 - y0;

The total distance is (Pytagoras):
d = Math.sqrt(dx * dx + dy * dy);

So, to move with constant speed from (x0, y0) to (x1, y1) you have to
define a speed, e.g.
speed = 5;

Let’s assume your current position is given as x and y. For each time step, you apply
the following transform:
x = x + dx * speed / d;
y = y + dy * speed / d;