brl.max2d CollideImageQuad

BlitzMax Forums/BlitzMax Module Tweaks/brl.max2d CollideImageQuad

plash(Posted 2009) [#1]
Function to allow specific quad collision (with or without an image).

In mod/brl.mod/max2d.mod/max2d.bmx on line 1061 (before the Private section), add:
Rem
	bbdoc: Check collisions with the given image and layer.
	about: The image can be Null (if it is the area of the quad will be checked).
End Rem
Function CollideImageQuad:Object[] (image:TImage, frame:Int, tx0:Float, ty0:Float, tx1:Float, ty1:Float, tx2:Float, ty2:Float, tx3:Float, ty3:Float, collidemask:Int, writemask:Int, id:Object = Null)
	Local q:TQuad, pix:TPixmap
	
	'q = CreateQuad(image, 0, x, y, x1, y1, id)
	
	If freequads
		q = freequads
		freequads = q.link
		q.link = Null
	Else
		q = New TQuad
	End If
	q.id = id
	If image <> Null
		pix = image.Lock(frame, True, False)
		If AlphaBitsPerPixel[pix.format] q.mask=pix
	End If
	
	q.SetCoords(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3)
	
	Return CollideQuad(q, collidemask, writemask)
	
End Function


Would an array, in this case, be worth the slight memory overhead? (for the call, just one array with [x0, y0, x1, y1..])