# HG changeset patch # User Matti Hamalainen # Date 1299170801 -7200 # Node ID eb2e72dd8caeb3a3edaebaed32adb88f2bca3eba # Parent 8d5cb9e5830124f70aea912097514c48e002208f Change how piece rotation works. diff -r 8d5cb9e58301 -r eb2e72dd8cae game/Piece.java --- a/game/Piece.java Thu Mar 03 18:36:16 2011 +0200 +++ b/game/Piece.java Thu Mar 03 18:46:41 2011 +0200 @@ -15,7 +15,7 @@ public enum RotateDir { LEFT, RIGHT } static final int numConnections = 8; - static final float maxTime = 35.0f; + static final float maxTime = 50.0f; int currRotation; int[] connections; @@ -42,8 +42,8 @@ rotationChanged = false; rotationActive = false; - currRotation = 0; - currAngle = 0; + currRotation = 4 * 5000; + currAngle = getAngle(currRotation); typeChanged = false; typeActive = false; @@ -91,16 +91,21 @@ stateChanged = true; } + public int getRotation() + { + return currRotation % 4; + } + public int getRotatedPoint(int in) { - int point = (in - (currRotation * 2)) % 8; + int point = (in - (getRotation() * 2)) % 8; if (point < 0) point = 8 + point; return point; } public int getAntiRotatedPoint(int in) { - int point = (in + (currRotation * 2)) % 8; + int point = (in + (getRotation() * 2)) % 8; if (point < 0) point = 8 + point; return point; } @@ -135,6 +140,11 @@ { return connections[point]; } + + private float getAngle(float rotation) + { + return (float) ((rotation * Math.PI) / 2.0f); + } public void rotate(RotateDir dir) { @@ -142,8 +152,8 @@ if (type != PieceType.LOCKED && type != PieceType.ACTIVE) return; - currRotation = (currRotation + (dir == RotateDir.RIGHT ? 1 : -1)) % 4; - newAngle = (float) ((currRotation * Math.PI) / 2.0f); + currRotation = (currRotation + (dir == RotateDir.RIGHT ? 1 : -1)); + newAngle = getAngle(currRotation); lerpRotation = new Interpolate(newAngle, currAngle, maxTime); rotationChanged = true; } @@ -197,12 +207,12 @@ rotationTime = time; rotationActive = true; rotationChanged = false; - rotationSpeed = 0.5f; + rotationSpeed = 1.0f; } if (typeChanged && type == PieceType.LOCKED) { - rotationSpeed = 1.0f; + rotationSpeed = 1.5f; } if (rotationActive)