Example #1
0
        static Yon HareketOku(Yon hareket)
        {
            if (KeyAvailable)
            {
                var key = ReadKey(true).Key;

                if (key == ConsoleKey.UpArrow && hareket != Yon.Asagi)
                {
                    hareket = Yon.Yukari;
                }
                else if (key == ConsoleKey.DownArrow && hareket != Yon.Yukari)
                {
                    hareket = Yon.Asagi;
                }
                else if (key == ConsoleKey.LeftArrow && hareket != Yon.Sag)
                {
                    hareket = Yon.Sol;
                }
                else if (key == ConsoleKey.RightArrow && hareket != Yon.Sol)
                {
                    hareket = Yon.Sag;
                }
            }
            return(hareket);
        }
Example #2
0
 private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Up || e.KeyCode == Keys.W)
     {
         if (yonumuz._y != 10)
         {
             yonumuz = new Yon(0, -10);
         }
     }
     else if (e.KeyCode == Keys.Down || e.KeyCode == Keys.S)
     {
         if (yonumuz._y != -10)
         {
             yonumuz = new Yon(0, 10);
         }
     }
     else if (e.KeyCode == Keys.Left || e.KeyCode == Keys.A)
     {
         if (yonumuz._x != 10)
         {
             yonumuz = new Yon(-10, 0);
         }
     }
     else if (e.KeyCode == Keys.Right || e.KeyCode == Keys.D)
     {
         if (yonumuz._x != -10)
         {
             yonumuz = new Yon(10, -0);
         }
     }
 }
Example #3
0
 private void yeni_oyun()
 {
     yem_varmi         = false;
     skor              = 0;
     yilanimiz         = new yilan();
     yonumuz           = new Yon(-10, 0);
     pb_yilanparcalari = new PictureBox[0];
     for (int i = 0; i < 3; i++)
     {
         Array.Resize(ref pb_yilanparcalari, pb_yilanparcalari.Length + 1);
         pb_yilanparcalari[i] = Pb_ekle();
     }
     timer1.Start();
     button1.Enabled = false;
 }
Example #4
0
 public void İlerle(Yon yon)
 {
     yonumuz = yon;
     if (yon._x == 0 && yon._y == 0)
     {
     }
     else
     {
         for (int i = yilan_parca.Length - 1; i > 0; i--)
         {
             yilan_parca[i] = new yilan_parcalari(yilan_parca[i - 1].x_, yilan_parca[i - 1].y_);
         }
         yilan_parca[0] = new yilan_parcalari(yilan_parca[0].x_ + yon._x, yilan_parca[0].y_ + yon._y);
     }
 }