Siv3D / OpenSiv3D

C++20 framework for creative coding 🎮🎨🎹 / Cross-platform support (Windows, macOS, Linux, and the Web)
https://siv3d.github.io/
MIT License
994 stars 136 forks source link

Timer の残り時間(秒)を切り上げて取得する Timer::s_ceil() #1233

Closed Reputeless closed 1 month ago

Reputeless commented 2 months ago
Reputeless commented 2 months ago
# include <Siv3D.hpp>

void Main()
{
    Scene::SetBackground(ColorF{ 0.6, 0.8, 0.7 });
    const Font font{ FontMethod::MSDF, 40, Typeface::Bold };
    Timer timer{ 10s };

    while (System::Update())
    {
        if (SimpleGUI::Button(U"Start", Vec2{ 500, 60 }))
        {
            timer.start();
        }

        font(U"{}"_fmt(timer.format())).draw(60, Vec2{ 40, 40 }, ColorF{ 0.4 });
        font(U".s():        {}"_fmt(timer.s())).draw(60, Vec2{ 40, 140 }, ColorF{ 0.11 });
        font(U".s_ceil():   {}"_fmt(timer.s_ceil())).draw(60, Vec2{ 40, 240 }, ColorF{ 0.11 });
    }
}