Jump to content
Sign in to follow this  
  • entries
    686
  • comments
    1952
  • views
    387716

Checkpoints

Sign in to follow this  
Stompy9999

118 views

Checkpoints are done:

off:


on:


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  


2 Comments


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(AllowInput)
{
if(InAir || !CanJump)
return;

// 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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!