SFML movement not working with delta time C++
Solution 1:
With basic drawing code and modern GPUs you can easily get up to 2-3k frames per second, which can then turn into a frame time of 1f / 3000fps = 0.00033s
which is less than one millisecond, thus when you call asMilliseconds()
you may end up with 0
.
An easy workaround here is to always work with seconds (asSeconds()
) and floats, that way you should never hit 0
. Keep in mind though, that you should always set a limit, either by enabling VSync or calling setFramerateLimit()
.
As for a design point of view, I recommend to not derive from sf::RectangleShape
and instead use composition over inheritance. You can then derive from the more interface-like classes such as `sf