Fix Delay compensation
This commit is contained in:
		
							parent
							
								
									4da430a02b
								
							
						
					
					
						commit
						e4f7fca02d
					
				| 
						 | 
				
			
			@ -26,19 +26,20 @@ pub fn main() !void {
 | 
			
		|||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const start = SDL.getTicks64();
 | 
			
		||||
 | 
			
		||||
        current_state = switch (current_state) {
 | 
			
		||||
            .main_menu => main_menu.tick(),
 | 
			
		||||
            .game => game.tick(),
 | 
			
		||||
        };
 | 
			
		||||
        const start = SDL.getTicks64();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        renderer.render();
 | 
			
		||||
 | 
			
		||||
        const delay = SDL.getTicks64() - start;
 | 
			
		||||
        std.debug.print("{} ms\n", .{delay});
 | 
			
		||||
        if (delay < 16) {
 | 
			
		||||
            SDL.delay(16 - @intCast(u32, delay));
 | 
			
		||||
        if (delay < 15) {
 | 
			
		||||
            SDL.delay(15 - @intCast(u32, delay));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue