Public Group

# jump algorithm

## Recommended Posts

I liked the  video

##### Share on other sites

well I have stubbed out some math code. I got this from the video. is Vo the x velocity or the y velocity?

#include<iostream>

using namespace std;

int main()
{
float g = -1.0f;
float Vo = 5.0f;
float time = 0.0f;
float Po = 0.0f;
float positionY = 0.0f;

cout << "Time: ";
cin >> time;
cout << endl;

for (int t = 0; t < time; t++)
{
positionY = 0.5f*g*(t*t) + Vo * t + Po;
cout << positionY << endl;
}

system("pause");
return 0;
}

Edited by phil67rpg

##### Share on other sites

Vo is just the velocity at time t=0. It should be a 2d vector. Po is position at t=0. It should also be a vector.

##### Share on other sites

well I have done some research and I have found out that Vo is the initial velocity in the x direction. is this assumption correct?

##### Share on other sites
8 minutes ago, phil67rpg said:

well I have done some research and I have found out that Vo is the initial velocity in the x direction. is this assumption correct?

No. It's the initial velocity, period. Velocity is always a vector, comprising direction and magnitude. Maybe it's only in the direction of x, but since you're trying to jump it will certainly have a vertical component as well.

##### Share on other sites

ok cool, I have taken linear algebra class, I will brush  up on my vectors. thanks

##### Share on other sites
7 hours ago, phil67rpg said:

well I have stubbed out some math code. I got this from the video. is Vo the x velocity or the y velocity?

Speaking specifically about that code then Vo is the initial Y velocity and Po is the initial Y position. No part of that code attempts to calculate anything for X. However since the horizontal is not affected by gravity (and not parabolic) then X is likely just a simple linear function of 't'.

##### Share on other sites
24 minutes ago, dmatter said:

No part of that code attempts to calculate anything for X

so how would I calculate for X

##### Share on other sites
1 minute ago, phil67rpg said:

so how would I calculate for X

If X is simply linear:  x = velocityX * t + initialX

Obviously if your x velocity is 1 and you start at the origin 0 then that simplifies to just x = t

cool thanks

##### Share on other sites
This topic is now closed to further replies.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 11
• 23
• 38
• 16
• 75