Game development for Apple platforms

First screenshot of all pieces in play

Now that the physics body creation for the blocks is a solved problem, we can quickly implement all 7 types:

And when the MatchSliceController needs to spawn one, we can just grab a random piece by putting all the initializers in an array:

class func random() -> BasePiece
{
    let options: [(Int) -> BasePiece] = [
        LPiece.init(gridSize:),
        JPiece.init(gridSize:),
        IPiece.init(gridSize:),
        OPiece.init(gridSize:),
        SPiece.init(gridSize:),
        ZPiece.init(gridSize:),
        TPiece.init(gridSize:),
    ]
    
    guard let constructor = options.randomElement() else {
        fatalError("No pieces available")
    }
    
    let gridSize = 30
    return constructor(gridSize)
}

#screenshot #spritekit