I have looked at this subject many times now, and every search has found the same answer.
If you do any search you’ll find the same answer I have. In VB this is:
Public Function Collision(rectangleA As Rectangle, dataA As Color(), rectangleB As Rectangle, dataB As Color()) As Boolean
Dim top As Integer = Math.Max(rectangleA.Top, rectangleB.Top)
Dim bottom As Integer = Math.Min(rectangleA.Bottom, rectangleB.Bottom)
Dim left As Integer = Math.Max(rectangleA.Left, rectangleB.Left)
Dim right As Integer = Math.Min(rectangleA.Right, rectangleB.Right)
For y As Integer = top To bottom - 1
For x As Integer = left To right - 1
Dim colorA As Color = dataA((x - rectangleA.Left) + (y - rectangleA.Top) * rectangleA.Width)
Dim colorB As Color = dataB((x - rectangleB.Left) + (y - rectangleB.Top) * rectangleB.Width)
If colorA.A <> 0 And colorB.A <> 0 Then
Return True
End If
Next
Next
Return False
End Function
I’m sorry this isn’t in a code bracket, but it isn’t working.
What I don’t understand, is where the rotation is coming in. I’m building the color array, or DataA and DataB well before this routine is called, but what I can’t seem to find is how these arrays are rotated.
Can someone fill this black hole?
Thanks.
Edit - Oh, it is in a code block. It wasn’t on the preview box.