make a timer. like how much you want your jump to last,
for each cycle, if your timer is larger than 0, subtract 1 to your timer, and add some height to your sprite. before you press the jump key, check to see if the jump timer is 0, and then if your jump key is being pressed. if it Is pressed, then add some time to your timer. sort of like this:
//supposing that you declare before the loop:
float height;
float jumpheight=10.0f;
int jumptime=20;
int jumptimer;// make sure your time is enough so that you dont "fly"
//and that inside your loop you have:
if(jumptimer>0)
{
height=height+jumpheight;
jumptimer=jumptimer-1;
}
if (jumptimer==0)//this checks to see if you can jump again
{
if(dbSpaceKey())
{
jumptimer=jumptime;
}
}
//you must also have gravity so:
if(height>0.0f)//here i suppose your height is 0, but you can use some other method.
{
height=height-0.5f;
}
// and just position your sprite at: X,Height .... dont know the sprite commands to do that.
hi