Tile game – SwiftSweeper

Time to stop talking about SpriteKit and get right into it! As stated at the beginning of this chapter, we will first show you how to make a simple-looking tile game in SpriteKit using the slightly more difficult boilerplate/code-drive-styled design. Don't worry, this is not going to involve direct calls to the GPU with C++ and handling extremely tiny memory requirements like veteran game developers did during the early console days. However, we will be using lots of code-heavy calls with SpriteKit objects, functions, and classes. Granted, getting down into the code directly is continually becoming less of the developer's responsibility as Apple continues to make more design-centric functionalities in Xcode.

Knowing the code structure can give you an edge over developers coming in on a more top-down methodology and coding will always be behind custom game logic.

Tile game – SwiftSweeper

What is SwiftSweeper?

SwiftSweeper is a clone of the classic tile puzzle game, MineSweeper, written entirely in Swift. SwiftSweeper makes use of Swift's ability to use Unicode emoticons so that we don't have to use many image assets and should give us a great starting point to making our own tile/puzzler game with difficulty levels.

We will build up much of the game from scratch, but the full source code can be found at https://github.com/princetrunks/SwiftSweeper.

Note

As at the time writing of this book, this was built in Xcode 7 Beta (7A120f) for the initial iOS 9 release and optimized for iPhone.

The goal of the game is to tap every tile on the game board without hitting mines hidden throughout the board. You do get some help though. Every tile that isn't a mine will tell the player how many tiles around it are mines. If the player knows that a tile without a doubt is a mine via the process of elimination, they can plant a flag on that tile to make sure that they don't tap that space. Tap all of the tiles that aren't a mine to win the game! SwiftSweeper even saves the time it took you to win for each difficulty level you chose to give the game a bit of replay value.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.76.138