; ImagesOverlap 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 ; ImagesOverlap only compares the two images' bounding rectangles - ; very fast, but transparent corners count as a hit hit=ImagesOverlap(player,px,py,rock,272,192) DrawImage rock,272,192 DrawImage player,px,py ; Flash a warning border while overlapping 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,"ImagesOverlap=1 - boxes touch (even the transparent corners!)" Else Text 0,20,"ImagesOverlap=0 - fast rectangle-only test" End If Flip Wend End