Пример #1
0
        public Board(Grid TetrisGrid)
        {
            rows = TetrisGrid.RowDefinitions.Count;
            cols = TetrisGrid.ColumnDefinitions.Count;
            score = 0;
            linesFilled = 0;

            blockControls = new Label[cols, rows];

            for (int i = 0; i < cols; i++)
            {
                for (int j = 0; j < rows; j++)
                {
                    blockControls[i, j] = new Label();
                    blockControls[i, j].Background = NoBrush;
                    blockControls[i, j].BorderThickness = new Thickness(1, 1, 1, 1);

                    Grid.SetColumn(blockControls[i, j], j);
                    Grid.SetRow(blockControls[i, j], i);
                    TetrisGrid.Children.Add((blockControls[i, j]));
                }
            }

            currTetrimino = new Tetrimino();
            currTetriminoDraw();
        }
Пример #2
0
        public void CurrTetriminoMoveDown()
        {
            Point position = currTetrimino.getCurrPosition();
            Point[] shape = currTetrimino.getCurrentShape();
            bool move = true;
            currTetriminoErase();

            foreach (Point s in shape)
            {
                if (((int)(s.Y + position.Y) + 2 + 1) >= rows)
                {
                    move = false;
                }
                else if (blockControls[((int)(s.X + position.X) + ((cols / 2)-1)), (int)(s.Y + position.Y) + 2 + 1].Background != NoBrush)
                {
                    move = false;
                }
            }

            if (move)
            {
                currTetrimino.moveDown();
                currTetriminoDraw();
            }
            else
            {
                currTetriminoDraw();
                CheckRows();
                currTetrimino = new Tetrimino();
            }
        }