var
next_time : UInt32 = 0;
const
TICK_INTERVAL = 30;
function TimeLeft : UInt32;
var
now : UInt32;
begin
now := SDL_GetTicks;
if ( next_time <= now ) then
begin
next_time := now + TICK_INTERVAL;
result := 0;
exit;
end;
result := next_time - now;
end;
// main game loop
while ( game_running ) do
begin
UpdateGameState;
SDL_Delay( TimeLeft );
end;