Skip to content

Instantly share code, notes, and snippets.

@ifshuaishuai
Created March 24, 2019 13:40
Show Gist options
  • Save ifshuaishuai/ff242f0999dba54fd554930aed9ddf9c to your computer and use it in GitHub Desktop.
Save ifshuaishuai/ff242f0999dba54fd554930aed9ddf9c to your computer and use it in GitHub Desktop.
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