+ 1

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

29th Jan 2018, 3:15 PM
Jorge
Jorge - avatar
2 Answers
+ 13
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â˜ș
29th Jan 2018, 3:41 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 2
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.
29th Jan 2018, 3:36 PM
Jacob Pembleton
Jacob Pembleton - avatar