Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


CombatCactus

Member Since 09 Oct 2012
Offline Last Active Jul 23 2013 06:56 AM

Posts I've Made

In Topic: [SDL] Jumping input

25 January 2013 - 10:54 AM

Try having these variables:

vSpeed, vSpeedMax, gravity, jHeight;

if there is no collision below the object, add gravity ( should be positive ) to vSpeed.

if vSpeed > vSpeedMax set vSpeed to vSpeedMax

if you press the jump key set vSpeed = to jHeight ( you want jHeight to be negative )

if you are in the air and there is a collision below the object at the vSpeed distance, set vSpeed to 0 and resolve collision.

Finally, add the vSpeed variable to the objects y coordinate.

PARTNERS