天天看點

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

CodeMonkey過關學習筆記系列:特技關卡 8-1 ~ 8-15 關
特技關卡 -
until near banana
    turnTo banana
    step 
           
CodeMonkey過關學習筆記系列:特技關卡 8-1 ~ 8-15 關
特技關卡 -
for b in bananas
    until near b
        turnTo b
        step 
           
CodeMonkey過關學習筆記系列:特技關卡 8-1 ~ 8-15 關
特技關卡 -
chase = (b) ->
    until near b
        turnTo b
        step 

chase bananas[]
chase bridge
chase bananas[]
           
CodeMonkey過關學習筆記系列:特技關卡 8-1 ~ 8-15 關
特技關卡 -
until near banana
    say "Not yet..."
    crocodile.turn 
           
CodeMonkey過關學習筆記系列:特技關卡 8-1 ~ 8-15 關
特技關卡 -
until beavers[].near bananas[]
    beavers[].step 
until beavers[].near bananas[]
    beavers[].step 
until beavers[].near bananas[]
    beavers[].step 

step distanceTo islands[]
           
CodeMonkey過關學習筆記系列:特技關卡 8-1 ~ 8-15 關
特技關卡 -
until near banana
    turtle.turnTo banana
    turtle.step 
           
CodeMonkey過關學習筆記系列:特技關卡 8-1 ~ 8-15 關
特技關卡 -
until cat.sleeping()
    wait()

step distanceTo banana
           
CodeMonkey過關學習筆記系列:特技關卡 8-1 ~ 8-15 關
特技關卡 -

step distanceTo islands[]

until near banana
    wait()
           
CodeMonkey過關學習筆記系列:特技關卡 8-1 ~ 8-15 關
特技關卡 -
i = 
for b in bridges
    turnTo b
    step distanceTo b
    until near bananas[i]
        wait()
    i++
           
CodeMonkey過關學習筆記系列:特技關卡 8-1 ~ 8-15 關
特技關卡 -
for c in crocodiles
    c.turn 
for b in bananas

    step 
    until near b
        wait()

           
CodeMonkey過關學習筆記系列:特技關卡 8-1 ~ 8-15 關
特技關卡 -
for banana in bananas
    until near banana
        wait()
           
CodeMonkey過關學習筆記系列:特技關卡 8-1 ~ 8-15 關
特技關卡 -
for banana in bananas
    until near banana
        crocodile.turn 
        wait()

           
CodeMonkey過關學習筆記系列:特技關卡 8-1 ~ 8-15 關
特技關卡 -
until cats[].sleeping()
        wait()
    step 
until cats[].sleeping()
        wait()
    step 

           
CodeMonkey過關學習筆記系列:特技關卡 8-1 ~ 8-15 關
特技關卡 -
i = 
for t in turtles
    step distanceTo t
    d = distanceTo bushes[i]
    t.step d
    until near bananas[i]
        wait()
    t.step -d
    i = i + 
           
CodeMonkey過關學習筆記系列:特技關卡 8-1 ~ 8-15 關
特技關卡 -
goto = (t) ->
    turnTo t
    step distanceTo t
until cat.sleeping()
    wait()
goto bananas[]
until cat.sleeping()
    wait()
goto bushes[]
goto bushes[]
until near bananas[]
    wait()
           

繼續閱讀