Hello,
I was wondering if their is a more optimized way to do this?
I know about the playerSprite,move(position); function but it doesn't do what I want it to.
This code works just fine and the movement is smooth but just by looking at it calling the playerSprite.setPosition(); every update call doesn't seem very fast to me. IDK maybe that is the fastest way to do it.
void Player::update(float delta)
{
if (sf::Keyboard::isKeyPressed(sf::Keyboard::W) || sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
{
position.y -= Player::VELOCITY * delta;
}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::S) || sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
{
position.y += Player::VELOCITY * delta;
}
playerSprite.setPosition(position);
}