|
-
Nov 30th, 2006, 09:44 AM
#1
Thread Starter
Member
[RESOLVED] Capture the Flag
I need some code so that when my player1 crosses a certian point on the form then the flag will disapear. So like when when player1 crosses img1 then the flag img will disapear.
-
Nov 30th, 2006, 04:53 PM
#2
Re: Capture the Flag
Sounds like collision detection. Is it acceptable to draw a virtual box around the flag, or do you need to have even tighter resolution? If you can say that the flag should disappear when the rectangle around player1 crosses into the rectangle around the flag, then the problem becomes quite simple, since you can just check whether the boxes overlap. There are simplifications that can be made to this, too, if either the flag or the player are considerably smaller than the other (such that one might be considered a point).
My usual boring signature: Nothing
 
-
Dec 2nd, 2006, 12:25 AM
#3
Thread Starter
Member
Re: Capture the Flag
ok is there code to just make it so that if player1 comes in contact with the flag then the flag will dissapear?
-
Dec 2nd, 2006, 12:57 AM
#4
Re: Capture the Flag
Assuming that 'flag' and 'player' are controls:
VB Code:
Dim intersection As Region = flag.Region.Clone()
intersection.Intersect(player.Region)
If intersection.IsEmpty() Then
'There is no intersection between the two regions so the controls are not overlapping.
End If
You should read up about the Region class and the Control.Region property to get a proper understanding of this code and how to best use it.
Last edited by jmcilhinney; Dec 2nd, 2006 at 01:01 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|