Exemplo n.º 1
0
        private void UpdateFigures()
        {
            foreach (Rect rect in NowFigure.CloneRects())
            {
                Rects.Add(rect);
                IfCellsFree[rect.Point] = false;
            }



            NowFigure = new Figure(PicBoxSizeClass.PointForFigure(), PicBoxSizeClass.RectSize, PicBoxSizeClass.MarginSize, nNextFigure);

            foreach (Rect rect in NowFigure.Rects)
            {
                if (!IfCellsFree[rect.Point])
                {
                    Restart();
                    return;
                }
            }

            nNextFigure = RandomNumber(1, 8);
            NextFigure  = new Figure(new Point(pictureBox2.Width / 2, pictureBox2.Height / 4), 20, 3, nNextFigure);
            pictureBox2.Invalidate();
            Score          += 1;
            ScoreLabel.Text = "Score: " + Score.ToString();
        }
Exemplo n.º 2
0
 private void Restart()
 {
     UpdatePicBox();
     Rects.Clear();
     nNextFigure            = RandomNumber(1, 8);
     NextFigure             = new Figure(new Point(pictureBox2.Width / 2, pictureBox2.Height / 4), 20, 3, RandomNumber(1, 8));
     NowFigure              = new Figure(PicBoxSizeClass.PointForFigure(), PicBoxSizeClass.RectSize, PicBoxSizeClass.MarginSize, RandomNumber(1, 7));
     StartButton.Text       = "Start";
     Pause                  = true;
     PicBoxSizeClass.Record = Score;
     Score                  = 0;
     ScoreLabel.Text        = "Score: " + Score.ToString();
     RecordLabel.Text       = "Record: " + PicBoxSizeClass.Record.ToString();
     pictureBox1.Invalidate();
     pictureBox2.Invalidate();
 }