YukiHerz wrote:if you spam the jump button/press it at the right time, you can continuously jump mid-air.
// apply X velocity
if (sideInput != 0) //if there is input
{
if (vx >= 0 && sideInput > 0) vx += PLAYER_ACCELERATE; //if velocity is above 0 & pressing right, add acc
else if (vx <= 0 && sideInput < 0) vx -= PLAYER_ACCELERATE; //if velocity is below 0 & pressing left, sub acc
vx = Clamp(vx, -SideMove1, SideMove1); //velocity = Limit(Velocity,input left, input right)
}
else if (sideInput == 0 && vx != 0) //if there's no input and velocity isn't 0
{
if (dir == DIR_Left) vx += (PLAYER_FRICTION * vx); //if facing left, add friction
else if (dir == DIR_Right) vx -= (PLAYER_FRICTION * vx); //if facing right, sub friction
}
else if (sideInput == 0 && vx == 0) //if there's no input and velocity is 0
{
vx *= PLAYER_FRICTION; //Velocity = Velocoity * Friction
}
// braking
if (sideInput != 0 && vx != 0) //if there's no input and velocity isn't 0
{
if (vx < 0 && sideInput > 0) vx += PLAYER_DECELERATE; //if velocity lower than 0 & facing right, add decelleration
else if (vx > 0 && sideInput < 0) vx -= PLAYER_DECELERATE; //if velocity is above 0 & facing left, sub decelleration
}
Users browsing this forum: No registered users and 2 guests