changeset 53:6bf4675e2d96

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 23 Feb 2011 16:58:21 +0200
parents 01851bae3da3
children cc7943cd7f2d
files game/Engine.java
diffstat 1 files changed, 13 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/game/Engine.java	Wed Feb 23 11:50:18 2011 +0200
+++ b/game/Engine.java	Wed Feb 23 16:58:21 2011 +0200
@@ -142,9 +142,9 @@
         }
     }
 
-    public boolean pieceCheck(Piece curr)
+    public boolean pieceCheck(Piece piece)
     {
-        if (curr == null)
+        if (piece == null)
         {
             // Create new piece
             currPiece = new Piece(PieceType.ACTIVE);
@@ -152,14 +152,12 @@
             return true;
         }
         else
-        if (curr.getType() == PieceType.START)
+        if (piece.getType() == PieceType.START)
         {
             if (currPiece != null)
             {
                 // Hit center starting piece, game over
                 flagGameOver = true;
-                currPiece = null;
-                System.out.print("GameOver!\n");
                 return true;
             }
             else
@@ -173,16 +171,16 @@
         }
 
         // Mark the current piece as locked
-        curr.setType(PieceType.LOCKED);
+        piece.setType(PieceType.LOCKED);
 
         // Solve connection (with rotations) through the piece
-        currPoint = curr.getRotatedPoint(curr.getMatchingPoint(currPoint));
+        currPoint = piece.getRotatedPoint(piece.getMatchingPoint(currPoint));
 
         // Mark connection as active
-        curr.setConnectionState(currPoint, true);
+        piece.setConnectionState(currPoint, true);
 
         // Solve exit point (with rotations)
-        currPoint = curr.getAntiRotatedPoint(curr.getConnection(currPoint));
+        currPoint = piece.getAntiRotatedPoint(piece.getConnection(currPoint));
 
         // Move to next position accordingly
         pieceMoveTo(currPoint);
@@ -203,10 +201,14 @@
                 // Outside of the board, game over
                 finished = true;
                 flagGameOver = true;
-                currPiece = null;
-                System.out.print("GameOver!\n");
             }
         }
+        
+        if (flagGameOver)
+        {
+            currPiece = null;
+            System.out.print("GameOver!\n");
+        }
     }
 
     public boolean keyPressed(KeyEvent e)