//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); } } }
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(); } } }
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); } } }
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; }
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; }
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); }
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(); }