Algorithm for jigsaw puzzle

I am planning to develop a jigsaw puzzle game in game.
Now I already have images and image pieces. So we dont need algorithm to cut the image in pieces.

On the UI side there would be two sections

1)First section contains the broken images in random order.
2) Second section contains the outline of the full image. User need to drag and drop the the cut images onto the outline image.

I am not sure how can the pieces be matched on the the outline image?
Any idea about the algorithm or the starting pointers?

Since you already know the size of the pieces and their location. You can store the pieces locations. When the user moves the pieces close enough to it correct location, you can have it “snap” to the location.

In my approach, create class for your piece (let’s call it Piece class). Jigsaw piece has some type, list it and define it on your Piece (something like typeValue). Based on this value, you can choose what picture a piece has on constructor. To check if it matches or not, just see the value on your class (Piece object) to the value on your second section.

Hope can help you :smiley: