# How can I solve multi collisions?

• ### Question

• Hi,

I have collision between a ball (obj) and  3 bars (obj11, obj22 and obj33).
Every time when I had a collision I suppose to score only one time.
This is the reason for using missed15, missed25, missed35 and not
if (!obj11.IsEmpty | !obj22.IsEmpty | !obj33.IsEmpty)
{
score++;
txtScore.Text = score.ToString();
}
In this case instead of 1 I have hundreds because if multi collision.

Sa my problem is how I get 4 score and so one by one. 1,2 and 3 are OK.
See code for more.

https://onedrive.live.com/redir?resid=857BC62170EDDB22!5572&authkey=!AIYlPsMNum16t9Q&ithint=file%2czip

obj11.Intersect(obj);

void gameTimer2_Tick(object sender, object e)
{
obj = new Rect();
obj.X = Canvas.GetLeft(Ball);
obj.Y = Canvas.GetTop(Ball);
//    obj.Height = 60; // 50;
//  obj.Width = 60;  // 50;
obj.Height =  50;

obj11 = new Rect();
obj11.X = Canvas.GetLeft(rect11);
obj11.Y = Canvas.GetTop(rect11);
obj11.Height = (double)PipeDifferentY; //Pipe1[1];
obj11.Width = 1; // 15; //66;

obj11.Intersect(obj);

if (!obj11.IsEmpty)
{
missed15 = 1;
missedTotal = missed15 + missed25 + missed35;
txtScore.Text = missedTotal.ToString();

}

obj33 = new Rect();
obj33.X = Canvas.GetLeft(rect33);
obj33.Y = Canvas.GetTop(rect33);
obj33.Height = (double)PipeDifferentY; //Pipe1[1];
obj33.Width = 1; // 15; //66;

obj33.Intersect(obj);

if (!obj33.IsEmpty)
{
missed15 = 1;
missedTotal = missed15 + missed25 + missed35;
txtScore.Text = missedTotal.ToString();
}    }

obj22 = new Rect();
obj22.X = Canvas.GetLeft(rect22);
obj22.Y = Canvas.GetTop(rect22);
obj22.Height = (double)PipeDifferentY; //Pipe1[1];
obj22.Width = 1; // 15; //66;

obj22.Intersect(obj);

if (!obj22.IsEmpty)
{
missed15 = 1;
missedTotal = missed15 + missed25 + missed35;
txtScore.Text = missedTotal.ToString();

}

Thanks

Monday, March 23, 2015 10:46 PM

• Hi,

I solved the  problem.

If is not Die() I counted for every finished pipe.

Thanks

• Marked as answer by Thursday, March 26, 2015 4:44 PM
Thursday, March 26, 2015 4:44 PM

### All replies

I don't understand what you are trying to ask. Can you please restate the problem more clearly?

It would also help if you would edit your post to correct the code snippets and to include them in code blocks with the Insert Code Block tool so they format nicely and are easier to read.

Thanks,
Rob

Monday, March 23, 2015 11:43 PM
• Hi.

It works for passing gate 1, 2, 3 I have the sore 3, but at 4 and next gates I have also 3 and not 4 and so.

Please see the project it suppose to work.

void gameTimer2_Tick(object sender, object e)
{
obj = new Rect();
obj.X = Canvas.GetLeft(Ball);
obj.Y = Canvas.GetTop(Ball);
//    obj.Height = 60; // 50;
//  obj.Width = 60;  // 50;
obj.Height =  50;

obj11 = new Rect();
obj11.X = Canvas.GetLeft(rect11);
obj11.Y = Canvas.GetTop(rect11);
obj11.Height = (double)PipeDifferentY; //Pipe1[1];
obj11.Width = 1; // 15; //66;

obj11.Intersect(obj);

if (!obj11.IsEmpty)
{
missed15 = 1;
missedTotal = missed15 + missed25 + missed35;
txtScore.Text = missedTotal.ToString();

}

obj22 = new Rect();
obj22.X = Canvas.GetLeft(rect22);
obj22.Y = Canvas.GetTop(rect22);
obj22.Height = (double)PipeDifferentY; //Pipe1[1];
obj22.Width = 1; // 15; //66;

obj22.Intersect(obj);

if (!obj22.IsEmpty)
{
missed25 = 1;
missedTotal = missed15 + missed25 + missed35;
txtScore.Text = missedTotal.ToString();

}

obj33 = new Rect();
obj33.X = Canvas.GetLeft(rect33);
obj33.Y = Canvas.GetTop(rect33);
obj33.Height = (double)PipeDifferentY; //Pipe1[1];
obj33.Width = 1; // 15; //66;

obj33.Intersect(obj);

if (!obj33.IsEmpty)
{
missed35 = 1;
missedTotal = missed15 + missed25 + missed35;
txtScore.Text = missedTotal.ToString();
}    }

Thanks

Tuesday, March 24, 2015 2:12 AM
• Hi,

I solved the  problem.

If is not Die() I counted for every finished pipe.

Thanks