if (sf::Keyboard::isKeyPressed(sf::Keyboard::W))
{
if (velocity.y > -_maxVelocity)
velocity.y -= _accel;
}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::S)) // when going from W to S there is a noticeable friction delay before moving // we should check this eventually
{
if (velocity.y < _maxVelocity)
velocity.y += _accel;
}
else
{
Clamp(velocity.y, 0.f, 5.f);
Clamp(velocity.x, -5.f, 0.f);
if (velocity.y > 0.f)
{
velocity.y -= _deccel;
}
else if (velocity.y < 0.f)
{
velocity.y += _deccel;
}
}
// X Movement
if (sf::Keyboard::isKeyPressed(sf::Keyboard::A))
{
if (velocity.x > -_maxVelocity)
velocity.x -= _accel;
}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::D))
{
if (velocity.x < _maxVelocity)
velocity.x += _accel;
}
else
{
Clamp(velocity.x, 0.f, 5.f);
Clamp(velocity.x, -5.f, 0.f);
if (velocity.x > 0.f)
{
velocity.x -= _deccel;
}
else if (velocity.x < 0.f)
{
velocity.x += _deccel;
}
}
Move(velocity * dt.asSeconds());