Example #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();
        }
Example #2
0
 public void UpdatePicBox()
 {
     pictureBox1.Size      = PicBoxSizeClass.PicBoxSize;
     pictureBox1.BackColor = PicBoxSizeClass.Background;
     pictureBox1.Image     = new Bitmap(pictureBox1.Width, pictureBox1.Height);
     PicBoxSizeClass.DrawGrid(pictureBox1.Image);
     pictureBox1.Invalidate();
     IfCellsFree     = PicBoxSizeClass.FillIsFree();
     timer2.Interval = 200 * (11 - PicBoxSizeClass.Speed);
 }
Example #3
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();
 }