Game Development Reference
In-Depth Information
Creating a piece
To create the jigsaw pieces, we start out with masks. The mask merged with the part
of the puzzle image is shown as follows:
There are totally 64 different masks that are applied to different parts of the image.
Each mask is stored as a PNG file in the jig/rsrc/mask folder of the project. Each
mask is brought into memory by jig.game.MaskAsset , like the snippet shown next:
package jig.game
{
public class MaskAsset
{
[Embed(source="jig\\rsrc\\mask\\17.png")]
public static const C17: Class;
[Embed(source="jig\\rsrc\\mask\\18.png")]
public static const C18: Class;
[Embed(source="jig\\rsrc\\mask\\20.png")]
public static const C20: Class;
[Embed(source="jig\\rsrc\\mask\\21.png")]
public static const C21: Class;
Each mask has an ID, which has great significance. Note that the filenames don't start
from 0 and go all the way to 63. Instead they represent the shape of the mask.
The edges of a piece can be of three different types:
• Flat
• Convex
• Concave
If the edge of the mask is flat, then we give it a binary value of 00. The edge will be
flat only if the piece is in the corner or along the edge. If the edge is convex, then we
give it a value of 01, and if the edge is concave, we give it a value of 10.
The name of the file is then formed by concatenating the piece's edge value in the
top, bottom, left, and right order.
 
Search WWH ::




Custom Search