1:When I click on the form,made a ball and Move to this side and that side.
2:When the click again,Repeat the above procedure .
3:when Two of the balls collide they,Both are removed.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication46
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public Boolean top = true;
public Boolean left = true;
public int Speed =5;
private void timer1_Tick(object sender, EventArgs e)
{
try
{
if (top == true) pictureBox1.Top += Speed; else pictureBox1.Top -= Speed;
if (left == true) pictureBox1.Left += Speed; else pictureBox1.Left -= Speed;
if (pictureBox1.Top >= this.Height-100) top = false;
if (pictureBox1.Left >= this.Width-100) left = false;
if (pictureBox1.Top < -5) top = true;
if (pictureBox1.Left < -5) left = true;
}
catch
{
timer1.Enabled = false;
}
}
private void Form1_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
}
}
}