Closed SerhiiYashchuk closed 10 years ago
Ideally you want to have a velocity defined in code. That will be constant or change depending on where the character will be in the jump height.
When it comes to position the sprite, simply calculate delta time as t - tLastFrame. Use this delta multiplied by the speed to move the character at the same speed.
To make him jump to same height I suggest either:
To get a nice slowing down then falling (#2), needs a bit more work. Either simulating the gravity drag with a mathematical calculation, or hardcoding speeds at different heights (it's believed that's how original mario games had speeds calculated). You can easily simulate gravity drag by decreasing an amount to the speed every frame.
See these: http://www.gamedev.net/topic/490713-jump-formula/ http://www.rodedev.com/tutorials/gamephysics/ http://gamedev.stackexchange.com/questions/6618/analysis-of-mario-game-physics
I'm trying to implement jump physic for my game. While the character is jumping, his speed is reduced a bit. The problem is that the character jumps with different height every time.
Using getFrameTime() to get the right delta for movement works differently. I tried to use timer and move character with constant delta when timer reaches a time delta. In this case the height of jump looks the same but speed is different.
How can I make him to jump with the same height and speed?