Esempio n. 1
0
 public void Drop(GameGrid grid)
 {
     if (Brick4.Rect.Y != 298 && MovementFunctions.BlockDropCollision(this, grid))
     {
         Brick1.Rect.Y += 16;
         Brick2.Rect.Y += 16;
         Brick3.Rect.Y += 16;
         Brick4.Rect.Y += 16;
     }
 }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        public void Move(int movementNumber, GameGrid grid)
        {
            if (MovementFunctions.LeftBounderyCollision(this) && movementNumber < 0 && MovementFunctions.LeftSideCollision(this, grid))
            {
                Brick1.Rect.X -= 16;
                Brick2.Rect.X -= 16;
                Brick3.Rect.X -= 16;
                Brick4.Rect.X -= 16;
            }

            if (MovementFunctions.RightBounderyCollision(this) && movementNumber > 0 && MovementFunctions.RightSideCollision(this, grid))
            {
                Brick1.Rect.X += 16;
                Brick2.Rect.X += 16;
                Brick3.Rect.X += 16;
                Brick4.Rect.X += 16;
            }
        }
        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);
            }
        }