private void Form1_KeyDown(object sender, KeyEventArgs e) { int i = (int)e.KeyCode; if (i == 37 && label1.Left > 0) label1.Left = label1.Left - 3; if (i == 39 && label1.Left < this.Width - label1.Width) label1.Left = label1.Left + 3; } private void timer1_Tick(object sender, EventArgs e) { pictureBox1.Top = pictureBox1.Top - 5; if (pictureBox1.Top < 0) { timer1.Enabled = false; timer2.Enabled = true; } } private void timer2_Tick(object sender, EventArgs e) { pictureBox1.Top = pictureBox1.Top + 5; pictureBox1.Left = pictureBox1.Left + 2; if(label1.Top == pictureBox1.Top && pictureBox1.Left > label1.Left && pictureBox1.Left < label1.Right) { timer1.Enabled = true; timer2.Enabled = false; } }
pictureBox1.Left -= 2;
Graphics
Paint
OnPaint
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)