/// <summary> /// Hit detection between rock and the ship /// </summary> /// <param name="gr">graphics object to check the regions on</param> private void ShipVsRock(Graphics gr) { PointF shipCenter = myShip.CenterPoint(); for (int i = 0; i < rockList.Count; i++) { PointF thisRock = rockList[i].Pos; //if the rock is dangerous if (rockList[i].isDangerous) { //check if the shapes are near each other if (GetDistance(shipCenter, thisRock) <= (ShipModel.SHIPRAD / 2 + rockList[i].RockSize)) { //intersect the regions Region shipReg = myShip.GetRegion(); Region rockReg = rockList[i].GetRegion(); shipReg.Intersect(rockReg); if (!shipReg.IsEmpty(gr)) { //if the regions intersect set the death bool of the ship and the rock to true myShip.IsMarkedForDeath = rockList[i].IsMarkedForDeath = true; } } } } }