Linked List Syntax

BlitzMax Forums/BlitzMax Beginners Area/Linked List Syntax

OK,OK, I think the docs need to be better, but I think the opportunity cost for creating them right now is to high (i.e Mark could be coding the 3D module!)

drudging through source code is not fun and it IS time consuming but... take a look at the following:

Function CollideQuad:Object[](pquad:TQuad,collidemask%,writemask%,id:Object=Null) 
	Local	result:Object[]
	Local	p:TQuad,q:TQuad
	Local	i,j,count

	p=pquad				'CreateImageQuad(image,frame,x,y)
' check for collisions
	For i=0 To 31
		If collidemask & (1 Shl i)
			q=quadlayer[i]
			While q
				If QuadsCollide(p,q)
					If count=Len(result) result=result[..((count+4)*1.2)]
					result[count]=q.id
					count:+1
				EndIf				
				q=q.link
			Wend		
		EndIf
	Next
' write to layers	
	For i=0 To 31
		If writemask & (1 Shl i)
			If freequads
				q=freequads
				freequads=q.link
			Else
				q=New TQuad
			EndIf
			q.id=p.id;	'TODO:optimize with memcpy?
			q.mask=p.mask;
			q.frame=p.frame
			MemCopy q.xyuv,p.xyuv,64
			q.minx=p.minx;q.miny=p.miny;q.maxx=p.maxx;q.maxy=p.maxy;
			q.link=quadlayer[i]
			quadlayer[i]=q
		EndIf
	Next
' return result
	Return result[..count]
End Function



not only does it make the function clearer, it also gives us more information about the status of the function
'TODO:optimize with memcpy?
not to mention that it is written rather well.

(once again, in case I failed to mention it, I do agree that BMAX needs better docs)