Example #1
0
 public static void Rotate(NPoint[] points, RtDirection direction)
 {
     for (int i = 0; i < points.Length; i++)
     {
         Rotate(ref points[i], direction);
     }
 }
Example #2
0
        public static NPoint Rotate(NPoint point, RtDirection direction) // A clockwise rotation matrix in the screen coordinate system
        {
            int a01 = (direction == RtDirection.Clockwise) ? -1 : 1;     // (a00, a01) = (cos(pi/2), -sin(pi/2))
            int a10 = (direction == RtDirection.Clockwise) ? 1 : -1;     // (a10, a11) = (sin(pi/2),   cos(pi/2))

            int tx = point.x;

            point.x = a01 * point.y;
            point.y = a10 * tx;
            return(point);
        }
Example #3
0
        public bool Rotate(RtDirection direction)
        {
            Field.RemovePiece(this);
            bool rotated = false;

            if (canRotate(direction))
            {
                Rotator.Rotate(Shape, direction);
                rotated = true;
            }

            Field.PutPiece(this);
            Field.Draw();
            return(rotated);
        }
Example #4
0
        private bool canRotate(RtDirection direction)
        {
            int COLS = Field.COLS, ROWS = Field.ROWS;

            foreach (NPoint pt in Shape)
            {
                var tpt = this.pos + Rotator.Rotate(pt, direction);

                if (Field[tpt.x, tpt.y] != PcColor.None)
                {
                    return(false);
                }
            }

            return(true);
        }
Example #5
0
        public bool RotatePiece(RtDirection direction)
        {
            bool rotated = piece.Rotate(direction);

            return(rotated);
        }
Example #6
0
 public static void Rotate(NPoint[] points, RtDirection direction)
 {
     for (int i = 0; i < points.Length; i++) {
         Rotate(ref points[i], direction);
     }
 }
Example #7
0
 public static void Rotate(ref NPoint point, RtDirection direction)
 {
     point = Rotate(point, direction);
 }
Example #8
0
        public static NPoint Rotate(NPoint point, RtDirection direction)
        {
            // A clockwise rotation matrix in the screen coordinate system
            int a01 = (direction == RtDirection.Clockwise) ? -1 : 1; // (a00, a01) = (cos(pi/2), -sin(pi/2))
            int a10 = (direction == RtDirection.Clockwise) ? 1 : -1; // (a10, a11) = (sin(pi/2),   cos(pi/2))

            int tx = point.x;
            point.x = a01 * point.y;
            point.y = a10 * tx;
            return point;
        }
Example #9
0
        private bool canRotate(RtDirection direction)
        {
            int COLS = Field.COLS, ROWS = Field.ROWS;

            foreach (NPoint pt in Shape) {
                var tpt = this.pos + Rotator.Rotate(pt, direction);

                if (Field[tpt.x, tpt.y] != PcColor.None) {
                   return false;
                }
            }

            return true;
        }
Example #10
0
        public bool Rotate(RtDirection direction)
        {
            Field.RemovePiece(this);
            bool rotated = false;

            if (canRotate(direction)) {
                Rotator.Rotate(Shape, direction);
                rotated = true;
            }

            Field.PutPiece(this);
            Field.Draw();
            return rotated;
        }
Example #11
0
 public static void Rotate(ref NPoint point, RtDirection direction)
 {
     point = Rotate(point, direction);
 }
Example #12
0
 public bool RotatePiece(RtDirection direction)
 {
     bool rotated = piece.Rotate(direction);
     return rotated;
 }