Banjo API
1.0.0-rc.2
Low-level C99 game development API
Loading...
Searching...
No Matches
time.c
Go to the documentation of this file.
1
15
16
#include <
banjo/log.h
>
17
#include <
banjo/main.h
>
18
#include <
banjo/system.h
>
19
#include <
banjo/time.h
>
20
21
int
main
(
int
argc,
char
* argv[]) {
22
(void)argc; (void)argv;
23
24
// BJ_NO_SYSTEM means we don't need video or audio - just basic functions
25
// like time and logging work without any subsystem.
26
if
(!
bj_begin
(
BJ_NO_SYSTEM
, 0)) {
27
return
1;
28
}
29
30
// Run for about 3 seconds, printing the elapsed time each iteration.
31
double
elapsed = 0.0;
32
while
(elapsed < 3.0) {
33
// bj_run_time() returns the number of seconds (as a double) since the
34
// program started. Useful for animations, timeouts, and delta time.
35
elapsed =
bj_run_time
();
36
bj_trace
(
"- %lf"
, elapsed);
37
38
// bj_sleep() pauses execution for the given number of milliseconds,
39
// which paces this loop and keeps it off the CPU between prints.
40
bj_sleep
(300);
41
}
42
43
bj_end
();
44
return
0;
45
}
main
int main(int argc, char *argv[])
Definition
audio_pcm.c:177
bj_trace
#define bj_trace(...)
Log a message using the BJ_LOG_TRACE level.
Definition
log.h:113
bj_begin
bj_bool bj_begin(int systems, struct bj_error **error)
Initialises the system.
bj_end
void bj_end(void)
De-initialises the system.
BJ_NO_SYSTEM
@ BJ_NO_SYSTEM
Definition
system.h:79
bj_sleep
void bj_sleep(int milliseconds)
Suspends the current thread for a specified duration.
bj_run_time
double bj_run_time(void)
Gets the current time in seconds since Banjo initialisation.
log.h
Logging utility functions.
main.h
Portable main() replacement with platform-aware entry shim.
system.h
Header file for system interactions.
time.h
Header file for time manipulation utilities.
examples
time.c
Generated on
for Banjo API by
1.14.0