I wanted to add a couple of little jigsaw puzzles to an interactive book I am working on, and here's what I came up with.
Feel free to use it in any of your own projects, just change out the graphics. Should be relatively easy to expand to larger sizes too.
YOU MUST BE SIGNED IN TO LEAVE A COMMENT
April 11, 2016
Thanks for the comments. I made this to go into a children's book that I'm working on, so I wanted the pieces to snap in position to make it a little easier. Plus it makes the logic easier, simply keep a running count of the number of pieces that have been snapped in and when that count equals the total number of pieces you know the puzzle has been solved.
I'll work on a non-snapping version, probably need a bunch of IF statements to check the position of each piece and tie these to a timer to constantly check if the puzzle has been solved or maybe have the check routine called each time a piece is moved.
I don't think a grid will work since the pieces are different sizes. If they are aligned on a grid, they won't match up properly. The way it is currently set up is there is a matching "base" piece for each puzzle piece. The base pieces are arranged in the solved configuration and their alpha is reduced so they are faded. When a puzzle piece collides with its base, it is snapped into position.
One variation (still snapping though) is to fade the base pieces completely, but then have an option to show the finished image if needed, kind of like looking at the the jigsaw puzzle box when you're solving a regular jigsaw puzzle.
April 11, 2016
Cool game! I think you should make it so the pieces don't stick to the right spot, but you should make it a grid!
April 11, 2016
Pretty good job! I figured out that you could just drag the puzzle piece around though and it will still stick to the grid! This could probably be fixed with some logic concerning the corners and sides happening before some of the middle ones, and those happen before some more middle ones... And so on, until the puzzle is over. This stuff is all about logic.