changeset 3:b8fd19e2d879

Indentation.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 28 Jan 2011 16:59:36 +0200
parents 1785f66a7beb
children e0e8fd08331e
files game/Piece.java
diffstat 1 files changed, 64 insertions(+), 60 deletions(-) [+]
line wrap: on
line diff
--- a/game/Piece.java	Fri Jan 28 16:53:06 2011 +0200
+++ b/game/Piece.java	Fri Jan 28 16:59:36 2011 +0200
@@ -13,79 +13,83 @@
 
 public class Piece
 {
-   static final int numConnections = 8;
-   static final int minRotation = 0;
-   static final int maxRotation = 3;
-   int currRotation;
-   int[] connections;
-   PieceType type, oldType;
+    static final int numConnections = 8;
+    static final int minRotation = 0;
+    static final int maxRotation = 3;
+    int currRotation;
+    int[] connections;
+    PieceType type, oldType;
 
-   boolean rotationChanged, rotationActive,
-           typeChanged, typeActive;
-   double currAngle, newAngle;
+    boolean rotationChanged, rotationActive,
+            typeChanged, typeActive;
+    double currAngle, newAngle;
 
-   
-   public Piece(PieceType ptype)
-   {
-      // Initialize
-      connections = new int[numConnections];
-      type = ptype;
+    public Piece(PieceType ptype)
+    {
+        // Initialize
+        connections = new int[numConnections];
+        type = ptype;
 
-      rotationChanged = false;
-      typeChanged = false;
-      rotationActive = false;
-      typeActive = false;
+        rotationChanged = false;
+        typeChanged = false;
+        rotationActive = false;
+        typeActive = false;
       
+        currRotation = 0;
+        currAngle = 0;
 
-      currRotation = 0;
 
-      // Initialize connections between endpoints of the paths inside the piece
-      for (int i = 0; i < numConnections; i++)
-         connections[i] = -1;
+        // Initialize connections between endpoints of the paths inside the piece
+        for (int i = 0; i < numConnections; i++)
+            connections[i] = -1;
 
-      Random rnd = new Random();
-      for (int i = 0; i < numConnections; i++)
-      {
-         int tmp = rnd.nextInt(numConnections);
-         if (connections[tmp] < 0 && connections[i] < 0)
-         {
-            connections[i] = tmp;
-            connections[tmp] = i;
-         }
-      }
-   }
-   
-   public Piece()
-   {
-      this(PieceType.NONE);
-   }
+        Random rnd = new Random();
+        for (int i = 0; i < numConnections; i++)
+        {
+            while (connections[i] < 0)
+            {
+                int tmp = rnd.nextInt(numConnections);
+                if (connections[tmp] < 0)
+                {
+                    connections[i] = tmp;
+                    connections[tmp] = i;
+                }
+            }
+        }
+    }
+
+    public Piece()
+    {
+        this(PieceType.NONE);
+    }
 
-   public void setType(PieceType ptype)
-   {
-      oldType = type;
-      type = ptype;
-   }
+    public void setType(PieceType ptype)
+    {
+        typeChanged = (oldType != ptype);
+        oldType = type;
+        type = ptype;
+    }
 
-   public int getConnection(int in)
-   {
-      return connections[in];
-   }
+    public int getConnection(int in)
+    {
+        return connections[in];
+    }
    
-   public void rotate(boolean dir)
-   {
-      if (type != PieceType.NORMAL)
-         return;
+    public void rotate(boolean dir)
+    {
+        if (type != PieceType.NORMAL)
+            return;
 
-      newRotation = currRotation + (dir ? 1 : -1);
+        newRotation = currRotation + (dir ? 1 : -1);
 
-      if (newRotation < minRotation)
-         newRotation = maxRotation;
-      else if (currRotation > maxRotation)
-         newRotation = minRotation;
+        if (newRotation < minRotation)
+            newRotation = maxRotation;
+        else if (currRotation > maxRotation)
+            newRotation = minRotation;
 
-      rotationDir = dir;
-      rotationChanged = true;
-   }
+        rotationDir = dir;
+        rotationChanged = true;
+     }
          
    public Point2D getPoint(double x, double y, double dim, int index)
    {