Using jQuery Mobile, we will create a mobile-friendly application—a game called TilePic (Figure 9-2). TilePic is a simple sliding-picture puzzle game with a few extra options and features to add longevity and interest. It is a good example of what’s realistic in terms of a graphical web application running on average mobile hardware. We could be more ambitious if developing for higher-end devices only, but for the sake of example, we will concentrate on creating an application that works acceptably on as many devices as possible.
Figure 9-2. TilePic, a simple mobile-friendly sliding puzzle game
TilePic works as follows:
The user is presented with a main menu screen (Figure 9-3).
The user chooses any one of three images.
The user selects the number of tiles to split the image into: 9, 16, or 25.
The user taps the Play button to start and is presented with the selected image split into tiles, which are randomly ordered to jumble the picture up. A faint watermark of the complete image is visible beneath the tiles to make the game a little easier (as shown earlier in Figure 9-2).
The user tries to correctly reassemble the picture, moving the tiles around by tapping them. At any time, the user can return to the main menu to select another image and/or difficulty level.
The application will automatically move multiple tiles—a ...