Code: Select all
InitSprite()
InitKeyboard()
OpenWindow(0,300,300,600,800,"Collision Test",#PB_Window_SystemMenu)
If OpenWindowedScreen(WindowID(0),0,0,DesktopScaledX(600),DesktopScaledX(800),0,0,0)
CreateSprite(1,10,10,#PB_Sprite_AlphaBlending|#PB_Sprite_PixelCollision)
StartDrawing(SpriteOutput(1))
DrawingMode(#PB_2DDrawing_AllChannels)
Box(0,0,OutputWidth(),OutputHeight(),RGBA(0,0,0,255))
Circle(4,4,5,RGBA(255,255,255,255))
StopDrawing()
TransparentSpriteColor(1,RGBA(0,0,0,255))
CreateSprite(0,400,40,#PB_Sprite_AlphaBlending|#PB_Sprite_PixelCollision)
StartDrawing(SpriteOutput(0))
DrawingMode(#PB_2DDrawing_AllChannels)
Box(0,0,OutputWidth(),OutputHeight(),RGBA(0,0,0,255))
Y=OutputHeight()/2
AX=OutputWidth()/2-Y
Circle(OutputWidth()-Y,Y,Y-5,RGBA(255,0,0,255))
Box(OutputWidth()/2,0.5*Y+2,OutputWidth()/2-OutputHeight()+Y,Y-5,RGBA(255,0,0,255))
Circle(OutputWidth()/2,Y,Y-5,RGBA(255,0,0,255))
StopDrawing()
TransparentSpriteColor(0,RGBA(0,0,0,255))
X=(ScreenWidth()-SpriteWidth(0))/2
Y=(ScreenHeight()-SpriteHeight(0))/2
Repeat
Repeat
Event=WindowEvent()
Select event
Case #PB_Event_CloseWindow
Break 2
EndSelect
Until Not Event
Angle=Angle+3
If Angle>359:Angle-360:EndIf
If Angle<0:Angle+360:EndIf
RotateSprite(0,Angle,#PB_Absolute)
ClearScreen(RGB(0,255,0))
If SpritePixelCollision(0,X,Y,1,X+150,Y)
MessageRequester("","",0)
EndIf
DisplayTransparentSprite(0,X,Y)
DisplayTransparentSprite(1,X+150,Y)
FlipBuffers()
ForEver
EndIf
