Example #1
0
        //Description: Check to see if the current shape in play has hit something
        public bool CheckCollision(Shape theShape)
        {
            for (int aBlock = 0; aBlock < mNumberOfBlocks; aBlock++)
            {
                if (theShape.PositionX < 0)
                {
                    return true;
                }

                //Check to see if one of the blocks that make up a shape is moving outside of the width or height of
                //the established playing area
                if (((theShape.PositionX + theShape.CurrentShape[theShape.Rotation, aBlock, 0] > mWidth - 1) | (theShape.PositionY + theShape.CurrentShape[theShape.Rotation, aBlock, 1] > mHeight - 1)))
                {
                    return true;
                }

                //If the current shapes position is outside of the top of the playing area, then
                //indicate that the game is over
                if (theShape.PositionY < 0)
                {
                    //base.myStage = eStage.GameOver;
                    return true;
                }
                if ((mPlayfield[theShape.PositionX + theShape.CurrentShape[theShape.Rotation, aBlock, 0], theShape.PositionY + theShape.CurrentShape[theShape.Rotation, aBlock, 1]] >= 0))
                {
                    return true;
                }
            }
            return false;
        }
Example #2
0
        //Description: Add a shape to the playfield
        public void AddShape(Shape theShape)
        {
            if (theShape.PositionY > mHeight - 1)
            {
                theShape.PositionY = mHeight;
            }

            //Construct a piece in the playing area and color it the current color
            for (int aBlock = 0; aBlock < mNumberOfBlocks; aBlock++)
            {
                mPlayfield[theShape.PositionX + theShape.CurrentShape[theShape.Rotation, aBlock, 0], theShape.PositionY + theShape.CurrentShape[theShape.Rotation, aBlock, 1] - 1] = theShape.Color;
            }
        }