mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-03-22 01:34:13 -05:00
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
#pragma once
|
|
#include <SDL2/SDL.h>
|
|
|
|
// Apparently system is used already?
|
|
namespace sys
|
|
{
|
|
/// @brief Class that uses SDL ticks to time things.
|
|
class Timer
|
|
{
|
|
public:
|
|
/// @brief Default constructor.
|
|
Timer() = default;
|
|
|
|
/// @brief Constructs a new timer.
|
|
/// @param triggerTicks Number of ticks the timer is triggered at.
|
|
Timer(uint64_t triggerTicks) noexcept;
|
|
|
|
/// @brief Starts the timer.
|
|
/// @param triggerTicks Number of ticks to trigger at.
|
|
void start(uint64_t triggerTicks) noexcept;
|
|
|
|
/// @brief Updates and returns if the timer was triggered.
|
|
/// @return True if timer is triggered. False if it isn't.
|
|
bool is_triggered() noexcept;
|
|
|
|
/// @brief Forces the timer to restart.
|
|
void restart() noexcept;
|
|
|
|
private:
|
|
/// @brief Tick count when the timer starts.
|
|
uint64_t m_startingTicks{};
|
|
|
|
/// @brief Number of ticks to trigger on.
|
|
uint64_t m_triggerTicks{};
|
|
};
|
|
} // namespace sys
|