Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while (gameThreadRunning) {
- Canvas canvas = null;
- try {
- canvas = surfaceHolder.lockCanvas();
- synchronized (surfaceHolder) {
- if (gameIsRunning()) {
- if(lastTickTime == -1){
- lastTickTime = System.nanoTime() - 1;
- }
- currentTickTime = System.nanoTime();
- tickDelta = currentTickTime - lastTickTime;
- if (updateDelay > 0) {
- long updateDelayRemaining = tickDelta - updateDelay;
- if (updateDelayRemaining > 0) {
- // in that case we need to wait a bit longer before continuing
- // to respect the configured update delay
- try {
- Thread.sleep(TimeUnit.NANOSECONDS.toMillis(updateDelayRemaining));
- } catch (InterruptedException e) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement