GMLJump math

A

Arturo Rojas

Guest
Maybe someone with better maths skills than mine can help me figure this out.

Basically, if I know my character sprite is 32x32 and my floor tiles are also 32x32, knowing that I want my jump duration to last exactly 1 sec (0.5 s to reach peak height) and I want to be able to jump 64 pixel high (basically to tiles). How much vertical speed & gravity do I have to apply assuming its initial vertical velocity is 0 (grounded)?

TheouAegis

Member
(2 * 64 / 30²)

vspeed should be -1095/256
(-73/512 * 30)

A

Arturo Rojas

Guest
I figured it out.
(2 * 64 / 30²)

vspeed should be -1095/256
(-73/512 * 30)
Actually what I ended up was:
h = 64 // height of the jump
Th = 30 // time to reach the peak of the jump expressed in frames. based on a 60 fps setting

for gravity
g = (2*h) / (Th*Th) // ..or Th²

apply gravity to vertical speed

vSpeed += g

and for the jump

key_jump = keyboard_check(vk_space);
if (place_meeting(x, y + 1, objFloor) && key_jump) {
vSpeed = -2*h / Th;
}

TheouAegis

Member
Whatever. As long as it works. I wasn't even sure if my numbers were right. I was just trying to use Google to help me figure it out. If your algorithm works too, then that means I figured it out after all and I'm happy with that. It is working correctly for you right?

Edit: actually I don't think you want your max height to be 64. By the time the player reaches the height of a second platform, he will immediately be falling. Your max height |shoulbe a little more than 2 blocks. I would set it to at least 66 and see how that goes.

Last edited: