changeset 45:79185dababf2

Add comments.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 22 Feb 2011 06:30:11 +0200
parents 698c6bcc4aec
children 3e8d1c30f573
files game/Piece.java
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/game/Piece.java	Tue Feb 22 06:03:51 2011 +0200
+++ b/game/Piece.java	Tue Feb 22 06:30:11 2011 +0200
@@ -230,8 +230,10 @@
 
     public void paint(Graphics2D g, float x, float y, float dim)
     {
+        // Transform drawing by current angle
         g.rotate(currAngle, x + dim / 2.0f, y + dim / 2.0f);
 
+        // Color piece by type
         switch (type) {
             case LOCKED:  g.setPaint(Color.green); break;
             case ACTIVE:  g.setPaint(Color.red); break;
@@ -240,10 +242,11 @@
 
         g.fill(new RoundRectangle2D.Float(x, y, dim, dim, dim / 10, dim / 10));
 
-
+        // Start pieces (center piece) do not have border, etc.
         if (type == PieceType.START)
             return;
 
+        // Active piece has a throbbing "ghost" border
         if (type == PieceType.ACTIVE)
         {
             float offs1 = throbTime * 10.0f,
@@ -251,12 +254,15 @@
 
             g.setPaint(new Color(0.0f, 0.0f, 0.0f, (float) (1.0f - throbTime) ));
             g.setStroke(new BasicStroke(2.0f + throbTime * 2.0f));
-            g.draw(new RoundRectangle2D.Float(x - offs1, y - offs1, dim + offs2, dim + offs2, dim / 10, dim / 10));
+            g.draw(new RoundRectangle2D.Float(
+                x - offs1, y - offs1,
+                dim + offs2, dim + offs2,
+                dim / 10, dim / 10));
         }
 
+        // Draw the connections
         g.setStroke(new BasicStroke(5.0f));
         CubicCurve2D c = new CubicCurve2D.Float();
-//        QuadCurve2D c = new QuadCurve2D.Float();
         boolean[] drawn = new boolean[numConnections];
         for (int i = 0; i < numConnections; i++)
         if (!drawn[i])
@@ -275,10 +281,12 @@
             c.setCurve(start, cp1, cp2, end);
             g.draw(c);
 
+            // Mark connection drawn, so we don't overdraw
             drawn[i] = true;
             drawn[connections[i]] = true;
         }
 
+        // Draw piece border
         g.setPaint(Color.black);
         g.setStroke(new BasicStroke(5.0f));
         g.draw(new RoundRectangle2D.Float(x, y, dim, dim, dim / 10, dim / 10));