Swift Playgrounds 基于笛卡尔坐标的立体金字塔
The most difficult thing in life is to know yourself.
- Thales
var coords: [Int] = []
var increse = 9
for i in 1 ... 4 {
for j in i ... i + increse {
coords.append(j)
}
let insideSquare = world.coordinates(inColumns: coords, intersectingRows: coords)
for coordinate in insideSquare {
for i in 1 ... 2 {
world.place(Block(), at: coordinate)
}
}
increse -= 2
coords.removeAll()
}
let squareLock = PlatformLock(color: .green)
coords = [5, 6]
let insideSquare = world.coordinates(inColumns: coords, intersectingRows: coords)
for coordinate in insideSquare {
world.place(Platform(onLevel: 6, controlledBy: squareLock), at: coordinate)
world.place(Block(), at: coordinate)
}
world.place(Character(name: .blu), facing: .north, at: Coordinate(column: 6, row: 6))