z_mirror/sdl-osu
git clone https://git.raiguard.me/z_mirror/sdl-osu
6724e9e
trunk
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 () { 8srand (time (NULL )); 9 10SDL_SetAppMetadata ("osu!" ,OSU_VERSION ,"me.raiguard.sdl-osu" ); 11 12struct Osu_Game * game = Osu_CreateGame (); 13 14union SDL_Event event ; 15bool quit = false; 16 17while (!quit ) { 18Osu_UpdateFrameTiming (& game -> frameTiming ); 19 20while (!quit && SDL_PollEvent (& event )) { 21quit = Osu_HandleGameEvent (game ,& event ); 22 } 23 24Osu_PreUpdateGame (game ); 25 26while (game -> frameTiming .accumulator >=UPDATE_DURATION ) { 27Osu_UpdateGame (game ); 28game -> frameTiming .accumulator -= UPDATE_DURATION ; 29 } 30 31Osu_PostUpdateGame (game ); 32 33Osu_RenderGame (game ); 34 35Uint64 thisFrameDuration = SDL_GetTicksNS ()- game -> frameTiming .lastFrameTime ; 36if (thisFrameDuration < FRAME_DURATION ) { 37SDL_DelayPrecise (FRAME_DURATION - thisFrameDuration ); 38 } 39 } 40 41Osu_DestroyGame (game ); 42}