gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Jumping around

#54403 - 3dfx - Mon Sep 19, 2005 1:01 am

How in the world would I go about for coding a routine that enables my sprite to jump? Thanks

#54418 - tepples - Mon Sep 19, 2005 4:14 am

First implement Newtonian kinematics: Keep (fixed-point) variables for the horizontal and vertical components of velocity, and add those to the sprite's displacement/position each frame. Also each frame, add a small constant to the vertical component of velocity to represent gravity.

Then to make your character jump, just set the vertical component of velocity upward.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.