Game Development Reference
In-Depth Information
That's it. We store each and every shape in this 4D array. The content of the array is deined
in the Pentomino.cpp ile. The following code is the extract that deines all 4 rotations of a
single shape:
char Shapes [ NUM_SHAPES ][ ROTATIONS ][ SHAPES_X ][ SHAPES_Y ] =
{
{
{
{0, 0, 0, 0, 0},
{0, 0, 0, 1, 0},
{0, 0, 3, 2, 0},
{0, 5, 4, 0, 0},
{0, 0, 0, 0, 0}
},
{
{0, 0, 0, 0, 0},
{0, 5, 0, 0, 0},
{0, 4, 3, 0, 0},
{0, 0, 2, 1, 0},
{0, 0, 0, 0, 0}
},
{
{0, 0, 0, 0, 0},
{0, 0, 4, 5, 0},
{0, 2, 3, 0, 0},
{0, 1, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{
{0, 0, 0, 0, 0},
{0, 1, 2, 0, 0},
{0, 0, 3, 4, 0},
{0, 0, 0, 5, 0},
{0, 0, 0, 0, 0}
}
},
The non-zero values in the array deine which cells belong to the shape. The magnitude of the
value deines the color of the cell.
See also
F Writing the match-3 game
 
Search WWH ::




Custom Search