Polygon Hit Sprite
Quad polygon now supports entity sprites also. This pretty much completes the rewrite of the vector side of the collision engine (code wise), just a matter of hooking stuff back up and culling some any redundant code now.
Create3DImage 2,32,32
width=GetImageWidth(2)
Height=GetImageHeight(2)
Cls rgb(22,100,0)
GetIMage 2,0,0,Width,Height
me= MakeParticleSprite(2,rndrange(100,300),rndrange(100,500),5)
Spritecollisiondebug me,true
SpriteCollisionRadius me,100
Type Vert
X#,y#
endtype
Dim POly(4) as Vert
Do
Cls rgb(100,200,300)
Turnsprite Me,0.1
DrawAllSprites
mx=mousex()
my=mousey()
print "Mode:"+Str$(getSpriteCollisionMode(me))
if mousebutton() then Scaler#=Scaler#+0.01
if Scaler#=0 then Scaler#=0.5
if Scaler#>10 then Scaler#=0.5
For lp=0 to 3
Angle2#=wrapangle(Angle#,(lp*90))
Poly(lp).x=(mx+Cosradius(angle2#,50*Scaler#))
Poly(lp).y=(my+Sinradius(angle2#,50*Scaler#))
next
Angle#=wrapangle(Angle#,0.1)
result=QuadHitSprite(Poly(0).x,Poly(0).y,_
Poly(1).x,Poly(1).y,_
Poly(2).x,Poly(2).y,_
Poly(3).x,Poly(3).y,_
me)
if result
print "Quad Hit Sprite"
HitColour=rgb(255,0,0)
else
HitColour=rgb(255,255,255)
print "Quad Missed Sprite"
endif
DRawPoly(HitColour)
If EnterKey()
r=GetspritecollisionMode(me)+1
if r>6 then r=0
spritecollisionMode me,r
flushkeys
EndIf
print fps()
Sync
loop
Function DRawPoly(HitColour)
For lp=0 to 3
lp2=(lp+1) and 3
linec Poly(lp).x,Poly(lp).y,Poly(lp2).x,Poly(lp2).y,HitColour
next
EndFUnction
Function MakeParticleSprite(ThisIMage,Xpos#,Ypos#,points)
ThisSprite=NewSprite(Xpos#,Ypos#,ThisIMage)
SpriteDrawMode ThisSprite, 2 ;+16
SpriteVertexQuantity thisSprite,(Points+1)*4
SpriteFaceQuantity thisSprite,(Points+1)
angleStep#=360.0/points
size=32
For lp=0 to points-1
angle#=wrapangle(angle#,anglestep#)
Radius#=100
SetVerts(ThisSprite,VertexOffset,Angle#,Radius#,Size,wrapangle(angle#,-45))
SetFace(ThisSprite,ThisFace,VertexOffset,RndRgb())
VertexOffset=VertexOffset+4
inc thisface
next
EndFunction ThisSPrite
Function SetVerts(ThisSprite,VertexOffset,Angle#,Radius,Size,Rotation)
CenterX#=CosNewValue(0,angle#,Radius)
CenterY#=SinNewValue(0,angle#,Radius)
For lp=0 to 3
X#=CosNewValue(CenterX#,Rotation,Size)
Y#=SinNewValue(CenterY#,Rotation,Size)
PokeSpriteVertex ThisSprite,VertexOffset,X#,y#,z#
Rotation=wrapangle(Rotation,90)
inc VertexOffset
next
EndFunction
Function SetFace(ThisSprite,ThisFace,VertexOffset,ThisColour)
PokeSpriteFaceVerts ThisSprite,ThisFace,4
PokeSpriteface ThisSprite,ThisFace,0,VertexOffset+0,0,0,ThisColour
PokeSpriteface ThisSprite,ThisFace,1,VertexOffset+1,1,0,ThisColour
PokeSpriteface ThisSprite,ThisFace,2,VertexOffset+2,1,1,ThisColour
PokeSpriteface ThisSprite,ThisFace,3,VertexOffset+3,0,1,ThisColour
EndFunction