O'Reilly logo

Beginning Facebook Game Apps Development by Wayne Graham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding Levels

If you recall, the code in the last chapter was written to allow you to dynamically generate a grid. The examples in that chapter defaulted to a 3 × 3–grid, but by changing the instantiation parameter, you can easily change this to 4 × 4, 5 × 5, and so on. Each time you add a grid column and row, you add a magnitude of complexity and challenge to the game. Not only does the number of tiles grow exponentially but picking out details to properly order the tiles becomes more difficult. We can use this fact to implement a level system, though some thought needs to go in to capping the maximum number of tiles that are playable as a maximum level. For instance, while technically possible, a 400 × 400–grid would give us a total of 160,000 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required