# HG changeset patch # User Matti Hamalainen # Date 1322221682 -7200 # Node ID f01cb1ea26a56797fa76a5832b1282dcaa7aa553 # Parent 5eea4719b429c14ad171e227c97db75c3072fc45 Add some decorative animated elements. diff -r 5eea4719b429 -r f01cb1ea26a5 game/Engine.java --- 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