35 lines
764 B
C
35 lines
764 B
C
#include "game.h"
|
|
|
|
#include <SDL3/SDL.h>
|
|
#include <stdlib.h>
|
|
|
|
game_t game;
|
|
|
|
static inline void update_time(void)
|
|
{
|
|
static uint64_t last_clock_state = 0;
|
|
uint64_t start_clock = SDL_GetTicksNS();
|
|
game.delta_time_ms = SDL_NS_TO_MS((float)(start_clock - last_clock_state));
|
|
if(game.delta_time_ms > 100.0f) game.delta_time_ms = 100.0f;
|
|
last_clock_state = start_clock;
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
int exit_status = EXIT_SUCCESS;
|
|
|
|
if(game_init()) exit_status = EXIT_FAILURE;
|
|
|
|
while(game.is_running)
|
|
{
|
|
update_time();
|
|
game_handle_event();
|
|
if(game_update()) exit_status = EXIT_FAILURE;
|
|
if(game_render()) exit_status = EXIT_FAILURE;
|
|
}
|
|
|
|
if(game_exit()) exit_status = EXIT_FAILURE;
|
|
|
|
return exit_status;
|
|
}
|