#include "Timer.h" Timer::Timer(std::chrono::milliseconds interval, bool cyclic) : m_start_time(clock_type::now()), m_interval(interval), m_running(false), m_cyclic(cyclic) { } void Timer::start() { m_running = true; m_start_time = clock_type::now(); } void Timer::stop() { m_running = false; } bool Timer::is_elapsed() const { return m_start_time + m_interval < clock_type::now(); } void Timer::update() { if (m_running && is_elapsed()) { elapsed(); if (m_cyclic) { start(); } else { stop(); } } }