Example #1
0
 // iterate through both the rows and if ball collides with the brick in first or secondrow, set brick to null, the null bricks will not be drawn
 public void BrickCollisions()
 {
     for (int i = 0; i < bricksPerRow; i++)
     {
         if (firstRow[i] != null)
         {
             if (ball.CollidesWith(firstRow[i]))
             {
                 ball.YSpeed *= -1;
                 firstRow[i]  = null;
                 break;
             }
         }
         if (secondRow[i] != null)
         {
             if (ball.CollidesWith(secondRow[i]))
             {
                 ball.YSpeed *= -1;
                 secondRow[i] = null;
                 break;
             }
         }
     }
 }