public function update(elapsed:Float)
{
groundCheck.setPosition(character.x + groundCheckOffset.x, character.y + groundCheckOffset.y);
if (controls.binds['left'].pressed())
{
if (!sprinting)
character.velocity.x = -speed;
sprinting = false;
if (controls.binds['sprint'].pressed())
{
sprinting = true;
if (character.velocity.x > -speed * 1.5)
{
character.velocity.x -= 20;
}
}
stopped = false;
}
else if (controls.binds['right'].pressed())
{
if (!sprinting)
character.velocity.x = speed;
sprinting = false;
if (controls.binds['sprint'].pressed())
{
sprinting = true;
if (character.velocity.x < speed * 1.5)
{
character.velocity.x += 20;
}
}
stopped = false;
}
else
{
if (character.velocity.x > speed * 1.25 && !sprinting)
{
wasSprinting = true;
}
if (wasSprinting)
{
if (Math.abs(character.velocity.x) > 20)
{
trace('was spirinting');
if (MathUtil.sign(character.velocity.x) == -1)
character.velocity.x += 20;
else
character.velocity.x -= 20;
}
else
{
character.velocity.x = 0;
}
}
if (!wasSprinting)
character.velocity.x = 0;
sprinting = false;
stopped = true;
}
if (controls.binds['jump'].justPressed())
{
character.velocity.y = jumpForce;
}
#if debug
if (character.velocity.x != prevVelX)
{
trace("CHARACTER VELOCITY: " + character.velocity.x);
prevVelX = character.velocity.x;
}
#end
character.acceleration.y = gravity;