I am having trouble with calculating coordinates for my game. I have a line that has a fixed endpoint. I want this line's start point to get closer to the endpoint with a constant speed. But that point just shoots off the screen. Can you help me.

if fleets[i][0][0] != fleets[i][1][0] and fleets[i][0][1] != fleets[i][1][1]: #this here reads coordinates into proper variables. (xo,yo) is the starting point #(x1;y1) is the endpoint x0 = float(fleets[i][0][0]) y0 = float(fleets[i][0][1]) x1 = float(fleets[i][1][0]) y1 = float(fleets[i][1][1]) #here I calculate the total distance between these points d2 = (x1 - x0)*(x1 - x0) + (y1 - y0)*(y1 - y0) d = math.sqrt(d2) #here is the distance that has passed since the last main function cycle d3 = 1 * (elapsedTime/1000) #I calculate how many percentages of the total distance I travelled since the last main function cycle p = (d3 / d2) * 100 #if both x'es are equal then there is no point in calculating the change in x if x0 == x1: x = x0 #if x0 is bigger than x1, i calculate the amount travelled along the x axis and substract that from the x0, getting my new x0 if x0 > x1: x_p1 = (x0 - x1)/100 x_p2 = x_p1 * p x = x0 - x_p2 #if x0 is smaller than x1, i ,again, calculate the distance travelled along x-axis, but then i add the travelled distance to the starting y0 to get my new x0 if x0 < x1: x_p1 = (x1 - x0)/100 x_p2 = x_p1 * p x = x0 + x_p2 #same happens here as happened with x'es if y0 == y1: y = y0 if y0 > y1: y_p1 = (y0 - y1)/100 y_p2 = y_p1 * p y = y0 - y_p2 if x0 < x1: y_p1 = (y1 - y0)/100 y_p2 = y_p1 * p y = y0 + y_p2 #the x0 and y0 that we started with at the beginning of this calculation are now replaced with the new coordinates fleets[i][0][0] = x fleets[i][0][1] = y #when I created this travelling line, I calculated the time it should travel #here already travelled time is updated fleets[i][3] = fleets[i][3] + (elapsedTime/1000)

**Edited by Ironmaggot, 12 December 2013 - 03:38 PM.**