|
|
@ -0,0 +1,28 @@ |
|
|
|
This page will go over some of the common questions new users have when starting out using raylib. |
|
|
|
|
|
|
|
* How do I make a timer? |
|
|
|
|
|
|
|
Raylib has no built in timer system. You are expected to keep track of time in your own code. You can do with with the GetTime and GetFrameTime functions. Below is an example of a simple timer struct and functions to use it. |
|
|
|
``` |
|
|
|
typedef struct |
|
|
|
{ |
|
|
|
double StartTime; |
|
|
|
double Lifetime; |
|
|
|
}Timer; |
|
|
|
|
|
|
|
void StartTimer(Timer* timer, double lifetime) |
|
|
|
{ |
|
|
|
timer->StartTime = GetTime(); |
|
|
|
timer->Lifetime = lifetime; |
|
|
|
} |
|
|
|
|
|
|
|
bool TimerDone(Timer timer) |
|
|
|
{ |
|
|
|
return GetTime() - timer.StartTime >= timer.Lifetime; |
|
|
|
} |
|
|
|
|
|
|
|
double GetElapsed(Timer timer) |
|
|
|
{ |
|
|
|
return GetTime() - timer.StartTime; |
|
|
|
} |
|
|
|
``` |