Jump to content
  • Advertisement
phil67rpg

jump algorithm

Recommended Posts

Advertisement

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!