Hi there, sorry if this is asked a lot, I have written some movement code for a little game, the code works, however on key press, it moves 1 tick of movement, before smoothly moving when held after about a second.
while (this->window->pollEvent(this->ev))
{
switch (this->ev.type)
{
case sf::Event::Closed:
this->window->close();
break;
case sf::Event::KeyReleased:
if (this->ev.key.code == sf::Keyboard::Escape)
{
this->window->close();
}
int i = 0;
if (this->ev.key.code == sf::Keyboard::W)
{
this->players[i].move(0.f, -15);
}
if (this->ev.key.code == sf::Keyboard::A)
{
this->players[i].move(-15, 0.f);
}
if (this->ev.key.code == sf::Keyboard::S)
{
this->players[i].move(0.f, 15);
}
if (this->ev.key.code == sf::Keyboard::D)
{
this->players[i].move(15, 0.f);
}
}
}
My question is if there is a simple way of fixing this so that the movement is smooth immediately. Thanks