Sign in to follow this  
shawnmcc

How to make a character jump up and down again

Recommended Posts

I have been working on my own game so far this is what I have so far for the jump function. do { PlayerPosY= PlayerPosY+ 1; LoadContent(); UpdateEnemies(); loopUp++; } while (loopUp <= 10); do { PlayerPosY= PlayerPosY- 1; LoadContent(); UpdateEnemies(); loopDown++; } while (loopDown >= 10); Now all it does is stay in one place. I have updated everything but could not get a delay in there that would work. Any answers as to how to make this work?

Share this post


Link to post
Share on other sites
Jumping is typically handled by giving some additional values to the player state, a velocity and/or acceleration depending on your games complexity. You want to process the jump asynchonously, allowing the standard game loop to continue while the player is jumping.

Your jump function, if you got it to work, would be quite limited. The player could only jump straight up or down, but could not jump in a parabola.

You will need to add conditions to the rest of your code to prevent, for example, the player walking while jumping, again depending on the game (some games allow the player limited control of the character even in the air). You might need to record whether the player is on the ground or jumping with a boolean condition variable. You will want some collision detection to determine if the player hits the ceiling (if any), other characters and when it hits the ground again.

Share this post


Link to post
Share on other sites

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

Sign in to follow this