/** Check if the ball collides with any twinkles and convert into a score */ public void CheckBallCollisions(Ball b) { if (b != null) { var qb = new nGQuad(5f).Offset(b.Position); foreach (var t in Twinkles) { var qc = new nGQuad(t.Size).Offset(t.Position); if (qc.Intersects(qb)) { t.Die(); CreateScore(t); } } } }
/** Check if two sprites intersect */ public static bool Intersects(nSprite a, nSprite b) { var q1 = new nGQuad(); q1.Points = a.Points.Raw; q1.Offset(a.Position[0], a.Position[1]); var q2 = new nGQuad(); q2.Points = b.Points.Raw; q2.Offset(b.Position[0], b.Position[1]); return q1.Intersects(q2); }