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

image121.jpeg

特技關卡 11-1

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

image122.jpeg

特技關卡 11-2
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

image123.jpeg

特技關卡 11-3
x = 0
2.times ->
    until bears[x].sleeping() and tigers[x].sleeping()
        wait()
    goto bananas[x]
    x = x + 1
//========================================================================================
waitFor=(obj1, obj2) ->
    until obj1.sleeping() and obj2.sleeping()
        wait()
x = 0
2.times ->
    waitFOr(bears[x], tigers[x])
    goto bananas[x]
    x = x + 1

image124.jpeg

特技關卡 11-4

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

image125.jpeg

特技關卡 11-5
for b in bananas
    until bear.sleeping() or bear.playing()
            wait()
    if b.green()
        goat.goto b
    else
        monkey.goto b

image126.jpeg

特技關卡 11-6

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

image127.jpeg

特技關卡 11-7
x = 2
3.times ->
    until bears[x].sleeping() or bears[x].playing()
        wait()
    #我們最好等待熊睡覺或是玩耍
    goto bananas[x]
    x = x - 1
//----------------------------------------------------------------------------
waitFor = (obj) ->
     until obj.sleeping() or obj.playing()
            wait()
x = 2
3.times ->
    waitFor(bears[x])
    goto bananas[x]
    x = x - 1

image128.jpeg

特技關卡 11-8

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

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

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

image129.jpeg

特技關卡 11-9
for b in bananas
    if b.green() or b.frozen()
        if b.frozen()
            goat.goto b
            goat.hit()
        goat.goto b


goto bananas[3]

image130.jpeg

特技關卡 11-10

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


2.times ->
    step 20
    turn left

image131.jpeg

特技關卡 11-11

chaser = bear
2.times ->
    say chaser
    until chaser.sleeping() or chaser.playing()
        wait()
    step 10
    chaser= tiger

image132.jpeg

特技關卡 11-12

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

image133.jpeg

特技關卡 11-13

x = 0
3.times ->
    for stepper in [monkey,goat]
        until tigers[x].sleeping() and bears[x].sleeping()
            wait()
        stepper.step 10   
    x = x + 1

image134.jpeg

特技關卡 11-14
waitFor = (b) ->
    until b.sleeping() or b.playing()
        wait()
x = 0
2.times ->
    waitFor(bears[x])
    goto bananas[x]
    waitFor(bears[x])
    goto turtle
    turtle.step 10
    x = x + 1

image135.jpeg

特技關卡 11-15
until (tiger.playing() or tiger.sleeping()) and (bear.playing() or bear.sleeping())
    wait()
goto banana

image136.jpeg

特技關卡 11-16
for b in bananas
    until ( bear.playing() or bear.sleeping() ) and ( tiger.playing() or tiger.sleeping() ) 
        wait()
    goto b
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章