Jump to content
  • Advertisement
Sign in to follow this  
artin

Please i need help ....

This topic is 3706 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i am having troubles making the player jump in the right way.... can someone help me with simple code for that ..... and please can anyone explain to me how can i add the gravity to my players ....

Share this post


Link to post
Share on other sites
Advertisement
It's hard to give specific advice since your question is rather vague.
You say your player's not jumping in the right way, well, he should go up then down again.

If you want some equations for this motion then look into the SUVAT kinematic equations, these two might be of interest:

s = u + at
s = ut + 1/2at2


You can transform that into your language of choice. I can't give you any real code because I don't know what language you're using but some pseudo code might suffice:

playerX = initialHorizontalSpeed + gravity * time
playerY = initialVerticalSpeed * time + 0.5 * gravity * time^2


Where initialHorizontalSpeed and initialVerticalSpeed are the 'jump' vector components. The larger you set the vertical speed, the higher your player will jump.

[Edited by - dmatter on April 1, 2008 9:55:06 PM]

Share this post


Link to post
Share on other sites
sorry for that .....
i'm using borlandc++ 6 and all i need is simple code to make my player jump ...
please help me

Share this post


Link to post
Share on other sites
When the user presses jump, you should add some value (depends on your game) to the player's Y component of velocity. That's really all there is to it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!