Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public static NPoint Move(NPoint point, Direction direction)
        {
            switch (direction)
            {
            case Direction.Left:
                point.x -= 1;
                break;

            case Direction.Right:
                point.x += 1;
                break;

            case Direction.Down:
                point.y += 1;
                break;
            }
            return(point);
        }
Ejemplo n.º 3
0
 public static NPoint Move(NPoint point, Direction direction)
 {
     switch (direction) {
         case Direction.Left:
             point.x -= 1;
             break;
         case Direction.Right:
             point.x += 1;
             break;
         case Direction.Down:
             point.y += 1;
             break;
     }
     return point;
 }
Ejemplo n.º 4
0
 public static void Rotate(NPoint[] points, RtDirection direction)
 {
     for (int i = 0; i < points.Length; i++) {
         Rotate(ref points[i], direction);
     }
 }
Ejemplo n.º 5
0
 public static void Rotate(ref NPoint point, RtDirection direction)
 {
     point = Rotate(point, direction);
 }
Ejemplo n.º 6
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;
        }
Ejemplo n.º 7
0
 public static void Move(NPoint[] points, Direction direction)
 {
     for (int i = 0; i < points.Length; i++) {
         Move(ref points[i], direction);
     }
 }
Ejemplo n.º 8
0
 public static void Move(ref NPoint point, Direction direction)
 {
     point = Move(point, direction);
 }
Ejemplo n.º 9
0
        public Piece(Field field, int x, int y, PcType type, PcColor? color= null)
        {
            this.Field = field;
            this.pos = new NPoint(x, y);
            this.Color = color ?? PC_CLRS[(int)type];

            var PcShp = PC_SHPS[(int)type];
            this.Shape = new NPoint[PcShp.Length];
            PcShp.CopyTo(this.Shape, 0);
        }
Ejemplo n.º 10
0
 public static void Move(ref NPoint point, Direction direction)
 {
     point = Move(point, direction);
 }
Ejemplo n.º 11
0
 public static void Rotate(ref NPoint point, RtDirection direction)
 {
     point = Rotate(point, direction);
 }
Ejemplo n.º 12
0
 public void RotateTest()
 {
     var expected = new NPoint(-1 * target.y, 1 * target.x);
     Rotator.Rotate(ref target, RtDirection.Clockwise);
     Assert.AreEqual(expected, target);
 }
Ejemplo n.º 13
0
 public void BeginTestMethod()
 {
     target = new NPoint(2, 1);
 }