Mercurial > hg > ristipolku
changeset 144:f01cb1ea26a5
Add some decorative animated elements.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 25 Nov 2011 13:48:02 +0200 |
parents | 5eea4719b429 |
children | 56aea6c89203 |
files | game/Engine.java |
diffstat | 1 files changed, 13 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/game/Engine.java Fri Nov 25 13:47:50 2011 +0200 +++ b/game/Engine.java Fri Nov 25 13:48:02 2011 +0200 @@ -230,7 +230,6 @@ public void startNewGame() { - board = new Piece[boardSize][boardSize]; board[boardMiddle][boardMiddle] = new Piece(PieceType.START); @@ -369,6 +368,13 @@ } pointElems = tmp; + + if (time % 32 == 1) + { + Random rnd = new Random(); + pointElems.add(new AnimatedPointElement( + new IDMPoint(10 + rnd.nextInt(400), 10 + rnd.nextInt(100)), ".")); + } } finally { @@ -581,7 +587,7 @@ MouseListener, MouseWheelListener { long startTime; - float gameClock, gameFrames; + float gameUpdates, gameFrames; Thread animThread; boolean animEnable = false; @@ -662,11 +668,11 @@ requestFocus(); } + gameUpdates = 0; } public void startNewGame() { - gameClock = 0; gameFrames = 0; startTime = new Date().getTime(); lauta.startNewGame(); @@ -831,15 +837,15 @@ while (animEnable) { // Progress game animation clock - gameClock++; + gameUpdates++; // Animate components - lauta.animate(gameClock); + lauta.animate(gameUpdates); if (lauta.nextPiece != null) - lauta.nextPiece.animate(gameClock); + lauta.nextPiece.animate(gameUpdates); // Repaint with a frame limiter - if (gameClock % 4 == 1) + if (gameUpdates % 4 == 1) repaint(); // Sleep for a moment