Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

javabean

Getting started in Game Programming -- a simple algorithm

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

Hi all, I am new into game programming and wondering where can I find some simple standard algorithm on the web? specifically I am looking for a simple algorithm which can calculate the path of a moving jumping object -- like an inverse "U" shape movement. Any help is much appreciated! Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Have it set the character''s vertical velocity to -10 (go up 10 pixels at a time), make a gravity value like 5 or something and add that to the velocity every frame. That way, when you jump, you go up really fast, then the gravity pulls you back down so your velocity will be like -10, -5, 0, 5, 10, 15, etc. until you hit the ground. The 5 and 10 are just random numbers for the demonstration, so you''ll have to experiment around until you get the speed right.
Oh, and you should use floats (or fixed point cause it''s faster) so you can have sub-pixel movement (else you''ll only be able to move in 8 directions).



-Deku-chan

DK Art (my site, which has little programming-related stuff on it, but you should go anyway^_^)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
you''re talking about a parabola. The formula is: ax^2 + bx + c since you want an upsidedown one you want a to be negative. Get a hold of a math book, algebra II I think and it will tell you some more important stuff. So you''ll want a formula that you can plug time and velocity into, and from time and velocity calculate x, and from there calculate y, and then you have the x,y

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!