跳到正文

个人记录

现成计时器

tablelovecpp约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟

版本

  1. v1当前
C++
struct TICKS {
    DWORD start, now, interval;

    bool operator==(TICKS ticks) { return now == ticks.now; }
    bool isNow() {
        if ((now - start) >= interval) {
            start = now;
            return true;
        }
        return false;
    }
    void update() { now = GetTickCount(); }

    TICKS(DWORD interval)
        : start(GetTickCount()), now(start), interval(interval) {}
    TICKS() {}
};
原文