Results 1 to 4 of 4

Thread: [RESOLVED] Capture the Flag

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2006
    Posts
    47

    Resolved [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.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    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

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2006
    Posts
    47

    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?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Capture the Flag

    Assuming that 'flag' and 'player' are controls:
    VB Code:
    1. Dim intersection As Region = flag.Region.Clone()
    2.  
    3. intersection.Intersect(player.Region)
    4.  
    5. If intersection.IsEmpty() Then
    6.     'There is no intersection between the two regions so the controls are not overlapping.
    7. 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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width