1
SFML development / Re: Introduce chrono to sf::Time
« on: August 21, 2022, 11:53:55 am »
I would say that sf::Time unnecessarily duplicates the code of std::chrono and greatly limits the flexibility of working with time. Using time units, conversions and other operations through std::chrono is much more natural and clear. Why should there be a default unit of something called "Int64 m_microseconds;" or "second = float". The user himself should determine the precision he needs for a given operation or what a given time period represents.
Instead of "time.AsSeconds", sf::Clock can be extended to "clock.getElapsedAsSeconds()", but basically it doesn't have much use. Perhaps make more sf::Clock alternatives like stopwatch, pauseable clock and so on would be better idea how improve work with time.
For the stated drawback (even if it's not important at all):
Instead of "time.AsSeconds", sf::Clock can be extended to "clock.getElapsedAsSeconds()", but basically it doesn't have much use. Perhaps make more sf::Clock alternatives like stopwatch, pauseable clock and so on would be better idea how improve work with time.
For the stated drawback (even if it's not important at all):
// Instead of
std::cout << "Time: " << duration<float>(t).count() << " second(s)\n";
// You can write
std::cout << "Time: " << duration<float>(t) << "\n";
// Output: Time: 1.001s
std::cout << "Time: " << duration<float>(t).count() << " second(s)\n";
// You can write
std::cout << "Time: " << duration<float>(t) << "\n";
// Output: Time: 1.001s