Mercurial > hg > ristipolku
changeset 164:2b2fa62cfea5
Fix animation timing.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 01 Mar 2017 13:50:50 +0200 |
parents | dda7152d2402 |
children | 0303db4df28f |
files | game/Engine.java |
diffstat | 1 files changed, 4 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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)