From e3df9a65480ec295a1881d6a6d8416253777dac7 Mon Sep 17 00:00:00 2001 From: Jeffery Myers Date: Fri, 21 Jan 2022 16:58:05 -0800 Subject: [PATCH] Created Frequently asked Questions Common Questions (markdown) --- ...ently-asked-Questions--Common-Questions.md | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Frequently-asked-Questions--Common-Questions.md diff --git a/Frequently-asked-Questions--Common-Questions.md b/Frequently-asked-Questions--Common-Questions.md new file mode 100644 index 0000000..6bf4e54 --- /dev/null +++ b/Frequently-asked-Questions--Common-Questions.md @@ -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; +} +```