Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views


Sign in to follow this  


Checkpoints are done:



One last thing before I can move onto level 2, controlling jump height. Meaning, determining how high a jump is by how long the button is held down. Hopefully I can get that done tomorrow, although I first have to figure out how.
Sign in to follow this  


Recommended Comments

Checkpoints were really needed. The first level was long.

As for making jump height proportional to the time the button is held down, this is how I would probably do it. First decide on some parameters: the maximum jump speed (maxSpeed) and the time the button must be held down to achieve this maximum speed (maxTime). Now, record the time at which the button is pressed (t1) and the time at which it is released (t2). Calculate (t2 - t1) / maxTime, clamp the result to the range [0,1], and call it normalizedTime. Now use this as a factor to interpolate linearly between 0 and maxSpeed; that is, have the character jump with speed normalizedTime * maxSpeed.

Alternatively, you could interpolate the jump height directly rather than the jump speed. From the jump height you would need to calculate the speed necessary to achieve that height (assuming you are physically simulating this with gravity acting linearly on the character's vertical speed).

Edit: On second thought, I think I may have misunderstood exactly what you are trying to do. Eh.

Share this comment

Link to comment
Blocky Man is coming along nicely; can't wait for the next demo [grin].

I actually got lucky and the higher-jumps thing was a side effect of how I designed my system. I'll try to give you an idea of how I have mine setup (hopefully I don't just confuse you lol.)

I use MinVelocityY to tell when to start falling. Then, in my Jump() method I subtract from the player's y-velocity until it reaches MinVelocityY, at which point I tell it that I should no longer be able to jump until I've hit the ground. My jump method looks something like so:

void Entity::Jump(float TimeScale)
if(InAir || !CanJump)

// Give the player an initial burst
if((int)VelocityY == 0)
VelocityY = -(Gravity * 0.25f);

// Modify VelocityY using time-scaling.
VelocityY -= ((Gravity * 2.5f) * TimeScale);

// We've reached the peak of our jump
if(VelocityY < MinVelocityY)
InAir = true;
CanJump = false;

When I fall on surface InAir is set to false and CanJump is set to true. Also, CanJump is set to false when I hit a ceiling/bottom of a platform.

Hopefully that's helpful and not just confusing [lol].

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!