# HG changeset patch # User Matti Hamalainen # Date 1297906801 -7200 # Node ID aa15b2c556b40ed26bcac1201933e00efa0bb1ba # Parent 6f6c551cc14c382b4e81c851aa1454ef2bcbe8ac Add comments. diff -r 6f6c551cc14c -r aa15b2c556b4 game/Engine.java --- a/game/Engine.java Thu Feb 03 20:37:34 2011 +0200 +++ b/game/Engine.java Thu Feb 17 03:40:01 2011 +0200 @@ -231,8 +231,10 @@ public void pieceFinishTurn() { + // Do we have a piece? if (current != null) { + // Yes, place and lock it current.setType(PieceType.LOCKED); PathInfo i = resolvePath(moveX, moveY, movePoint, true); @@ -246,18 +248,24 @@ } } + // Create a new piece current = new Piece(PieceType.ACTIVE); + + // Find a place for it if (isEmpty(moveX, moveY)) { + // Current position is empty, use it board[moveX][moveY] = current; } else { + // Resolve path PathInfo i = resolvePath(moveX, moveY, movePoint, true); if (i != null) board[moveX][moveY] = current; else { + // Path ended up center/gameboard walls - it's game over, man System.out.print("pieceFinishTurn(): Game Over!\n"); flagGameOver = true; } @@ -465,6 +473,9 @@ snd(Sound.PIECE_PLACED).stop(); snd(Sound.PIECE_PLACED).play(); break; + + case KeyEvent.VK_ESCAPE: + break; } }