Im confused trying to implement delta time for my character movement. here is some code (Ive only shown important parts for simplicity):
sf::RenderWindow Game1(sf::VideoMode(800, 600), "Platform Engine", sf::Style::Close);
Game1.EnableVerticalSync(true);
//Game1.SetFramerateLimit(25);
//time in seconds
float deltaTime = Game1.GetFrameTime() / 1000.0f;
if(sf::Keyboard::IsKeyPressed(sf::Keyboard::Left))
{
playerX -= 40.0f * deltaTime;
}
if(sf::Keyboard::IsKeyPressed(sf::Keyboard::Right))
{
playerX += 40.0f * deltaTime;
}
playerSprite.SetPosition(playerX, playerY);
Problem is, when I run the game with frame limit set to 25, the character takes 20 seconds to cross the screen, as it should be. But if I have no frame limit, it takes longer for the character to cross the screen. Id like to release with no frame limit, but upon testing on other machines, both slower and faster ones, I'm still getting varying speeds of character movement.
Any ideas on what I'm doing wrong?
Cheers.