System.Drawing.Rectangle.IntersectsWith C# (CSharp) Method

IntersectsWith() private method

private IntersectsWith ( Rectangle rect ) : bool
rect Rectangle
return bool
        public bool IntersectsWith(Rectangle rect) =>
            (rect.X < X + Width) && (X < rect.X + rect.Width) &&
            (rect.Y < Y + Height) && (Y < rect.Y + rect.Height);

Same methods

Rectangle::IntersectsWith ( System rect ) : bool

Usage Example

Example #1
0
 private void SearchIntersections() // scans if the ball is intersecting with anything
 {
     for (int i = 0; i < 60; i++)
     {
         if (pingBall.IntersectsWith(bricks[i]) && brickExists[i] == true)
         {
             //rectangleGraphics.FillRectangle(blackBrush, bricks[i]);
             brickExists[i] = false;
             // write code to detect specific wall; WallRebound(0/1/2/3);
             System.Drawing.Rectangle leftSide = new System.Drawing.Rectangle(bricks[i].Left, bricks[i].Top, 1, 25);
         }
     }
     if (pingBall.Left < 0)
     {
         runningVelocity[1] *= -1;
     }
     if (pingBall.IntersectsWith(topWall))
     {
         runningVelocity[0] *= -1;
     }
     if (pingBall.Right > 450)
     {
         runningVelocity[1] *= -1;
     }
     if (pingBall.IntersectsWith(bottomWall))
     {
         YouDroppedTheBallOnThisOne();
     }
     if (pingBall.IntersectsWith(paddle))
     {
         CurryRebound();
     }
 }
All Usage Examples Of System.Drawing.Rectangle::IntersectsWith