Implementation of the timer utility. More...
Functions | |
| Timer * | Timer_Create (float duration) |
| [Start/Utility] Creates a timer with the specified duration | |
| void | Timer_Start (Timer *timer) |
| [Utility] Starts or restarts a timer | |
| bool | Timer_IsFinished (Timer *timer) |
| [Utility] Determines whether a timer is finished | |
| float | Timer_GetTimeLeft (Timer *timer) |
| [Utility] Gets the remaining time before a timer finishes | |
| bool | Timer_IsInProgress (Timer *timer) |
| [Utility] Determines whether a timer is currently running | |
| void | Timer_Destroy (Timer *timer) |
| [Utility] Destroys a timer and frees its memory | |
Implementation of the timer utility.
Provides functionality for creating, starting, checking, and destroying timers. Timers are used for cooldowns, fire rates, animations, and other time-based features.
| Timer * Timer_Create | ( | float | duration | ) |
[Start/Utility] Creates a timer with the specified duration
Creates a new timer with the specified duration.
Allocates and initializes a new timer with the given duration. The timer starts in a stopped state and must be started with Timer_Start().
| duration | The duration of the timer in seconds |
| void Timer_Destroy | ( | Timer * | timer | ) |
[Utility] Destroys a timer and frees its memory
Destroys the timer and frees its memory.
| timer | Pointer to the timer to destroy |
| float Timer_GetTimeLeft | ( | Timer * | timer | ) |
[Utility] Gets the remaining time before a timer finishes
Gets the time left on the timer.
Returns how many seconds are left before the timer completes. Returns 0 if the timer is not running or has already finished.
| timer | Pointer to the timer to check |
| bool Timer_IsFinished | ( | Timer * | timer | ) |
[Utility] Determines whether a timer is finished
Checks if the timer is finished.
A timer is finished when Current Time - Timer start time > Timer duration. If the timer is not running, returns the cached finished state.
| timer | Pointer to the timer to check |
| bool Timer_IsInProgress | ( | Timer * | timer | ) |
[Utility] Determines whether a timer is currently running
Checks if the timer is in progress.
Checks if the timer is in the "in progress" state.
| timer | Pointer to the timer to check |
| void Timer_Start | ( | Timer * | timer | ) |
[Utility] Starts or restarts a timer
Starts the timer.
Sets the start time to the current time and marks the timer as in progress. If the timer was already running, this will restart it.
| timer | Pointer to the timer to start |