Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Declare Function IntersectRect Lib "user32" (lpDestRect As RECT, lpSrc1Rect As RECT, lpSrc2Rect As RECT) As Long
' Collision Detection (Sprites)
' - Acknowledgement here goes to Richard
' Lowe (riklowe@hotmail.com) for his colli
' sion detection
' algorithm which I have used as the bas
' is of my collision detection algorithm.
' Most of the logic in
' here is radically different though, an
' d his algorithm originally didn't deallo
' cate memory properly ;-)
' - All X/Y/Width/Height values MUST be
' measured in pixels (ScaleMode = 3).
' - Compares bounding rectangles, and if
' they overlap, it goes to a pixel-by-pixe
' l comparison.
'This therefore has detection down to th
' e pixel level.
' Function assumes you are using Masking
' sprites (not an unreasonable assumption,
' I'm sure you'll agree).
' - e.g. To test if collision has occurr
' ed between two sprites, one called "Ball
' ", the other "Bat":
Public Function CollisionDetect(ByVal x1 As Long, ByVal y1 As Long, ByVal X1Width As Long, ByVal Y1Height As Long, _
ByVal Mask1LocX As Long, ByVal Mask1LocY As Long, ByVal Mask1Hdc As Long, ByVal x2 As Long, ByVal y2 As Long, _
ByVal X2Width As Long, ByVal Y2Height As Long, ByVal Mask2LocX As Long, ByVal Mask2LocY As Long, _