Created
March 24, 2019 13:40
-
-
Save ifshuaishuai/ff242f0999dba54fd554930aed9ddf9c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void RunBad() | |
{ | |
var sw = new Stopwatch(); | |
int ticks = 0; | |
while (true) | |
{ | |
sw.Restart(); | |
Thread.Sleep(TimePerFrame - ticks); | |
ticks = (int)(ticks + sw.ElapsedMilliseconds); | |
while (ticks >= TimePerFrame) | |
{ | |
Update(TimePerFrame); | |
ticks -= TimePerFrame; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment