Jumping in 2D java game | SoloLearn: Learn to code for FREE!


Jumping in 2D java game

Im having trouble with managing jumping and gravity in a 2D game. Whats is the most basic formula I can use so I create a code around it? The kind of jumping im looking for resembles that of the mario NES games

1/29/2018 3:15:29 PM


2 Answers

New Answer


time of going up must be equal to time of getting down //in physics (ideal conditions) t=u/g //where u is vel. in dirn opp. to gravity(in ms^-1) & g=9.8ms^-2[units of same system] //h will be u^2/2g //but in real world , this formula fails for calculating exact value ... for game also , u must not use that ... ur wish☺


Use momentum. When you jump, momentum goes up. Gravity brings it down slightly every tick unless on ground or terminal velocity. Maybe by multiplication and momentum being a float or double.