#include #include #include #include #include #include int main (int count, char ** arguments) { /* :config */ int horizontal = 1920, vertical = 1080; { /* this idented (DENTED) style is autistic and dumb but I like it visually */ SetConfigFlags(FLAG_WINDOW_RESIZABLE); /* tell raylib to shut up */ /* SetTraceLogLevel(LOG_NONE); */ InitWindow(horizontal, vertical, arguments[0]); SetWindowState(FLAG_WINDOW_HIDDEN); InitAudioDevice(); SetWindowPosition(0, 0); } /* :todo ping me I'll update this to a u/f seperated game loop */ { /* loop to end all loops */ uint64_t frame = 0; /* :config */ float fps = 30; double wait = wait = 1.0 / fps, Δ = wait; struct timespec start, end; clock_gettime(CLOCK_MONOTONIC, &start); ClearWindowState(FLAG_WINDOW_HIDDEN); while (1) { if (Δ > wait) { clock_gettime(CLOCK_MONOTONIC, &start); { /* update */ ++frame; PollInputEvents(); /* physical keys */ switch (GetKeyPressed()) { case KEY_Q: goto stop; case KEY_ESCAPE: goto stop; } /* routed keys */ /* switch (GetCharPressed()) { case 'q': goto stop; } */ } { /* draw */ BeginDrawing(); ClearBackground(BLACK); DrawText(TextFormat("Delta (Δ): %d", Δ), 10, 10, 20, WHITE); rlDrawRenderBatchActive(); SwapScreenBuffer(); } } clock_gettime(CLOCK_MONOTONIC, &end); Δ = (end.tv_sec - start.tv_sec) + (end.tv_nsec - start.tv_nsec) / 1e9; if (Δ < wait) { double should = -(Δ - wait); if (should > 0) { usleep(1e6 * should); } } } } stop: SetWindowState(FLAG_WINDOW_HIDDEN); CloseAudioDevice(); CloseWindow(); return 0; }