浮岛    构建循环  你自己的关卡
2024-04-09 17:30:35  阅读数 191

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()

           

        }

}

   

   

   

}