# timing a jump - solved

This topic is 4623 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm making a simple 2d game and want to time my jumps so that in .75 seconds he reaches the peak of his jump and in another .75 seconds he is back on the ground. The way I do it right now is all frame independent but I have no control over how long he is in the air for. Here's what I have
	float jumpDistance = 32.0f;

if (bjump == rising)
{
distanceJumped += jumpDistance*elapsedtime;
movementValue = jumpDistance*elapsedtime;

if (distanceJumped >= desiredDistance)
{
movementValue -= distanceJumped - jumpDistance;
distanceJumped = 32;
bjump = falling;
}
}
else
{
distanceJumped -= jumpDistance*elapsedtime;
movementValue = -jumpDistance*elapsedtime;

if (distanceJumped <= 0)
{
movementValue -= distanceJumped;
jumpingFlag = 0;
bjump = rising;
distanceJumped = 0;
isJumping = 0;
}
}

yPos += movementValue;


What would you reccommend that I do to make this jump timed? [Edited by - gellin on October 22, 2005 5:34:24 PM]

##### Share on other sites
Since you want the jumper to reach desiredDistance (which I would rename to halfDesiredDistance) in 0.75 seconds, you need to set jumpDistance (which I would rename to jumpVelocity) to desiredDistance / 0.75 (or 750 if your values are in ms), rather than setting it to a constant (32).

##### Share on other sites
Nevermind. It turns out I already had some timer in there. I haven't worked on this in a week and forgot I put it in already. Thanks anyways.

• 48
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631374
• Total Posts
2999653
×