-
Book Overview & Buying
-
Table Of Contents
Android NDK Game Development Cookbook
By :
This recipe you shows how to implement the game logic for a picture puzzle game. The game consists of a set of rectangular tiles shuffled and rendered on the screen. Users can tap on individual tiles, and move them around, swapping them with the other tiles. Let us draft the backbone data structures to implement this logic.
To feel the game logic better, you can build and run the 2_PuzzleProto project, which can be downloaded from www.packtpub.com/support. If you want to enjoy the full-featured game, just go ahead and download our Linderdaum Puzzle HD from Google Play. You can do it at http://play.google.com/store/apps/details?id=com.linderdaum.engine.puzzLHD.

First, we need the clTile class to store the state of an individual puzzle piece. It contains the current coordinates of the tile's upper-left corner, the original indices of the tile in the grid, and the target coordinates where this tile will move to:
class clTile
{...
Change the font size
Change margin width
Change background colour