private Point location;
private void button1_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
}
private int v1 = 40;
private int v2 = 40;
private void timer1_Tick(object sender, EventArgs e)
{
if (pictureBox1.Location.X < 0 || pictureBox1.Location.X >= this.Width-50)
{
v1 = -v1;
}
if (pictureBox1.Location.Y < 0 || pictureBox1.Location.Y >= this.Height - 50)
{
v2 = -v2;
}
location.X = location.X + v1;
location.Y = location.Y + v2;
pictureBox1.Location = location;
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
}
private int v1 = 40;
private int v2 = 40;
private void timer1_Tick(object sender, EventArgs e)
{
if (pictureBox1.Location.X < 0 || pictureBox1.Location.X >= this.Width-50)
{
v1 = -v1;
}
if (pictureBox1.Location.Y < 0 || pictureBox1.Location.Y >= this.Height - 50)
{
v2 = -v2;
}
location.X = location.X + v1;
location.Y = location.Y + v2;
pictureBox1.Location = location;
}