# HG changeset patch # User Matti Hamalainen # Date 1488369050 -7200 # Node ID 2b2fa62cfea52e9e31e4a0df0d22b69085e86e79 # Parent dda7152d2402d65d83b09fa3d43d0b1e4ab13c22 Fix animation timing. diff -r dda7152d2402 -r 2b2fa62cfea5 game/Engine.java --- a/game/Engine.java Wed Mar 01 12:53:45 2017 +0200 +++ b/game/Engine.java Wed Mar 01 13:50:50 2017 +0200 @@ -592,7 +592,7 @@ implements Runnable, KeyListener, MouseListener, MouseWheelListener { - long startTime; + double startTime; float gameUpdates, gameFrames; Thread animThread; @@ -680,12 +680,12 @@ } gameUpdates = 0; + startTime = System.currentTimeMillis(); } public void startNewGame() { gameFrames = 0; - startTime = new Date().getTime(); lauta.startNewGame(); } @@ -852,7 +852,8 @@ gameUpdates++; // Animate components - lauta.animate(gameUpdates); + int tmp = (int) ((System.currentTimeMillis() - startTime) / 10f); + lauta.animate(tmp); // Repaint with a frame limiter if (gameUpdates % 4 == 1)