Beispiel #1
0
        private void EraseStackedBlocks()
        {
            int erasedRowNumber        = 0;
            int topErasedRowNumber     = 0;
            ParameterComparer comparer = new ParameterComparer();

            for (int indexY = MyTetrisForm.frameLimitY; indexY >= 0; indexY--)
            {
                for (int indexX = 0; indexX < MyTetrisForm.frameLimitX; indexX++)
                {
                    int[] point = new int[] { indexX, indexY };
                    if (!this.stackedBlockPosition.Contains(point, comparer))
                    {
                        break;
                    }
                    if (indexX == MyTetrisForm.frameLimitX - 1)
                    {
                        this.stackedBlockPosition = this.stackedBlockPosition.Where(sepBlockPoint => sepBlockPoint[1] != indexY).ToList();
                        erasedRowNumber          += 1;
                        topErasedRowNumber        = indexY;
                    }
                }
            }
            Invalidate();
            DropStackedBlocks(erasedRowNumber, topErasedRowNumber);
            this.score          += (100 * erasedRowNumber);
            this.ScoreLabel.Text = this.score.ToString();
        }
Beispiel #2
0
        private void Draw(object sender, PaintEventArgs e)
        {
            Pen blackPen = new Pen(Color.Black, 1);
            ParameterComparer comparer = new ParameterComparer();

            for (int y = 0; y < MyTetrisForm.frameLimitY; y += 1)
            {
                for (int x = 0; x < MyTetrisForm.frameLimitX; x += 1)
                {
                    int[] point = new int[] { x, y };
                    if (this.stackedBlockPosition.Contains(point, comparer))
                    {
                        e.Graphics.FillRectangle(this.brushList[y][x], this.board[y][x]);
                        e.Graphics.DrawRectangle(blackPen, this.board[y][x]);
                    }
                    else if (IsContainesPoint(point))
                    {
                        e.Graphics.FillRectangle(myBlockBrush, this.board[y][x]);
                        e.Graphics.DrawRectangle(blackPen, this.board[y][x]);
                    }
                    else
                    {
                        e.Graphics.DrawRectangle(blackPen, this.board[y][x]);
                    }
                }
            }
        }
Beispiel #3
0
        private bool IsOperatingBlockInsideFrame(int[][] operatingBlockPosition, int yMovingDistance, bool isBlockInitial = false)
        {
            ParameterComparer comparer = new ParameterComparer();

            for (int oneDimensionalIndex = 0; oneDimensionalIndex < operatingBlockPosition.GetLength(0); oneDimensionalIndex++)
            {
                int[] sepBlockPosition = operatingBlockPosition[oneDimensionalIndex];
                if (sepBlockPosition[0] >= MyTetrisForm.frameLimitX || sepBlockPosition[0] < 0)
                {
                    return(false);
                }

                if (sepBlockPosition[1] >= MyTetrisForm.frameLimitY)
                {
                    StackOperatingBlockPosition();
                    return(false);
                }

                if (this.stackedBlockPosition.Contains(sepBlockPosition, comparer))
                {
                    if (isBlockInitial)
                    {
                        return(false);
                    }

                    if (yMovingDistance > 0) //縦方向の移動
                    {
                        StackOperatingBlockPosition();
                        return(false);
                    }
                    else //横方向の移動
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }