So I have my movement code working, but there is always a lag between when I press the button, and when the player starts walking. I have no idea why this happens. This isn't my biggest issue, it's just really confusing.
All my directions are the same, so I'm simply posting the minimal ammount of code I can.
EDIT: I solved my own problem. I only half wrote this code, and forgot to make my inputs Boolean. I COMPLETELY forgot to read the document I wrote to myself and ended up finding it in my google docs when I went to turn something into school.
void changePosX(float delta, bool isNegative)
{
if (!isNegative)
{
playerSprite.move(speed * delta, 0.0f);
}
else
{
playerSprite.move(-(speed * delta), 0.0f);
}
}
Where delta comes from:
if (sf::Keyboard::isKeyPressed(sf::Keyboard::W))
{
player.changeDir(player.UP);
if (player.getPosY() >= 0)
{
player.changePosY(delta, 1);
}
}