well I have solved my collision problem but when I draw a row of bugs when the bullet hits them all of them disappear, I only want one of them to disappear. here is my updated code
int count = 102;
bool collision = false;
public void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawImage(ship, 350 + x, 530);
e.Graphics.DrawImage(bullet, 375 + x, 520 + y);
if(collision)
{
return;
}
e.Graphics.DrawImage(bug_one, 120, 0);
e.Graphics.DrawImage(bug_one, 180, 0);
e.Graphics.DrawImage(bug_one, 240, 0);
e.Graphics.DrawImage(bug_one, 300, 0);
e.Graphics.DrawImage(bug_one, 360, 0);
e.Graphics.DrawImage(bug_one, 420, 0);
e.Graphics.DrawImage(bug_one, 480, 0);
e.Graphics.DrawImage(bug_one, 540, 0);
e.Graphics.DrawImage(bug_one, 600, 0);
if (y <= -510 && x >= -15 && x <= 15 && count > 0)
{
e.Graphics.DrawImage(coll, 360, 0);
count = 0;
collision = true;
}
if (y <= -510 && x >= -75 && x <= -45 && count > 0)
{
e.Graphics.DrawImage(coll, 300, 0);
count = 0;
collision = true;
}
}
public void timer1_Tick(object sender, EventArgs e)
{
y -= 5;
Invalidate();
}
public void timer2_Tick(object sender, EventArgs e)
{
count--;
Invalidate();
}
}