现成计时器

· · 个人记录

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() {}
};