Example #1
0
 //helper method for rotating matrixes
 public void calculateBoundingPos(Vector2 origin)
 {
     for(int row = 0; row < boundingBox.GetLength(1); row++) {
         for(int col = 0; col < boundingBox.GetLength(0); col++) {
             boundingBox[row, col] = new TetSquare(new Vector2(origin.X + 30 * col, origin.Y + row * 30), boundingBox[row, col].isFilled);
         }
     }
 }
Example #2
0
        public TetBlock(Vector2 origin, Texture2D square)
        {
            this.position = origin;
            this.square = square;

            prevBox = boundingBox;

            for(int row = 0; row < boundingBox.GetLength(0); row++) {
                for(int col = 0; col < boundingBox.GetLength(1); col++) {
                    boundingBox[col, row] = new TetSquare();
                }
            }
        }
Example #3
0
        public TetBoard(int gridUnit)
        {
            for(int row = 0; row < tetBoard.Length; row++) {
                tetBoard[row] = new TetSquare[10];
            }

            for(int row = 0; row < tetBoard.Length; row++) {
                TetSquare[] innerArray = tetBoard[row];

                for(int col = 0; col < innerArray.Length; col++) {
                    innerArray[col] = new TetSquare(new Vector2(col * gridUnit, row * gridUnit), false);
                }
            }
        }
Example #4
0
        public SBlock(Vector2 origin, Texture2D square)
            : base(origin, square)
        {
            for(int row = 0; row < boundingBox.GetLength(1); row++) {
                for(int col = 0; col < boundingBox.GetLength(0); col++) {
                    boundingBox[row, col] = new TetSquare(square, new Vector2(90 + 30 * col, 0 + row * 30));
                }
            }

            boundingBox[0, 1].isFilled = true;
            boundingBox[0, 2].isFilled = true;
            boundingBox[1, 0].isFilled = true;
            boundingBox[1, 1].isFilled = true;
        }
Example #5
0
        public ZBlock(Vector2 origin, Texture2D square)
            : base(origin, square)
        {
            //initializes bounding box position
            for(int row = 0; row < boundingBox.GetLength(1); row++) {
                for(int col = 0; col < boundingBox.GetLength(0); col++) {
                    boundingBox[row, col] = new TetSquare(square, new Vector2(90 + 30 * col, 0 + row * 30));
                }
            }

            //initializes tetris shape in bounding box
            boundingBox[0, 0].isFilled = true;
            boundingBox[0, 1].isFilled = true;
            boundingBox[1, 1].isFilled = true;
            boundingBox[1, 2].isFilled = true;
        }
Example #6
0
        public LBlock(Vector2 origin, Texture2D square)
            : base(origin, square)
        {
            for(int row = 0; row < boundingBox.GetLength(1); row++) {
                for(int col = 0; col < boundingBox.GetLength(0); col++) {
                    boundingBox[row, col] = new TetSquare(square, new Vector2(90 + 30 * col, -30 + row * 30));
                }
            }

            boundingBox[0, 2].isFilled = true;
            boundingBox[1, 0].isFilled = true;
            boundingBox[1, 1].isFilled = true;
            boundingBox[1, 2].isFilled = true;

            //spawn coordinates
            //blockSquares[0].squarePosition = new Vector2(150, 0);
            //blockSquares[1].squarePosition = new Vector2(90, 30);
            //blockSquares[2].squarePosition = new Vector2(120, 30);
            //blockSquares[3].squarePosition = new Vector2(150, 30);
        }
Example #7
0
        public virtual void rotateRight(int n)
        {
            prevBox = boundingBox;
            Vector2 origin = boundingBox[0, 0].squarePosition;
            TetSquare[,] rotatedMatrix = new TetSquare[n, n];

            for(int row = 0; row < n; row++) {
                for(int col = 0; col < n; col++) {
                    rotatedMatrix[row, col] = boundingBox[n - col - 1, row];
                }
            }

            boundingBox = rotatedMatrix;
            calculateBoundingPos(origin);
            isValidRotation();
        }