Original Post
I have made a simple platform game that when press space jumps when press ctrl accelerates and with acceleration the jump is higher and when i jump so high with acceleration and try to control where the player would land i get tooo much control becouse when i press right or left the player moves around the x axis just as fast as on the gorund and it looks bad, the bottom line is that when i start the jump the player will jump allong the x axis and acceleration but when a key is pressed during the jump i want to be able to controlle the player BUT not so much so that it looks like he can fly. here is my code...
if(lockjump==true )//SIMULACIJA GRAVITACIJE U VAZDUHU
{
if(xtime%200==0)
{
velx*=0.9;
}
}
else
velx*=0.000099;
if(keystates[SDLK_RIGHT])
{
velx = VELMOVING;
faceright = true;
W_RIGHT=true;
}
else W_RIGHT=false;
if(keystates[SDLK_LEFT])
{
velx =-VELMOVING;
faceright = false;
W_LEFT=true;
}
else W_LEFT=false;
if(keystates[SDLK_SPACE] && !lockjump)
{
ON_GROUND==false;
vely = -VELJUMP;
lockjump = true;
jumping = true;
}
if(keystates[SDLK_LCTRL] && (W_LEFT==true || W_RIGHT==true))
{
if (lockjump==false)
{
if (VELMOVING<15)
{
VELMOVING+=0.5;
}
if (VELJUMP<25 )
{
if(xtime%3==0)
VELJUMP+=1;
}
}
}
else
{
if (VELMOVING > 4)
VELMOVING-=1;
if (VELJUMP>15)
VELJUMP-=1;
}
xtime is my way of cehcking the time it ads up 1 on every main loop... i need to be able to control the player when making an accelerated jump BUT not too much...