CodeMonkey过关学习笔记系列:86-95关

CodeMonkey过关学习笔记系列:86-95关

image103.jpeg

86 关挑战

//"直到"沙地
//接下来要介绍的是 直到 until 这个循环指令 !
//这个和71关是一样的。这里用到了until和near。
until near match
    step 1

grab()
until near pile
    step 1
drop()

image104.jpeg

87 关挑战

//接近 near 这个指令会返回给你 - 肯定的 yes 或 否定的 no 的结果
//这个和71,86关是一样的。这里用到了until和near。

until near match
    step 1
grab()
until near pile
    step 1
drop()

image105.jpeg

88 关挑战

//如果你不好好使用的话 , 直到 until 这个循环指令将会永无止尽的继续下去.
//介绍了死循环

until near match
    step 1
grab()
turnTo pile
until near pile
    step 1
drop()

image106.jpeg

89 关挑战

接下来你需要好好利用 直到 until 这个循环指令哦.

until near match
    step 1
grab()
turnTo pile
step distanceTo pile
drop()

image107.jpeg

90 关挑战
turn left
until near match
    step 1
grab()
turnTo pile
step distanceTo pile
drop()


image108.jpeg

91 关挑战

until near match
    step 1
grab()
turnTo pile
step distanceTo pile
drop()

image109.jpeg

92 关挑战
until turtle.near bridge
    turtle.step 1
grab()
step distanceTo pile
drop()



image110.jpeg

93 关挑战

until near match
    turnTo match
    step 1
grab()
turnTo pile
step distanceTo pile
drop()

image111.jpeg

94 关挑战

希望你没有忘了函数,也就是 functions !
chase = (m) ->
    until near m
        turnTo m
        step 1
chase match
grab()
chase pile
drop()

image112.jpeg

95 关挑战
chase = (m) ->
    until near m 
        turnTo m
        step 1
#这段代码是正常的:
for m in matches
    chase m
    grab()
    chase pile
    drop()


猜你喜欢

转载自blog.csdn.net/mmh19891113/article/details/80748320