예제 #1
0
        /// <summary>
        /// Moves current block down
        /// </summary>
        private void StepDown()
        {
            // Check whether block can fall down
            if (Check(currentBlock, blockX, blockY + 1))
            {
                blockY++;
                return;
            }

            // We reached the field-bottom
            // Set block as part of the field
            for (int row = 0; row < currentBlock.Rows; row++)
            {
                for (int col = 0; col < currentBlock.Columns; col++)
                {
                    byte value = currentBlock.GetCell(row, col);
                    if (value != 0)
                    {
                        field.SetCell(row + blockY, col + blockX, value);
                    }
                }
            }

            // Find and remove all full lines
            ProcessFullLines();

            // Get new block
            NewBlock();
        }
예제 #2
0
        /// <summary>
        /// Rotate current block
        /// </summary>
        public void Rotate()
        {
            ByteMatrix rotated = new ByteMatrix(currentBlock.Columns, currentBlock.Rows);

            // Rotate the object
            for (int row = 0; row < currentBlock.Rows; row++)
            {
                for (int col = 0; col < currentBlock.Columns; col++)
                {
                    rotated.SetCell(rotated.Rows - col - 1, row, currentBlock.GetCell(row, col));
                }
            }

            // Check whether rotate object fits the field
            if (Check(rotated, blockX, blockY))
            {
                currentBlock = new ByteMatrix(rotated);
            }
        }
예제 #3
0
        /// <summary>
        /// Rotate current block
        /// </summary>
        public void Rotate()
        {
            ByteMatrix rotated = new ByteMatrix(currentBlock.Columns, currentBlock.Rows);

            // Rotate the object
            for (int row = 0; row < currentBlock.Rows; row++)
                for (int col = 0; col < currentBlock.Columns; col++)
                    rotated.SetCell(rotated.Rows - col - 1, row, currentBlock.GetCell(row, col));

            // Check whether rotate object fits the field
            if (Check(rotated, blockX, blockY))
                currentBlock = new ByteMatrix(rotated);
        }