I'm basing this from what you said about your knowledge of maths.
I'm pretty sure there's a problem with what you have too, and I wouldn't mind some proof reading/analysing from someone else - maybe Cozzie if he comes about.
Basically, the problem I see is that your values are the coordinates of the point you want to jump to and not the values that they should be which are the values of the increase in x and y from the current point to the destination point. This might not look like an issue, but I'll explain why it is.
distance = Math.sqrt(x_plus * x_plus + y_plus * y_plus).round Regarding the formula:
What it's actually doing is finding the length of the given vector using what is more commonly known as the Pythagoras' theorem. If the jump is +10 (pixels) along the x-axis and +3 pixels down the y-axis (based on screen coordinate system where (0, 0) is the top left of the screen), the length of the line starting from (0, 0) to (10, 3) - it's irrelevant on where the start coordinates are as long as the second set of coordinates has an x value that is +10 the first and the y value that is +3 the first - can be calculated based on triangle geometry.
Essentially, what VX does is apply the formula to a vector that starts at the origin (0, 0) (referred to as O from now on), to the "point" (referred to as P) that is based on the jump values of x and y. Thus, if we jump 10x and 5y the point P used is (10, 5). And because that line OP can be thought of as the hypotenuse of a triangle in relation to the coordinate grid, we can apply Pythagoras' theorem to find the distance of the line - or how far we're moving.
I drew up an image in paint to help illustrate it:
Spoiler for :
The orange line represents the side of the triangle with length x, the red line represents the side with length y and the green line is the hypotenuse of the triangle which is also the vector OP.
We can see that the orange line has length 10 and the red line length 3.
Pythagoras tells us that the length of the hypotenuse of a right angled triangle is the square root of x
2 + y
2 , which is what the distance formula is.
Now, that formula used to calculate distance is always based on this idea; that we are calculating the distance based on a line from O to point P (where P is (x jump, y jump)).
However, what you have is this:
distance = Math.sqrt(dest_x * dest_x + dest_y * dest_y).round
These aren't actually the same thing. What you're finding with this formula is the length of the vector from O to point Q, where Q is an actual position on your screen - in other words, the distance the sprite will move will not be what you expect. What you wanted to do, though, is find the distance you need to go to get from P (where you are) to Q (where you want to go).
What you need to do is find the vector from point P to point Q. We can do this by subtracting the x and y of P from Q.
For example, P(5, 10) and Q(7, 15)
vector PQ = ((7 - 5), (15-10)) = (2, 5)
As an FYI, this vector PQ(2, 5) can be read as: "the x increases by 2 and the y increases by 5".
A definition would be (Wiki): "A vector is what is needed to "carry" the point A to the point B". And that's what we have there. Point Q is 2x's and 5y's from point P.
The two values, 2 and 5, are what is needed to go into the formula to calculate the distance of the jump.
I would like a second opinion on that, but I'm sure I have that right. It's been a while since I did anything involving this level of mathematics.
Moving on, what I've been looking into for you is polynomial curves. VX, as Cozzie described earlier, bases the jump arc on a circle - this I only learned in that post too. However, because you want to introduce a height, I figured it might be worth looking into. We could, on the other hand, reverse engineer (for lack of words) a circle that has the same properties including your height limitations and then calculate the arc based on that.
Regarding the curves, what you would do is create a third point, point R, based on the two other points P (the start point) and Q (the end point) and create a formula that would calculate the location of the next point to move to in our curve.
I drew another picture to show this:
Point R has an x value that is halfway between PQ and a y value that is P(y) + height. Then, with 3 points, we can create a quadratic equation that will give us the formula we need to plug values into to find the next drawing location for the sprite to move to until it reaches the end point Q.
Where I'm having issues, though, is that I'm not sure what to do when it comes to points with different y values - I've only ever done curves that intersect the x-axis where y = 0. If someone has a clue, that'd be appreciated. If not, I'll keep trying to figure it out/seek some expert help and get back with that.
Failing that, I'll see about reverse engineering the circle to fit it.