> >* Get coordinates of each shape for program clarity. > >WITH THISFORM > > nLeft1 = .shape1.left > nRght1 = .shape1.left + .shape1.width > nTops1 = .shape1.top > nBttm1 = .shape1.top + .shape1.height > > nLeft2 = .shape2.left > nRght2 = .shape2.left + .shape2.width > nTops2 = .shape2.top > nBttm2 = .shape2.top + .shape2.height > >ENDWITH > > >* default to not overlapping/collided > >lCollided = .F. > > >* Test for overlapping. See if any of the four >* corners of shape1 are within shape2. >* > >DO CASE > >* Case 1 - >* Test if the top of shape1 is between the top and bottom of shape2. If so... >* Is the left-most edge within the horizontal span of shape2 or is the >* right-most edge of shape 1 within the horizontal span of shape2? > >CASE BETWEEN( nTops1, nTops2, nBttm2 ) .AND. ; > ( BETWEEN( nLeft1, nLeft2, nRght2 ) .OR. ; > BETWEEN( nRght1, nLeft2, nRght2 ) ) > > lCollided = .T. > > >* Case 2 - >* Test if the bottom of shape1 is between the top and bottom of shape2. If so... >* Is the left-most edge within the horizontal span of shape2 or is the >* right-most edge of shape 1 within the horizontal span of shape2? > >CASE BETWEEN( nBttm1, nTops2, nBttm2 ) .AND. ; > ( BETWEEN( nLeft1, nLeft2, nRght2 ) .OR. ; > BETWEEN( nRght1, nLeft2, nRght2 ) ) > > lCollided = .T. > > >ENDCASE > > >RETURN( lCollided ) > >>