I'm working on a simpel path for a target in a game. I want the target to diagonally through the hypotenuse since I know the legs. The target as the coordinates of point A, being the start point, and point B, the end point. The target also has a speed on which it should move n amount of pixels per frame. My simple formula is pretty much newXCoordinate=(legX/hypotenuse)*speed and newYCoordinate = (legY/hypotenuse)*speed.

In reality it move like the yellow like shown in the image attached. I'm guessing it's because each pixel movement is calculated as integers and not float number. So the target can't move in decimal pixels but only whole pixels at a time.

An alternative would be to calculate with memory. Example, for each 2 x-axis pixels the target move, it also moves 3 pixel in the y-axis, but every other time the target moves in the x-axis it needs to move 4 pixels in the y-axis. Or does anyone have a better idea?