Ejemplo n.º 1
0
        public static bool RightBounderyCollision(GameBlockNew block)
        {
            if (BounderyCoordinate(block.Brick1.Coordinate) == 0)
            {
                return(false);
            }

            if (BounderyCoordinate(block.Brick2.Coordinate) == 0)
            {
                return(false);
            }

            if (BounderyCoordinate(block.Brick3.Coordinate) == 0)
            {
                return(false);
            }

            if (BounderyCoordinate(block.Brick4.Coordinate) == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
 //Clears and resets the block data
 void clearBlock()
 {
     block                = randomize();
     preview              = randomize();
     setNormalbool        = true;
     score                = 0;
     level                = 1;
     multiplier           = 1;
     multiplierExpiration = 0;
     dropTime             = 45;
     dropCounter          = 0;
 }
Ejemplo n.º 4
0
        public GameBlockNew Copy()
        {
            GameBlockNew otherBlock = this.Create();

            otherBlock.rState = this.rState;

            otherBlock.Brick1 = this.Brick1.copy();
            otherBlock.Brick2 = this.Brick2.copy();
            otherBlock.Brick3 = this.Brick3.copy();
            otherBlock.Brick4 = this.Brick4.copy();

            return(otherBlock);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
        //This region contains the code for the main game update mehtod, fail state checking, and level setup and update.
        #region Update, Fail State, and Level Data
        void update(GameTime gameTime)
        {
            //If the block has reached the bootom or hit another block, check counter
            if (block.Brick4.Rect.Y == 298 || !MovementFunctions.BlockDropCollision(block, grid))
            {
                //If the update counter reaches 30, convert current block to grid, get new block, and check rows
                if (updateCounter == 30)
                {
                    gridFill();                  //Converts the block to the grid
                    block         = preview;     //Sets the preview block to the main block
                    preview       = randomize(); //Randomizes the next preview block
                    setNormalbool = true;
                    countRows();                 //Conts the number of blocks in a row
                    deleteBlocks();              //Deletes any full rows
                    updateMultiplier(gameTime);  //Updates the multiplier
                    updateScore(gameTime);       //Updates the score
                    levelUpdate(gameTime);       //Update the level
                    updateCounter = 0;           //Resets the counter
                }
                //Else update the counter
                else
                {
                    updateCounter++;
                }
            }
            //Else update counters
            else
            {
                reduceMultiplier(gameTime);
                dropCounter++;
                accelCounter++;
            }

            movementCounter++;
            failState();
        }
Ejemplo n.º 8
0
 void initializeBlocks()
 {
     block   = randomize();
     preview = randomize();
 }