added Time::get_ticks() to poll for an immediate value

This commit is contained in:
Noel Berry 2022-02-11 16:07:07 -08:00
parent c52258ddcd
commit 068d0778c2
2 changed files with 10 additions and 2 deletions

View File

@ -8,10 +8,10 @@ namespace Blah
// ticks per second (microseconds, in this case)
constexpr u64 ticks_per_second = 1000000;
// uptime, in ticks
// uptime, in ticks, at the start of the current frame
extern u64 ticks;
// uptime, in seconds
// uptime, in seconds, at the start of the current frame
extern double seconds;
// delta time from last frame
@ -26,6 +26,9 @@ namespace Blah
// time the application should pause for
extern float pause_timer;
// uptime, in ticks. polls the Platform for an immediate value, unlike the cached `Time::ticks` value
u64 get_ticks();
// pauses the entire application for the given time
void pause_for(float duration);

View File

@ -10,6 +10,11 @@ double Time::previous_seconds = 0;
float Time::delta = 0;
float Time::pause_timer = 0;
u64 Time::get_ticks()
{
return Platform::ticks();
}
void Time::pause_for(float duration)
{
if (duration >= pause_timer)