private void HandleInputs()
{
double left = input.left();
double right = input.right();
bool gotDirInput = false;
if (!punch.IsActive())
{
//Move left if left is pressed
if (left > 0)
{
Vel = new Vector2((float)(-speed * left), Vel.Y);
gotDirInput = true;
flip = true;
}
//Move right if right is pressed
else if (right > 0)
{
Vel = new Vector2((float)(speed * right), Vel.Y);
gotDirInput = true;
flip = false;
}
//Jump if up is pressed
if ((input.up() > .999 || input.select()) && Vel.Y == 0)
{
Vel = new Vector2(Vel.X, -speed * 5);
}
}
//If no directional input, reset X velocity.
if (!gotDirInput)
{
Vel = new Vector2(0, Vel.Y);
}
if (gettingPunched && recoilAnim.Looped)
{
idleAnim.Reset();
gettingPunched = false;
}
else if (punching && punchAnim.Looped)
{
idleAnim.Reset();
punching = false;
if (flip)
{
SetPos(new Vector2(Pos.X + punchAnim.GetWidth() - idleAnim.GetWidth(), Pos.Y));
}
}
//Punch if punch key is pressed
if (input.punch() && !punching)
{
punch.Trigger();
punchAnim.Reset();
punching = true;
if (flip)
{
SetPos(new Vector2(Pos.X - punchAnim.GetWidth() + idleAnim.GetWidth(), Pos.Y));
}
}
}