Hi, I would like to ask on how to code on the movement of character. Basically, when I press my right arrow key, it will move right, and when I press my left shift, it will dash for a certain time(using int dashcounter
) The problem comes in, players could constantly spam SHIFT to allow the character to infinetly dash, how do i control/prevent it?
if (CP_Input_KeyDown(KEY_RIGHT) )
{
movementH = right;
if (CP_Input_KeyDown(KEY_LEFT_SHIFT) && dashcounter < 20)
{
movementV = CP_Vector_Zero();
movementH = CP_Vector_Add(right, dash);
dashcounter += 1;
}
}
if (CP_Input_KeyReleased(KEY_LEFT_SHIFT))
{
dashcounter = 0;
}