Worklog for Glenn Dodd

Jigsaw Puzzle

Return to Worklogs

Jigsaw Puzzle 21 July 2007(Posted 2007-07-20)
To start with i will be using Greys Framework, which is really good as now i have a project to do i will learn it properly. Thanks Grey.
The concept is fairly simple. Get a picture, cut it into pieces, mix them up and then try to reassemble.
To start with i will use pieces that are square. There won't be any fancy interconnecting bits. Once i have this working i will add different shapes (triangles, octagonals etc) with the nice connecting pieces.
Staring with a simple 4 * 4 piece puzzle.
Each piece being numbered:
1, 2, 3, 4
5, 6, 7, 8
9, 10, 11, 12
13, 14, 15, 16

The puzzle piece type will hold:
Number, image, 4 sides (top, bottom, left and right). Each side will have a reference to the side of another piece it connects to. ie the top of piece 7 will connect to the bottom of piece 3. Each side will have a boolean for "side connected" so it should be easier to move joined pieces around. ie if i move piece 7, and it is already connected to piece 3 then both should move.
Each side should have a center point (screen x and y coordinate) so if a piece is dropped next to it, and the 2 center points are close enough, then they can snap together, aligning themselves properly. That should also simplify the checks for if an item is close enough to a correct joining piece, as i only need to check if any of the 4 sides (center points) are close enough to a joining side (center point).

Once i get the basic game functionality working then i will add timers, help methods (showing which pieces it should join to, or where on the picture grid it fits in) and being able to choose your own picture, number of pieces and shape for the pieces.

I would really appreciate some feedback on how other poeple would do this too.

Cheers
Glenn