Getting started in Game Programming -- a simple algorithm

Started by
2 comments, last by javabean 23 years ago
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!
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^_^)
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
btw, deku''s method will make a parabola.

This topic is closed to new replies.

Advertisement