/// <summary> /// Rotates the tetromino Counter clockwise /// </summary> public void RotateCounterClockwise() { switch (currentRotation) { case 0: this.currentRotationState = Tetromino.RotationState.Kick_0L; break; case 1: this.currentRotationState = Tetromino.RotationState.Kick_L2; break; case 2: this.currentRotationState = Tetromino.RotationState.Kick_2R; break; case 3: this.currentRotationState = Tetromino.RotationState.Kick_R0; break; } //C# does not have a "mathematically correct" version of the modulo operation, and is instead a remainder operation //That takes the sign of the dividend. if (--currentRotation == -1) { currentRotation = 3; } }
/// <summary> /// Rotates the tetromino Clockwise /// </summary> public void RotateClockwise() { switch (currentRotation) { case 0: this.currentRotationState = Tetromino.RotationState.Kick_0R; break; case 1: this.currentRotationState = Tetromino.RotationState.Kick_R2; break; case 2: this.currentRotationState = Tetromino.RotationState.Kick_2L; break; case 3: this.currentRotationState = Tetromino.RotationState.Kick_L0; break; } currentRotation = ++currentRotation % rotationMatrix.GetLength(0); }