Example #1
0
        public void CurrTetraminoMoveDown()
        {
            Point Position = currTetramino.getCurrPosition();

            Point[] Shape = currTetramino.getCurrShape();
            bool    move  = true;

            currTetraminoErase();
            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)
            {
                currTetramino.movDown();
                currTetraminoDraw();
            }
            else
            {
                currTetraminoDraw();
                CheckRows();
                currTetramino = new Tetramino();
            }
        }
Example #2
0
        public Board(Grid TetrisGrid)
        {
            Rows       = TetrisGrid.RowDefinitions.Count;
            Cols       = TetrisGrid.ColumnDefinitions.Count;
            Score      = 0;
            LineFilled = 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].BorderBrush     = SilverBrush;
                    BlockControls[i, j].BorderThickness = new Thickness(1, 1, 1, 1);
                    Grid.SetRow(BlockControls[i, j], j);
                    Grid.SetColumn(BlockControls[i, j], i);
                    TetrisGrid.Children.Add(BlockControls[i, j]);
                }
            }
            currTetramino = new Tetramino();
            currTetraminoDraw();
        }