'코드'
let 상수를 정의 하여
world.place ( expert, atColumn:1,row:1) 캐릭터 위치를 지정해줍니다.
func 사용하여 함수를 정의 합니다.
let expert = Expert()
world.place(expert, atColumn:2, row: 6)
func turnAround() {
expert.turnLeft()
expert.turnLeft()
}
func turnLockCollectGem() {
expert.turnLeft()
expert.turnLockUp()
turnAround()
expert.moveForward()
expert.collectGem()
turnAround()
expert.moveForward()
expert.turnRight()
}
turnLockCollectGem()
expert.move(distance: 5)
turnLockCollectGem()
expert.move(distance: 6)
expert.collectGem()
'Playgrounds'플레이그라운드'' 카테고리의 다른 글
Playgrounds '플레이그라운드' 16. (0) | 2024.05.24 |
---|---|
Playgrounds '플레이그라운드' 15. (0) | 2024.05.22 |
Playgrounds '플레이그라운드' 14. (0) | 2024.05.21 |
Playgrounds '플레이그라운드' 13. (0) | 2024.05.20 |
Playgrounds '플레이그라운드' 12. (0) | 2024.05.20 |