Esempio n. 1
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (canFall(fallFigur))
     {
         fallFigur.stepFigure();
     }
     else 
     {
         liyPoints.AddRange(fallFigur.FillPoints);
         foreach (Point pn in fallFigur.FillPoints)
         {
             tetr[pn.X / width, pn.Y / width] = true;
         }
         checkLine();
         cehckFail();
         fallFigur = randomFigure();
     }
     pictureBox1.Invalidate();
 }
Esempio n. 2
0
 private void timer2_Tick(object sender, EventArgs e)
 {
     switch (lastKey)
     {
         /*case KeyPressed.Space:
             fallFigur.rotate();
             break;*/
         case KeyPressed.A:
             if (canLeft(fallFigur))
             {
                 fallFigur.LeftPoint = new Point(fallFigur.LeftPoint.X - width, fallFigur.LeftPoint.Y);
                 pictureBox1.Invalidate();
             }
             break;
         case KeyPressed.D:
             if (canRight(fallFigur))
             {
                 fallFigur.LeftPoint = new Point(fallFigur.LeftPoint.X + width, fallFigur.LeftPoint.Y);
                 pictureBox1.Invalidate();
             }
             break;
         case KeyPressed.S:
             timer1.Enabled=timer2.Enabled=false;
             while (canFall(fallFigur))
             {
                 fallFigur.stepFigure();
             }
             liyPoints.AddRange(fallFigur.FillPoints);
             foreach (Point pn in fallFigur.FillPoints)
             {
                 tetr[pn.X / width, pn.Y / width] = true;
             }
             checkLine();
             cehckFail();
             fallFigur = randomFigure();
             pictureBox1.Invalidate();
             timer1.Enabled = timer2.Enabled = true;
             lastKey = KeyPressed.None;
             break;
     }
 }
Esempio n. 3
0
        private bool canRight(Figure fg)
        {
            bool result = fg.RightPoint.X + width < pictureBox1.Width - 1;
            foreach (Point point in liyPoints)
            {
                foreach (Point point2 in fg.FillPoints)
                {
                    if (point.Equals(new Point(point2.X + width, point2.Y)))
                        return false;
                }
            }

            return result;
        }
Esempio n. 4
0
 private bool canLeft(Figure fg)
 {
     bool result = fg.LeftPoint.X - width >= 0;
     foreach (Point point in liyPoints)
     {
         foreach (Point point2 in fg.FillPoints)
         {
             if (point.Equals(new Point(point2.X - width, point2.Y)))
                 return false;
         }
     }
     return result;
 }
Esempio n. 5
0
        private bool canFall(Figure fg)
            {
            bool result = fg.BottomPoint.Y + width < pictureBox1.Height - 1;
            foreach (Point point in liyPoints)
            {
                foreach (Point point2 in fg.FillPoints)
                {
                    if (point.Equals(new Point(point2.X, point2.Y + width)))
                        return false;
                }
            }
            return result;

        }
Esempio n. 6
0
 public static void AddFigure(Figure figure)
 {
     figureList.Add(figure);
 }
Esempio n. 7
0
 private void многоугольникToolStripMenuItem_Click(object sender, EventArgs e)
 {
     var o = new Figure(comboBox1.SelectedIndex+5);
     FigureList.Add(o);
     Invalidate();
 }