Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Detecting object collisions
Message
 
To
28/09/2005 08:58:11
Héctor Lizarraga
Gobierno Del Edo de Querétaro
Querétaro, Mexico
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01053875
Message ID:
01053878
Views:
10
See this msg: Re: Is there any object here ? Thread #1017390 Message #1017522


>Hi
>
>I'm creating an app where the user can move shape objects but I want the moved object 'detect' other object's borders so the movement is restricted to the free available area. The code belows is from an example from Gérald Santerre here in the downloads section.
>
>It's working ok, but how can I detect collisions between objects?
>
>Any ideas?
>
>Thanks in advance
>Héctor L.
>
>**************************************************
>DEFINE CLASS _mover AS shape
> Height = 6
> Width = 100
> MousePointer = 5
> Name = "_mover"
>
>
> PROCEDURE RightClick
> LOCAL oParent
>
> oParent = This.Parent
>
> DEFINE POPUP sizing SHORTCUT FROM mrow(),mcol()
>
> DEFINE BAR 1 OF sizing PROMPT "Max Width"
> DEFINE BAR 2 OF sizing PROMPT "Max Height"
> DEFINE BAR 3 OF sizing PROMPT "Bring to Front"
> DEFINE BAR 4 OF sizing PROMPT "Send to Back"
>
> ON SELECTION BAR 3 OF sizing =oParent.ZOrder(0)
> ON SELECTION BAR 4 OF sizing =oParent.ZOrder(1)
>
> ACTIVATE POPUP sizing
> RELEASE POPUP sizing
> ENDPROC
>
>
> PROCEDURE MouseMove
> LPARAMETERS nButton, nShift, nXCoord, nYCoord
>
> LOCAL nFreeZone, nLeft, nTop, oRef
>
> nFreeZone = This.Parent.nFreeZone
>
> IF This.Parent.Mover_flag = .T. AND This.MousePointer = 5
> nLeft = (This.Parent.OldLeft - (This.Parent.OldX - nXCoord))
> nTop = (This.Parent.OldTop - (This.Parent.OldY - nYCoord))
>
> *set the Left position
> IF nLeft < Thisform.Width - This.Parent.Width - nFreeZone
> IF nLeft > nFreeZone
> This.Parent.Left = nLeft
> ELSE
> This.Parent.Left = nFreeZone
> ENDIF
> ELSE
> This.Parent.Left = Thisform.Width - This.Parent.Width - nFreeZone
> ENDIF
>
> *set the top position
> IF nTop < Thisform.Height - This.Parent.Height - nFreeZone
> IF nTop > nFreeZone
> This.Parent.Top = nTop
> ELSE
> This.Parent.Top = nFreeZone
> ENDIF
> ELSE
> This.Parent.Top = Thisform.Height - This.Parent.Height- nFreeZone
> ENDIF
> ENDIF
> ENDPROC
>
>
> PROCEDURE MouseLeave
> LPARAMETERS nButton, nShift, nXCoord, nYCoord
>
> This.Parent.Mover_flag = .F.
> ENDPROC
>
>
> PROCEDURE MouseUp
> LPARAMETERS nButton, nShift, nXCoord, nYCoord
>
> This.Parent.Mover_flag = .F.
> ENDPROC
>
>
> PROCEDURE Init
> This.Top = 0
> This.Left = 0
> This.Width = This.Parent.Width
>
> This.Anchor = 10
> ENDPROC
>
>
> PROCEDURE MouseDown
> LPARAMETERS nButton, nShift, nXCoord, nYCoord
>
> This.Parent.OldX = nXCoord
> This.Parent.OldY = nYCoord
> This.Parent.OldLeft = This.Parent.Left
> This.Parent.OldTop = This.Parent.Top
>
> This.Parent.Mover_flag = .T.
> This.Parent.edtEditArea.SetFocus()
> ENDPROC
>
>
>ENDDEFINE
>*
>*-- EndDefine: _mover
>**************************************************
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform