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

            Point[] Shape = currTetris.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)
            {
                currTetris.moveDown();
                currTetrisDraw();
            }
            else
            {
                currTetrisDraw();
                CheckRows();
                currTetris = new Tetramino();
            }
        }
Example #2
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].BorderBrush     = PurpleBrush;
                    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]);
                }
            }
            currTetris = new Tetramino();
            currTetrisDraw();
        }