Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Kinematics - Grid Jumping Problem  (Read 1347 times)

0 Members and 1 Guest are viewing this topic.

seyuup

  • Newbie
  • *
  • Posts: 14
    • View Profile
Kinematics - Grid Jumping Problem
« on: July 06, 2017, 03:24:41 pm »
Hi, I hope that someone will be able to assist me with my problem.

  • I have an object that moves from grid to grid (left, right, up, or down) at a speed, s.
  • The grid is 32x32.
  • There are "holes" scattered around the grid map. These holes can only be passed by jumping over them.
  • Each hole is also, 32x32
  • I want the object to be able to jump over these holes, but I want the jump movement to last the time it takes for the object to move from grid to grid.

I'll let, d, represent the direction (either x or y) that the object is moving. Thus,
  • ddisplacement = 32 (since each grid is 32x32).
  • t = ddisplacement / dspeed * elapsed time (as seconds)

Here, t, should be time it'll take for the object to cover the displacement, ddisplacement (in pixels), at speed, dspeed.

I then proceed to finding gravity amount:
  • jumppower = 100.f.
  • V0z = jumppower (the initial velocity in the 'z' direction).
  • Zdisplacement = 0 (the displacement of the jump).
  • gravity = 2 * (V0z * t - Zdisplacement) / t2

Notice: I'm not sure if the elapsed time needed to be applied here when calculating gravity.

Finally, I attempt to calculate the height at time, tother.
  • Before jump:
  • tother = 0 (this is set once before the jump executes).
  • ...
  • height = Z0 + V0z * tother + 0.5 * gravity * tother2.
  • V0z += gravity * elapsed time (as seconds).
  • tother += elapsed time (as seconds).
  • ...
  • Height applied to the sprite
  • sprite.setPosition(x, y + height)

Once again, I'm not sure if I applied the elapsed time correctly here. After attempting this, however, it appears to keep the object in the air of the length of traversing grid space to grid space, but the jump movement isn't what I'm going for.

When I press the key to make the object jump, object gradually moves upward, but then drops like a rock. I would like for it to be a nice smooth movement (like Super Mario Bros.).

Sorry, if this entire post was confusing, please let me know where any confusions may lie so I can try to help you all understand my problem better.

Thanks!

 

anything