# CodeMonkey過關學習筆記系列：特技關卡 11-1 ～ 11-16 關

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

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

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

``````特技關卡 11-4

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

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

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

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

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

``````特技關卡 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]
``````

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

``````特技關卡 11-11

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

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

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

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

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

``````特技關卡 11-16
for b in bananas
until ( bear.playing() or bear.sleeping() ) and ( tiger.playing() or tiger.sleeping() )
wait()
goto b
``````