void game_run(int argc, char **argv) { sargc = argc; sargv = argv; _game_init(); while (!quit) { _game_events(); _game_update(); _game_draw(); } _game_deinit(); }
int game_loop() { Uint32 ticks_per_second = 1000/fps; Uint32 next_ticks = SDL_GetTicks() + ticks_per_second; Uint32 now_ticks; while(1){ //1, now_ticks = SDL_GetTicks(); if (now_ticks < next_ticks) { SDL_Delay(next_ticks - now_ticks); } next_ticks += ticks_per_second; if (_game_handle_event() == 1) { return 1; } if (_game_draw() < 0) { printf("_game_draw_error"); return -1; } //2, //3, } return 0; }