#include #include #include #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(30); 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(); } }