Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Collision detection...
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00769784
Message ID:
00769821
Vues:
21
Thanks, I will take a look at it.
But I have found a solution myself :-)
See Re: Collision detection... Thread #769784 Message #769819

Thanks anyways...



>Gerald, one un-tested solution below ?
>
>
>
>
>* 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 )
>
>
>
>
>
>
>
>>In an application I have a form in which you can move shapes around.
>>I need to know when two shape was in contact to each other.
>>
>>If one shape was at
>>
>>left:100
>>Top:100
>>Height:100
>>Width:100
>>
>>and another one was at
>>
>>Left:150
>>Top:75
>>Height:100
>>Width:100
>>
>>
>>I need a really fast function to call it in a loop.
>>Any help will be appreciated :-)
If we exchange an apple, we both get an apple.
But if we exchange an idea, we both get 2 ideas, cool...


Gérald Santerre
Independant programmer - internet or intranet stuff - always looking for contracts big or small :)
http://www.siteintranet.qc.ca
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform