Jump to content
  • Advertisement
Sign in to follow this  
BS-VecVidjeno

SDL-platform game gravity

This topic is 3991 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

Hello all, ive been making a platform type game in SDL and so far it's been going great, i made the acceleration the long jump the one way tiles big scrolable map... but i have hit this snag with the gravity... I have used the simple gravity of downvard, and when i jump it goes a some distance up, and when in combined with the arow keys (left,right) it creates the illusion off jumping LEFT or RIGHT, the thing is that that means that if I release my key (left or right) the player would stop!!!! and just fall down!!! caouse there is no inercia (god, my spelling is crap). EVEN WORSE is when i'm flying left and i change my mind and press right the player (while still being in the jump) just drifts away in the right direction!!!!!! So i'm asking for some help with the gravity? and inercia... so that when i jump left the forcec of inercia pull's it to the left, and that if i press right at THAT flying point the player would gradulay slow down giving me some controll over my player?

Share this post


Link to post
Share on other sites
Advertisement
How much physics have you taken/are comfortable with? Inertia is really just momemtum, and momentum is mass times velocity; when you jump, you could retain their horizontal velocity, and then they would "drift" in the jump. If they pressed it the other way, you could either take into account acceleration or fudge it by simply subtracting the same amount from velocity.

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.

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!