7 Ocak 2019 Pazartesi

c# Form Hedefi araba ile yakalamak.

 private void Form1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Left)
            {
                pictureBox1.Location = new Point(pictureBox1.Location.X - 1, pictureBox1.Location.Y);
            }

            if (e.KeyCode == Keys.Right)
            {
                pictureBox1.Location = new Point(pictureBox1.Location.X + 1, pictureBox1.Location.Y);
            }
            if (e.KeyCode == Keys.Up)
            {
                pictureBox1.Location = new Point(pictureBox1.Location.X, pictureBox1.Location.Y - 1);
            }
            if (e.KeyCode == Keys.Down)
            {
                pictureBox1.Location = new Point(pictureBox1.Location.X, pictureBox1.Location.Y + 1);
            }

        }

 private void timer1_Tick(object sender, EventArgs e)
        {
            if (pictureBox2.Location==pictureBox1.Location)
            {
                Random x = new Random();
                Random y = new Random();
                pictureBox2.Location = new Point(x.Next(0, 550), y.Next(0, 490));
            }

            label1.Text = pictureBox1.Location.X.ToString();
            label2.Text = pictureBox1.Location.Y.ToString();
            label3.Text = pictureBox2.Location.X.ToString();
            label4.Text = pictureBox2.Location.Y.ToString();

            if (pictureBox1.Location.X == pictureBox2.Location.X && pictureBox1.Location.Y == pictureBox2.Location.Y)
            {
             
                timer1.Stop();
                DialogResult dialogResult = MessageBox.Show("Hedefi yediniz kalmak istiyor musunuz ?", "Giriş", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    ++skor;
                    skor = int.Parse(label6.Text);

                }
                else if (dialogResult == DialogResult.No)
                {
                    Application.Exit();
                }


                if (pictureBox1.Location.Y < -5)
                {
                    timer1.Enabled = false;
                    MessageBox.Show(" nereye");
                    


                }

Hiç yorum yok:

Yorum Gönder

c# Veritabanıyla giriş yapıp, üye olmak ve şifre unutmak!

Üye olmak;;;  if (con.State == ConnectionState.Closed)             {                 con.Open();                 string kayit = ...