mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-03-22 01:34:13 -05:00
28 lines
556 B
C++
28 lines
556 B
C++
#include <SDL2/SDL.h>
|
|
|
|
#include "system/timer.hpp"
|
|
|
|
sys::timer::timer(uint32_t triggerTicks) :
|
|
m_TriggerTicks(triggerTicks)
|
|
{
|
|
restartTimer();
|
|
}
|
|
|
|
void sys::timer::restartTimer(void)
|
|
{
|
|
// Set starting ticks
|
|
m_StartingTicks = SDL_GetTicks();
|
|
}
|
|
|
|
bool sys::timer::triggered(void)
|
|
{
|
|
// Get current ticks
|
|
uint32_t currentTicks = SDL_GetTicks();
|
|
// If amount is greater or equal, triggered
|
|
if(currentTicks - m_StartingTicks >= m_TriggerTicks)
|
|
{
|
|
m_StartingTicks = currentTicks;
|
|
return true;
|
|
}
|
|
return false;
|
|
} |