1

Create a SpriteKit Game Project

11:21FreeDone
2

Lay Out the Game UI

8:54FreeDone
3

Define the Game Piece Model

13:16FreeDone

Create the Level Model

5:47FreeDone
5

Draw the Rune Sprites

6:02FreeDone
6

Detecting Taps on Runes

5:27ProsDone
7

Determine Swipe Direction

6:18ProsDone
8

Add Physics to Shatter Runes

14:00ProsDone
9

Build Out the UI Text

12:24ProsDone
10

Keeping Score

8:41ProsDone
11

Displaying Score Feedback

8:18ProsDone

Create the Level Model

Published by Chris Slowik

Episode Notes

Extra tips from the author

Now that there’s a game piece to organize, lets start making the model for the game level. It’s pretty simple, since its just a single column of tiles. We’ll create functions to generate a level based on the level number. These can be tweaked to adjust the difficulty curve.

class Level {
    // MARK: - Properties
    var numSlots: Int = 7
    fileprivate var runes = [Rune]()

    // MARK: - Utility
    func runeAt(slot: Int) -> Rune {
        assert(slot >= 0 && slot < numSlots)
        return runes[slot]
    }

    func generateLevel(_ level: Int) -> [Rune] {
        numSlots = 7 + level * 7
        let newLevel = generateLevel()
        return newLevel
    }

    private func generateLevel() -> [Rune] {
        var newLevel = [Rune]()

        for slot in 0 ..< numSlots {
            let runeType = RuneType.random()
            let runeColor = RuneColor.random()
            let rune = Rune(slot: slot, runeColor: runeColor, runeType: runeType)
            runes.append(rune)
            newLevel.append(rune)
        }
        return newLevel
    }
}
Episode Topics: