; ImageRectCollide Example ; ------------------------ Graphics 640,480,0,2 SetBuffer BackBuffer() player=LoadImage("media/player.bmp") 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 ; ImageRectCollide is the pixel-perfect version of ImageRectOverlap: ; only the ship's SOLID pixels trigger a hit on the screen rectangle. ; Costs more than the rectangle-only test - use it when accuracy matters. ; The 0 is the animation frame of the image to test. hit=ImageRectCollide(player,px,py,0,250,180,140,120) ; Draw the hot zone - red while solid ship pixels touch it If hit Then Color 255,60,60 Else Color 80,200,80 End If Rect 250,180,140,120,False DrawImage player,px,py Text 0,0,"Arrow keys: fly the ship into the zone Esc: exit" Text 0,20,"ImageRectCollide(player,"+px+","+py+",0,250,180,140,120)="+hit Flip Wend End