Всем привет, не понимаю читая штатный хелп на русском: как сделать обработчик столкновения спрайтов?
Вот мой код:
Procedure ImportData()
; const size
#Window_Main = 0
#Screen_Width = 1920
#Screen_Height = 1080
#Square_Size = 20
#Sprite_Snake = 0
#Sprite_StoneWall = 1
; global data
Global x.i = 960
Global y.i = 540
Global WallX.i = 100
Global WallY.i = 100
; massive section
; color code
#Bg_Color = $000000
#Snake_Color = $FFFFFF
#StoneWallColor = $919189
EndProcedure
Procedure InitDevice()
InitSprite()
InitKeyboard()
EndProcedure
Procedure main()
OpenWindow(#Window_Main, 0, 0, #Screen_Width, #Screen_Height, "CavePB", #PB_Window_BorderLess)
OpenWindowedScreen(WindowID(#Window_Main), 0, 0, #Screen_Width, #Screen_Height, #True, 0, 0)
; main character
CreateSprite(#Sprite_Snake, #Square_Size, #Square_Size)
StartDrawing(SpriteOutput(#Sprite_Snake))
Box(0, 0, #Square_Size, #Square_Size, #Snake_Color)
StopDrawing()
;home building
CreateSprite(#Sprite_StoneWall, #Square_Size, #Square_Size)
StartDrawing(SpriteOutput(#Sprite_StoneWall))
Box(0, 0, #Square_Size, #Square_Size, #StoneWallColor)
StopDrawing()
Repeat
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_CloseWindow
End
EndSelect
Until Event = 0
ExamineKeyboard()
; ####################################################################################################
If KeyboardPushed(#PB_Key_W) : y - 3 : EndIf
If KeyboardPushed(#PB_Key_A) : x - 3 : EndIf
If KeyboardPushed(#PB_Key_S) : y + 3 : EndIf
If KeyboardPushed(#PB_Key_D) : x + 3 : EndIf
If x = 1899 : x = -24 : EndIf
If x = -27 : x = 1899 : EndIf
If y = 1086 : y = -33 : EndIf
If y = -36 : y = 1086 : EndIf
Debug "X = " + x
Debug "Y = " + y
; ####################################################################################################
; draw a Юрта
FlipBuffers()
ClearScreen(#Bg_Color)
DisplaySprite(#Sprite_Snake, x, y)
For WallX = 100 To 200 Step 20
DisplaySprite(#Sprite_StoneWall, WallX, 100)
Next
For WallY = 120 To 200 Step 20
DisplaySprite(#Sprite_StoneWall, 100, WallY)
Next
For WallX = 120 To 200 Step 20
DisplaySprite(#Sprite_StoneWall, WallX, 200)
Next
DisplaySprite(#Sprite_StoneWall, 200, 120)
DisplaySprite(#Sprite_StoneWall, 200, 140)
For WallX = 200 To 230 Step 20
DisplaySprite(#Sprite_StoneWall, WallX, 150)
Next
For WallX = 200 To 230 Step 20
DisplaySprite(#Sprite_StoneWall, WallX, 200)
Next
; end draw a Юрта
; обработчик колизий спрайтов
DataCollision.i = SpriteCollision(#Sprite_Snake, x, y, #Sprite_StoneWall, WallX, WallY)
Debug "Перекрытие спрайтов = " + DataCollision
; конец обработчика колизий спрайтов
Until KeyboardPushed(#PB_Key_Escape)
End
EndProcedure
ImportData()
InitDevice()
main()