You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.0 KiB
Objective-C
45 lines
1.0 KiB
Objective-C
#include <stdio.h>
|
|
#include <raylib.h>
|
|
#include <stdbool.h>
|
|
#include "timer.h"
|
|
|
|
static inline struct timespec subts(volatile struct timespec t1, volatile struct timespec t2) {
|
|
return (struct timespec) {
|
|
.tv_sec = t2.tv_sec - t1.tv_sec,
|
|
.tv_nsec = t2.tv_nsec - t1.tv_nsec,
|
|
};
|
|
}
|
|
|
|
int main(void) {
|
|
|
|
Timer *t = [[Timer alloc] init];
|
|
char buffer[100];
|
|
|
|
InitWindow(400, 400, "raytime");
|
|
SetTargetFPS(60);
|
|
|
|
Color theColor = BLACK;
|
|
|
|
[t start];
|
|
while (!WindowShouldClose()) {
|
|
sprintf(buffer, "%jd", (intmax_t)[t time].tv_sec);
|
|
|
|
if (IsKeyPressed(KEY_SPACE)) {
|
|
if (t->paused) {
|
|
[t resume];
|
|
theColor = BLACK;
|
|
} else {
|
|
theColor = RED;
|
|
[t pause];
|
|
}
|
|
}
|
|
|
|
[t tick];
|
|
|
|
BeginDrawing();
|
|
ClearBackground(WHITE);
|
|
DrawText([t timeString], 400/2 - 50, 400/2 - 50, 100, theColor);
|
|
EndDrawing();
|
|
}
|
|
}
|