public static bool BlockDropCollision(GameBlockNew block, GameGrid grid) { int i = 0; int j = 0; CalculateCoordinates(block.Brick1.Coordinate, out i, out j); if (grid.GetCell(i, j + 1).squareFilled) { return(false); } CalculateCoordinates(block.Brick2.Coordinate, out i, out j); if (grid.GetCell(i, j + 1).squareFilled) { return(false); } CalculateCoordinates(block.Brick3.Coordinate, out i, out j); if (grid.GetCell(i, j + 1).squareFilled) { return(false); } CalculateCoordinates(block.Brick4.Coordinate, out i, out j); if (grid.GetCell(i, j + 1).squareFilled) { return(false); } else { return(true); } }
public void FillGridCells(GameGrid grid) { int i, j; MovementFunctions.CalculateCoordinates(Brick1.Coordinate, out i, out j); Brick1.fillGridCell(grid.GetCell(i, j)); MovementFunctions.CalculateCoordinates(Brick2.Coordinate, out i, out j); Brick2.fillGridCell(grid.GetCell(i, j)); MovementFunctions.CalculateCoordinates(Brick3.Coordinate, out i, out j); Brick3.fillGridCell(grid.GetCell(i, j)); MovementFunctions.CalculateCoordinates(Brick4.Coordinate, out i, out j); Brick4.fillGridCell(grid.GetCell(i, j)); }
public static bool RotationCollision(GameBlockNew block, GameGrid grid) { GameBlockNew rotatedBlock; bool temp = true; int i = 0; int j = 0; if (block.Brick1.Coordinate <= 10 || block.Brick2.Coordinate > 180) { temp = false; return(temp); } rotatedBlock = block.Copy(); rotatedBlock.Rotate(); CalculateCoordinates(rotatedBlock.Brick1.Coordinate, out i, out j); if (grid.GetCell(i, j).squareFilled) { temp = false; } CalculateCoordinates(rotatedBlock.Brick2.Coordinate, out i, out j); if (grid.GetCell(i, j).squareFilled) { temp = false; } CalculateCoordinates(rotatedBlock.Brick3.Coordinate, out i, out j); if (grid.GetCell(i, j).squareFilled) { temp = false; } CalculateCoordinates(rotatedBlock.Brick4.Coordinate, out i, out j); if (grid.GetCell(i, j).squareFilled) { temp = false; } return(temp); }
public static bool RightSideCollision(GameBlockNew block, GameGrid grid) { int i = 0; int j = 0; if (block.Brick2.Rect.X < 138) { CalculateCoordinates(block.Brick1.Coordinate, out i, out j); if (grid.GetCell(i + 1, j).squareFilled) { return(false); } CalculateCoordinates(block.Brick2.Coordinate, out i, out j); if (grid.GetCell(i + 1, j).squareFilled) { return(false); } CalculateCoordinates(block.Brick3.Coordinate, out i, out j); if (grid.GetCell(i + 1, j).squareFilled) { return(false); } CalculateCoordinates(block.Brick4.Coordinate, out i, out j); if (grid.GetCell(i + 1, j).squareFilled) { return(false); } else { return(true); } } else { return(true); } }
void initializeGrid() { int coordinateCounter = 1; for (int i = 0; i < 19; i++) { for (int j = 0; j < 10; j++) { grid.GetCell(j, i).square = new Rectangle(9 + (16 * j), 10 + (16 * i), 16, 16); grid.GetCell(j, i).coordinate = coordinateCounter; grid.GetCell(j, i).brick = this.Content.Load <Texture2D>("Clear Brick"); coordinateCounter++; } } }