dcsimg
Results 1 to 3 of 3

Thread: Need advice, suggestions, anything that will help

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2017
    Posts
    553

    Need advice, suggestions, anything that will help

    In my jigsaw puzzle program I have now made the code to cut out all the puzzle pieces, load them into User Controls, move them around the board and put them together to make the finished picture.

    However, two problems remain:

    1) Detecting when player has moved a piece and successfully locked it in place with another piece

    2) Join the two pieces together so that they stay together and move together as though it was one piece if player moves it again.

    I have no idea about problem #1.

    I have an idea about problem #2 but not too sure if it is the best way to approach this problem.

    Assume player has moved piece #1 into piece #2 and my program knows this because problem #1 has been resolved. Now, I have a procedure that "glues" pieces together. I need to get the image from piece #1 and the image from piece #2 and connect them together (not sure how at this time) and then load the next piece user control and make it's picture property the picture of the two pieces that are locked together as one picture. Now, I unload the UC's for piece #1 and #2. If player now moves this control around it appears that the two pieces are moving together.

    Any one have any ideas about either or both problems. Anything will be highly appreciated.

  2. #2
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,504

    Re: Need advice, suggestions, anything that will help

    1) For each chopped puzzle piece, have an ID property and also 4 other property such as North/South

    Also have some form of a Virtual Table/Array which has all the info about the puzzle. i/e
    Sides North / South / East / West ID's that match with their corresponding North / Sound / East West ID's.
    (that way you know how they match)

    2) Have 4 more properties that remember if each of the sides (north / south / east / west) have been JOINED.
    That way you can easily loop on drag to see if any sides are Joined to eachother.

    So your usercontrol should have the following properties.

    .ID as Integer
    .North as Integer
    .South as Integer
    .East as Integer
    .West as Integer
    .isNorthJoined as Boolean
    .isSouthJoined as Boolean
    .isEastJoined as Boolean
    .isWestJoined as Boolean

    Name:  puzzle.png
Views: 55
Size:  84.1 KB
    Last edited by some1uk03; Jun 20th, 2019 at 04:50 PM.
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2017
    Posts
    553

    Re: Need advice, suggestions, anything that will help

    Yes, I was think along that line. You need a little bit more than what you posted, however

    Code:
     +----+----+----+
     | NW | N  | NE |
     +----+----+----+
     | W  | XX | E  |
     +----+----+----+
     | SW | S  | SE |
     +----+----+----+
    With all the right variables, tables, etc this part seems fairly straight forward. The harder part is knowing when the actual images have touched. Moving a piece around and having it's binding box overlay the binding box of another piece wont trigger anything; it will require knowing that the actual image within the binding box has touched another actual image. This I haven't figured out yet. If the pieces were square then that wouldn't be a problem but I do not know the shape of any given piece even though I know it's ID number. Also, whatever methods I use will need to be universal and not tailored for one particular puzzle.
    Last edited by Code Dummy; Jun 20th, 2019 at 08:52 PM.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width