Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


#ActualCornstalks

Posted 24 January 2013 - 01:26 AM

You can either use a timer (i.e. "from now until the next second, give the player an upward y velocity; after this second is over, let gravity take effect."), or you could have a counter (which kinda acts like a timer; i.e. "if counter <= 0, let gravity take effect; if counter > 0, give upward y velocity; when jump button is pressed, set counter to 100 (or whatever) and decrement it every update loop"), or if you're doing a more "physically based" jump you can add some amount to the y velocity to make it positive and then let gravity slowly pull it back down.

 

However, in all of these methods, you're going to probably want to first check if the player is touching the ground when they press jump. If the player is not touching the ground, ignore the press. If the player is touching the ground, go ahead and jump.


#1Cornstalks

Posted 24 January 2013 - 01:26 AM

You can either use a timer (i.e. "from now until the next second, give the player an upward y velocity; after this second is over, let gravity take effect."), or you could have a counter (which kinda acts like a timer; i.e. "if counter <= 0, do not give an upward y velocity; if counter > 0, give upward y velocity; when jump button is pressed, set counter to 100 (or whatever) and decrement it every update loop"), or if you're doing a more "physically based" jump you can add some amount to the y velocity to make it positive and then let gravity slowly pull it back down.

 

However, in all of these methods, you're going to probably want to first check if the player is touching the ground when they press jump. If the player is not touching the ground, ignore the press. If the player is touching the ground, go ahead and jump.


PARTNERS