天天看點

CodeMonkey過關學習筆記系列:特技關卡 11-1 ~ 11-16 關

CodeMonkey過關學習筆記系列:特技關卡 11-1 ~ 11-16 關
特技關卡 -

for b in bananas
    until tiger.sleeping() and bear.sleeping()
        wait()
    goto b

//封裝為函數
waitFor=()->
    until tiger.sleeping() and bear.sleeping()
        wait()
for b in bananas
    waitFor()
    goto b
           
CodeMonkey過關學習筆記系列:特技關卡 11-1 ~ 11-16 關
特技關卡 -
for b in bananas
    until tiger.sleeping() and bear.sleeping()
        wait()    #在這裡增加編碼
    if b.frozen()
        goat.goto b
        goat.hit()
    until tiger.sleeping() and bear.sleeping()
        wait() 
    goto b


//封裝為函數
waitFor=()->
    until tiger.sleeping() and bear.sleeping()
        wait()

for b in bananas
    waitFor()    #在這裡增加編碼
    if b.frozen()
        goat.goto b
        goat.hit()
    waitFor() 
    goto b
           
CodeMonkey過關學習筆記系列:特技關卡 11-1 ~ 11-16 關
特技關卡 -
x = 
times ->
    until bears[x].sleeping() and tigers[x].sleeping()
        wait()
    goto bananas[x]
    x = x + 
//========================================================================================
waitFor=(obj1, obj2) ->
    until obj1.sleeping() and obj2.sleeping()
        wait()
x = 
times ->
    waitFOr(bears[x], tigers[x])
    goto bananas[x]
    x = x + 
           
CodeMonkey過關學習筆記系列:特技關卡 11-1 ~ 11-16 關
特技關卡 -

until tiger.sleeping() and bear.sleeping()
    wait() 
for b in bananas
    goto b    
           
CodeMonkey過關學習筆記系列:特技關卡 11-1 ~ 11-16 關
特技關卡 -
for b in bananas
    until bear.sleeping() or bear.playing()
            wait()
    if b.green()
        goat.goto b
    else
        monkey.goto b
           
CodeMonkey過關學習筆記系列:特技關卡 11-1 ~ 11-16 關
特技關卡 -

for b in bananas

    if b.green()
        until tiger.sleeping() or tiger.playing()
            wait()
        goat.goto b

    else
        until bear.sleeping() or bear.playing()
            wait()

        goto b

//--------------------------------------------------------------------------------
waitFor = (obj) ->
     until obj.sleeping() or obj.playing()
            wait()
for b in bananas
    if b.green()
        waitFor(tigger)
        goat.goto b
    else
        waitFor(bear)
        goto b
           
CodeMonkey過關學習筆記系列:特技關卡 11-1 ~ 11-16 關
特技關卡 -
x = 
times ->
    until bears[x].sleeping() or bears[x].playing()
        wait()
    #我們最好等待熊睡覺或是玩耍
    goto bananas[x]
    x = x - 
//----------------------------------------------------------------------------
waitFor = (obj) ->
     until obj.sleeping() or obj.playing()
            wait()
x = 
times ->
    waitFor(bears[x])
    goto bananas[x]
    x = x - 
           
CodeMonkey過關學習筆記系列:特技關卡 11-1 ~ 11-16 關
特技關卡 -

until tiger.sleeping() or tiger.playing()
    wait()
goat.goto bridges[]

until tiger.sleeping() or tiger.playing()
    wait()
monkey.goto bridges[]

for b in bananas
    if b.frozen()
        goat.goto(b)
        goat.hit()
    monkey.goto b
           
CodeMonkey過關學習筆記系列:特技關卡 11-1 ~ 11-16 關
特技關卡 -
for b in bananas
    if b.green() or b.frozen()
        if b.frozen()
            goat.goto b
            goat.hit()
        goat.goto b


goto bananas[]
           
CodeMonkey過關學習筆記系列:特技關卡 11-1 ~ 11-16 關
特技關卡 -

for b in bananas
    if b.green() or b.frozen()
        if b.frozen()
            goat.goto b
            goat.hit()
        goat.goto b


times ->
    step 
    turn left
           
CodeMonkey過關學習筆記系列:特技關卡 11-1 ~ 11-16 關
特技關卡 -

chaser = bear
times ->
    say chaser
    until chaser.sleeping() or chaser.playing()
        wait()
    step 
    chaser= tiger
           
CodeMonkey過關學習筆記系列:特技關卡 11-1 ~ 11-16 關
特技關卡 -

chaser = tiger
mover = monkey

for b in bananas
    if b.green()
        #完成我:
        chaser = bear
        mover = goat
    else
        #和我:
        chaser = tiger
        mover = monkey

    until chaser.sleeping() or chaser.playing()
        wait()
    mover.goto b
           
CodeMonkey過關學習筆記系列:特技關卡 11-1 ~ 11-16 關
特技關卡 -

x = 
times ->
    for stepper in [monkey,goat]
        until tigers[x].sleeping() and bears[x].sleeping()
            wait()
        stepper.step    
    x = x + 
           
CodeMonkey過關學習筆記系列:特技關卡 11-1 ~ 11-16 關
特技關卡 -
waitFor = (b) ->
    until b.sleeping() or b.playing()
        wait()
x = 
times ->
    waitFor(bears[x])
    goto bananas[x]
    waitFor(bears[x])
    goto turtle
    turtle.step 
    x = x + 
           
CodeMonkey過關學習筆記系列:特技關卡 11-1 ~ 11-16 關
特技關卡 -
until (tiger.playing() or tiger.sleeping()) and (bear.playing() or bear.sleeping())
    wait()
goto banana
           
CodeMonkey過關學習筆記系列:特技關卡 11-1 ~ 11-16 關
特技關卡 -
for b in bananas
    until ( bear.playing() or bear.sleeping() ) and ( tiger.playing() or tiger.sleeping() ) 
        wait()
    goto b
           

繼續閱讀