z_mirror/sdl-osu

git clone https://git.raiguard.me/z_mirror/sdl-osu

Caleb HeuerUpdate app ID6724e9e

trunk
1019 B42 linesraw
1#include "game.h"
2#include <SDL3/SDL.h>
3#include <SDL3/SDL_main.h>
4#include <stdlib.h>
5#include <time.h>
6
7int main() {
8    srand(time(NULL));
9
10    SDL_SetAppMetadata("osu!", OSU_VERSION, "me.raiguard.sdl-osu");
11
12    struct Osu_Game* game = Osu_CreateGame();
13
14    union SDL_Event event;
15    bool quit = false;
16
17    while (!quit) {
18        Osu_UpdateFrameTiming(&game->frameTiming);
19
20        while (!quit && SDL_PollEvent(&event)) {
21            quit = Osu_HandleGameEvent(game, &event);
22        }
23
24        Osu_PreUpdateGame(game);
25
26        while (game->frameTiming.accumulator >= UPDATE_DURATION) {
27            Osu_UpdateGame(game);
28            game->frameTiming.accumulator -= UPDATE_DURATION;
29        }
30
31        Osu_PostUpdateGame(game);
32
33        Osu_RenderGame(game);
34
35        Uint64 thisFrameDuration = SDL_GetTicksNS() - game->frameTiming.lastFrameTime;
36        if (thisFrameDuration < FRAME_DURATION) {
37            SDL_DelayPrecise(FRAME_DURATION - thisFrameDuration);
38        }
39    }
40
41    Osu_DestroyGame(game);
42}