I usually think it's better to use standard stuff, because it is more flexible, robust, documented, used, etc. and people don't have to learn yet another xyz class which just works for this specific framework. And we can focus on the real value of SFML (multimedia abstractions) rather than thin wrappers provided for pure convenience.
But I have to admit that std::chrono makes things more verbose and confusing than needed... So here is my suggestion:
sf::Time looks much better than the standard equivalent (either verbose templates everywhere, or std::chrono::nanoseconds which looks confusing). So I'd keep it. With additional conversions to and from std::chrono::duration, if possible.
sf::Clock doesn't deserve to exist compared to a standard
clock::now() (yes, don't be afraid to typedef those long standard clock types). But it's convenient because it returns that sf::Time that I want to keep in the API. So let's make it more useful! Everyone wants a pausable clock, let's do it. Maybe we can even find other good ideas in the long list of suggestions/implementations available.
PS: here is the standard example using less verbose syntax (let's not make it more complicated than it is
![Wink ;)](https://www.sfml-dev.org/forums/Smileys/default/wink.gif)
)
#include <SFML/Graphics.hpp>
#include <chrono>
int main()
{
using clock = std::chrono::high_resolution_clock;
sf::RenderWindow window{sf::VideoMode(800, 600), "SFML"};
window.setVerticalSyncEnabled(true);
sf::RectangleShape shape{{10.f, 10.f}};
sf::Vector2f velocity{20.f, 20.f};
auto last = clock::now();
while (window.isOpen())
{
auto now = clock::now();
auto dt = std::chrono::duration_cast<std::chrono::seconds>(now - last);
last = now;
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
shape.move(velocity * dt.count());
window.clear();
window.draw(shape);
window.display();
}
}
By the way, is std::chrono::duration<float> a number of seconds?