Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.13 KB | None | 0 0
  1.         while (gameThreadRunning) {
  2.             Canvas canvas = null;
  3.             try {
  4.                 canvas = surfaceHolder.lockCanvas();
  5.                 synchronized (surfaceHolder) {
  6.                     if (gameIsRunning()) {
  7.                         if(lastTickTime == -1){
  8.                             lastTickTime = System.nanoTime() - 1;
  9.                         }
  10.                         currentTickTime = System.nanoTime();
  11.                         tickDelta = currentTickTime - lastTickTime;
  12.  
  13.                         if (updateDelay > 0) {
  14.                             long updateDelayRemaining = tickDelta - updateDelay;
  15.                             if (updateDelayRemaining > 0) {
  16.                                 // in that case we need to wait a bit longer before continuing
  17.                                 // to respect the configured update delay
  18.                                 try {
  19.                                     Thread.sleep(TimeUnit.NANOSECONDS.toMillis(updateDelayRemaining));
  20.                                 } catch (InterruptedException e) {
  21.                                 }
  22.                             }
  23.                         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement