Mercurial > hg > ristipolku
diff game/Piece.java @ 26:3d4cc47df31a
Cleanups, fix piece rendering and rotation.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 01 Feb 2011 19:18:25 +0200 |
parents | df494a65bf8c |
children | 26adc2827983 |
line wrap: on
line diff
--- a/game/Piece.java Tue Feb 01 18:05:19 2011 +0200 +++ b/game/Piece.java Tue Feb 01 19:18:25 2011 +0200 @@ -50,6 +50,7 @@ for (int i = 0; i < numConnections; i++) connections[i] = -1; + // Randomize connections in the piece Random rnd = new Random(); for (int i = 0; i < numConnections; i++) @@ -57,7 +58,7 @@ while (connections[i] < 0) { int tmp = rnd.nextInt(numConnections); - if (connections[tmp] < 0) + if (tmp != i && connections[tmp] < 0) { connections[i] = tmp; connections[tmp] = i; @@ -89,9 +90,9 @@ if (type != PieceType.LOCKED && type != PieceType.ACTIVE) return; - currRotation = (currRotation + (dir ? -1 : 1)) % 4; + currRotation = (currRotation + (dir ? 1 : -1)) % 4; newAngle = (float) ((currRotation * Math.PI) / 2.0f); - lerpRotation = new Interpolate(currAngle, newAngle, maxTime); + lerpRotation = new Interpolate(newAngle, currAngle, maxTime); rotationChanged = true; } @@ -164,11 +165,7 @@ public void paint(Graphics2D g, float x, float y, float dim) { -// AffineTransform tf = new AffineTransform(); g.rotate(currAngle, x + dim / 2.0f, y + dim / 2.0f); -// g.transform(tf); - -// if (type == PieceType.ACTIVE) System.out.print("angle = " + currAngle + "\n"); switch (type) { case LOCKED: g.setPaint(Color.green); break;