Announcement

Collapse
No announcement yet.

Backwards Jigsaw - Discussion

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Backwards Jigsaw - Discussion

    Hey Chris!

    Nice work. Using a dialog for each piece gives you lots of options.

  • #2
    Well done, Chris!
    Rod
    "To every unsung hero in the universe
    To those who roam the skies and those who roam the earth
    To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

    Comment


    • #3
      Thanks Chris, would be nice to allow the users the ability to rotate the pieces interactively?

      Comment


      • #4
        Chris(H),
        You may have seen on my puzzle code that I can change the number of pieces used for the image. Using your approach, I'd have to have a template for each size, which I'd rather not do.

        An reasonable solution for creating the tongue and groove for random sized drawings is not obvious to me.

        But at this link ...https://mathematica.stackexchange.co...uzzle-cut-path points out some interesting code to create interlocking shape...

        Let's start from writing the following function:
        bsc[p1_, p2_] := With[{rc = RandomChoice[{-1, 1}], d = EuclideanDistance[p1, p2], pm = (p1 + p2)/2, dp = (p2 - p1)/5}, If[d < .1, Line[{p1, p2}], BSplineCurve[{p1, pm, pm - dp + rc {1, -1} Reverse[dp], pm + dp + rc {1, -1} Reverse[dp], pm, p2}, SplineWeights -> {1, 5, 5, 5, 5, 1}/22] ]]
        which will morph a long enough line into a line with a "tongue". It will put the tongue in a random direction for more random generation of puzzle pieces
        With this image as a result ...

        Click image for larger version

Name:	pb_2194.jpg
Views:	82
Size:	5.0 KB
ID:	788580

        I've only just started looking at options for programatically drawing the interlocking shapes, so perhaps there are other that might be useful in our PBWin apps.

        Comment


        • #5
          Gary, Bezier curves are your friend - I posted an example in 2011 in the source code forum but it has vanished, will look for it in the vaults...

          Here's the comments thread for it https://forum.powerbasic.com/forum/u...-bezier-curves

          Breaking news... I find in the archives a Pascal app written 2000 AD by Jean-Yves Queinec which does everything rather well, maybe you can find it online... I will see if I can extract his algorithms (ouch!) and get back... I could be some time..


          Update: yes, he uses Bezier curves.

          Comment


          • #6
            Originally posted by Tim Lakinir View Post
            ...would be nice to allow the users the ability to rotate the pieces interactively?
            Rotate about which axis?

            Comment


            • #7
              Chris, If the jigsaw plane is located in the x-y plane then we need to rotate about the z-axis

              Also, best to show the jigsaw puzzle in a disjointed, mess up form first and then allow the user to drag or rotate the pieces to form the complete image. Get the users
              to think first and allow their imaginations to assemble the image.

              Comment


              • #8
                I reinstated my Bezier curve drawing app to the Source Code forum. It might be useful for drawing a each side of a puzzle piece, because it can emit source code once the shape is OK. Possibly. It's here: https://forum.powerbasic.com/forum/u...ard#post788594

                Comment


                • #9
                  Originally posted by Gary Beene View Post
                  ...Using a dialog for each piece gives you lots of options.
                  Yes, but I'm not sure it is the best way. Sprites may be better.

                  Comment


                  • #10
                    Originally posted by Gary Beene View Post

                    An reasonable solution for creating the tongue and groove for random sized drawings is not obvious to me.
                    I'd use the same method they do when making cardboard picture puzzles.
                    Make a stamping template.
                    Starting with equal sized squares, add edge components to a two color grid.
                    Size the grid to the size of the picture, and use a fill algorithm to cut the pieces.
                    Click image for larger version

Name:	jigsaw.png
Views:	47
Size:	526 Bytes
ID:	788604
                    The world is strange and wonderful.*
                    I reserve the right to be horrifically wrong.
                    Please maintain a safe following distance.
                    *wonderful sold separately.

                    Comment


                    • #11
                      I've played a number of computer jigsaw puzzle games and what I've found most enjoyable are just plain square pieces. On my 15" fill HD laptop screen the pieces are fairly small and giving them traditional jigsaw shapes, available in most games, makes them harder to see details. Having square piece makes them easier to see and makes it possible to have more smaller pieces and still make out details.

                      Rotating pieces is usually optional. If I plan to focus on the puzzle I usually do rotate them. If it's something to keep my hands busy while listening to an audiobook or watching a tv show I usually won't rotate the pieces.

                      Another little trick one puzzle game used was to cut pieces out of most of the picture, leaving a border something like 1/2" wide un-broken up. I suspect the programmer did that primarily to make it easier to have all the pieces the same size while still allowing any size picture. But for the person solving the puzzle it's also a help to have that little bit as reference in figuring out the picture.

                      Barry

                      Comment

                      Working...
                      X