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 ...
Get Beginning Facebook Game Apps Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.