Skip to content

Instantly share code, notes, and snippets.

@stepheng
Last active November 30, 2016 00:09
Show Gist options
  • Save stepheng/21eb373d546ad9251a6b71ffd9c8a11f to your computer and use it in GitHub Desktop.
Save stepheng/21eb373d546ad9251a6b71ffd9c8a11f to your computer and use it in GitHub Desktop.
let tileString = "0100100000" +
"0111100110" +
"0111101010" +
"0001001000" +
"0011000100" +
"0011100010" +
"0011110010" +
"0011110010" +
"0001110010" +
"0011111100"
tiles = [[Tile]]()
for row in 1...height {
var rowArray = [Tile]()
for col in 0..<width {
let indexVal = ((height - row) * width) + col
let index = tileString.index(tileString.startIndex, offsetBy: indexVal)
let character = tileString[index]
let value = Int(String(character))!
let tile = Tile(pos: (col, row), hidden: true, colorIndex: value)
rowArray.append(tile)
}
tiles.append(rowArray)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment