Thank you for visiting Blazing Games

Putting the Pieces Together

Building a quick puzzle game like the one in episode 17 is not that difficult. While the irregular pieces of the shapes may seem like an issue, when you think about it, all the pieces in the game are made up of a group of one or more squares. This means that all you need to define a piece is a list of squares that make up the piece and their relative position to the position you define as an origin point. My choice of origin point is the upper left corner. This information can be defined in constants that are created when the game is initialized.

Now that we have the pieces, we have to figure out a way of assembling the distinct pieces into a whole. My solution was to have a grid hold information about the placement of the pieces. When you place a piece on the placement grid, you simply mark all the pieces on the grid that the piece occupies as occupied. This is all done relatively to the location that was selected for the placement of the piece. We already have arrays containing the relative positions of the blocks that make up the piece so this is a very simple task to perform.

The problem is that it is possible to place a piece on the grid that overlaps existing pieces. The solution to this problem is to simply check to make sure that all the blocks within the piece can be placed where we wish to place them.

Finally, we can very simply determine if the game has been won by simply looking at the grid used to place the pieces and see if all the pieces have been covered. This has the extra benefit of allowing solutions to the problem that we have not foreseen, if such a solution exists.

Previous page
Chapter 17 Page 5

About - Privacy Policy - Contact - Links - FAQ
Copyright © 2007 Blazing Games Inc. All Rights Reserved