浮岛    构建循环  你自己的关卡

let greenPortal = Portal(color: #colorLiteral(red: 0.4028071761, green: 0.7315050364, blue: 0.2071235478, alpha: 1))


world.place (greenPortal, atStartColumn:

               

                1,

           

            startRow: 7,atEndColumn: 1, endRow: 1)

let A = Portal(color: #colorLiteral(red: 0.8043354153633118, green: 0.018336141481995583, blue: 6.016343689907444e-08, alpha: 1.0))


world.place (A, atStartColumn:

               

                2,

           

            startRow: 2,atEndColumn: 5, endRow: 4)

greenPortal.isActive = true

A.isActive = true

let expert = Character()

world.place(expert, facing: .north, atColumn: 1, row: 6)

let block9: Block = Block()

world.place(block9,

            atColumn: 1, row: 6)


let block8: Block = Block()

world.place(block8,

            atColumn: 5, row: 4)

let block7: Block = Block()

world.place(block7,

            atColumn: 6, row: 3)

let block6: Block = Block()

world.place(block6,

            atColumn: 2, row: 2)

let block5: Block = Block()

world.place(block5,

            atColumn: 1, row: 1)

for i in 1 ... 2 {

    let qc = Stair()

    world.place (qc,facing: .north, atColumn:2,row: 6)

    let qa = Stair()

    world.place (qa,facing: .north, atColumn:1,row: 6)

    let qb = Stair()

    world.place (qb,facing: .north, atColumn:1,row: 7)

}

func QQ() {

    if expert.isOnClosedSwitch {

        expert.toggleSwitch()

       

    } else if expert.isOnGem {

        expert.collectGem()

    }

}


for i in 1 ... 3 {

   

    for i in 1 ... 3 {

       

        for i in 1 ... 3 {

            if !expert.isBlocked {

                expert.moveForward()

            } else if  !expert.isBlockedRight {

                expert.turnRight()

               

            } else if !expert.isBlockedLeft {

                expert.turnLeft()

               

            }else if expert.isBlocked {

                expert.turnLeft()

                expert.turnLeft()

            }

           

            QQ()

           

        }

}

   

   

   

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
禁止转载,如需转载请通过简信或评论联系作者。

相关阅读更多精彩内容

友情链接更多精彩内容