; ImagesCollide Example ; --------------------- Graphics 640,480,0,2 SetBuffer BackBuffer() player=LoadImage("media/player.bmp") ; Create an asteroid image - a round boulder with empty corners rock=CreateImage(96,96) SetBuffer ImageBuffer(rock) Color 130,120,110 Oval 8,8,80,80,True SetBuffer BackBuffer() px=100 py=100 While Not KeyDown(1) Cls ; Arrow keys steer the ship If KeyDown(203) Then px=px-3 If KeyDown(205) Then px=px+3 If KeyDown(200) Then py=py-3 If KeyDown(208) Then py=py+3 ; ImagesCollide is pixel-perfect: transparent pixels never count, ; so brushing past the boulder's empty corners is safe. ; It is slower than ImagesOverlap - use it when accuracy matters. ; The 0s are the animation frames to test (frame 0 of each image). hit=ImagesCollide(player,px,py,0,rock,272,192,0) DrawImage rock,272,192 DrawImage player,px,py ; Flash a warning border while colliding If hit Then Color 255,0,0 Rect 0,0,640,480,False Rect 1,1,638,478,False End If Text 0,0,"Arrow keys: fly the ship into the asteroid Esc: exit" If hit Then Text 0,20,"ImagesCollide=1 - solid pixels really touch" Else Text 0,20,"ImagesCollide=0 - corners do not count, only solid pixels" End If Flip Wend End