In short, I am making a platform. I am not yet so old as to take Calculus yet, so I donโt know derivatives or integrals, but I know them. The desired behavior is that my character automatically jumps when there is a block on either side of it that is higher than the one on which it stands; for example, stairs. Thus, the player can simply hold left / right to climb the stairs, instead of spamming the jump key.
The problem is how I implemented jumping; I decided to go mario style and let the player hold the jump longer to jump higher. To do this, I have a โjumpโ variable that is added to player Yโs speed. The jump variable increases to the set value when the โjumpโ key is pressed, and decreases very quickly after pressing the โjumpโ key, but decreases less quickly while you hold hold down the jump key, thereby providing continuous acceleration while you hold the jump. It also makes a pleasant, smooth leap, rather than a sharp sharp acceleration.
So, to take into account the variable height of the stairs, I want to be able to accurately calculate what value the variable โjumpโ should get in order to accurately jump to the height of the stairs; preferably not more, not less, although a little more is permissible. Thus, the character can jump up steep or shallow flights of stairs without looking strange or slow.
There are essentially 5 variables in the game:
h -the height the character needs to jump to reach the stair top<br> j -the jump acceleration variable<br> v -the vertical velocity of the character<br> p -the vertical position of the character<br> d -initial vertical position of the player minus final position<br> Each timestep:<br> j -= 1.5; //the jump variable deceleration<br> v -= j; //the jump value influence on vertical speed<br> v *= 0.95; //friction on the vertical speed<br> v += 1; //gravity<br> p += v; //add the vertical speed to the vertical position<br> v-initial is known to be zero<br> v-final is known to be zero<br> p-initial is known<br> p-final is known<br> d is known to be p-initial minus p-final<br> j-final is known to be zero<br> j-initial is unknown<br>
Given all these facts, how can I make an equation that will be solved with j?
tl; dr How is the calculus?
Many thanks to the one who has done this so far and decides to fail this problem.
Edit: Here is a graph that I made from an example in Excel. 
I need an equation that allows me to find the value for A given for B. Since the jump variable decreases with time, the position value is not just a simple parabola.