I'm a beginner and I'm having some trouble getting smooth movement in SFML. I made a Pong game Allegro, and movement was handled as follows. keyState being an array of bools and keypressed being an enum with an element for each key. (sorry if this pseudo-code is terrible)
Poll for events {
if key is down, keyState[keypressed] = true;
if key is released, keyState[keypressed] = false;
if (timer ticks) { // (timer was set to 1.0 / 60)
redraw = true;
handle player movement based on keyState[keypressed] values;
if (redraw && event queue is empty)
redraw = false;
draw everything;
}
clear display;
flip display;
This resulted in the timer ticking 60 times per second, redrawing at 60 FPS and handling the movement smoothly. With SFML 2.0, I'm having troubles replicating what I did. I've read about time-based movement (i.e move by x * deltaT), but for some reason the implementation and logic behind it is completely eluding me.
Right now I have movement handled within the event polling, and it moves fine, but there is a delay if you hold the key down between the first movement and the repeated movement, and it's jumpy.
Can anyone help explain how to handle smooth movement in SFML 2.0?