CodeMonkey过关学习笔记系列:86-95关
•“直到”沙地 ( THE SANDS OF UNTIL )86~100
第 86 关挑战
//"直到"沙地
//接下来要介绍的是 直到 until 这个循环指令 !
//这个和71关是一样的。这里用到了until和near。
until near match
step 1
grab()
until near pile
step 1
drop()
第 87 关挑战
//接近 near 这个指令会返回给你 - 肯定的 yes 或 否定的 no 的结果
//这个和71,86关是一样的。这里用到了until和near。
until near match
step 1
grab()
until near pile
step 1
drop()
第 88 关挑战
//如果你不好好使用的话 , 直到 until 这个循环指令将会永无止尽的继续下去.
//介绍了死循环
until near match
step 1
grab()
turnTo pile
until near pile
step 1
drop()
第 89 关挑战
接下来你需要好好利用 直到 until 这个循环指令哦.
until near match
step 1
grab()
turnTo pile
step distanceTo pile
drop()
第 90 关挑战
turn left
until near match
step 1
grab()
turnTo pile
step distanceTo pile
drop()
第 91 关挑战
until near match
step 1
grab()
turnTo pile
step distanceTo pile
drop()
第 92 关挑战
until turtle.near bridge
turtle.step 1
grab()
step distanceTo pile
drop()
第 93 关挑战
until near match
turnTo match
step 1
grab()
turnTo pile
step distanceTo pile
drop()
第 94 关挑战
希望你没有忘了函数,也就是 functions !
chase = (m) ->
until near m
turnTo m
step 1
chase match
grab()
chase pile
drop()
第 95 关挑战
chase = (m) ->
until near m
turnTo m
step 1
#这段代码是正常的:
for m in matches
chase m
grab()
chase pile
drop()
CodeMonkey过关学习笔记系列:96-100关
•“直到”沙地 ( THE SANDS OF UNTIL )86~100
第 96 关挑战
goto = (t) ->
turnTo t
step distanceTo t
collect = (t) ->
goto t
grab()
goto pile
drop()
#如果猫还醒着,千万别走过去!
until cat.sleeping()
wait()
collect match
step 15
第 97 关挑战
用 wait 指令来静待猫咪睡觉吧...
goto = (t) ->
turnTo t
step distanceTo t
collect = (t) ->
goto t
grab()
goto pile
drop()
for m in matches
until cat.sleeping()
wait()
collect m
第 98 关挑战
goto = (t) ->
turnTo t
step distanceTo t
#让这个函数能够收集t collect t
#并且不要被吃掉或掉到水里哦
safeCollect = (t) ->
until cat.sleeping()
wait()
#就在那儿!
goto bridge
goto t
grab()
goto bridge
goto pile
drop()
for m in matches
safeCollect m
第 99 关挑战
chase = (t) ->
#实现这里!
turnTo t
step distanceTo t
safeCollect = (m) ->
until cat.sleeping()
wait()
#完成这里!
until near m
chase m
grab()
chase pile
drop()
safeCollect match
第 100 关挑战
chase = (t) ->
turnTo t
step distanceTo t
safeCollect = (m) ->
until cat.sleeping()
wait()
until near m
chase m
grab()
chase pile
drop()
for m in matches
safeCollect m