-3

I have created a nice pattern using the following one line code

repeat 36 [repeat 10[fd 10 rt 36] rt 10]

Now I want this to appear as if it is rotating. I have tried to clear the screen and then rotate the turtle a at a specific angle and then print the pattern again. But there is something completely wrong in my logic. Can anybody help?

4

1 回答 1

2

为了完成动画,你需要一个支持它的解释器。解释器必须是在显示之前渲染整个输出的解释器(在绘制过程中不显示海龟的移动),并且它还必须支持wait命令(或类似的东西)。符合这些资格的口译员的一个例子是www.logointerpreter.com上的口译员。这是一个让你的轮子旋转一整圈并与该解释器一起工作的示例:

ht
repeat 360
[
  clean
  repeat 36 [repeat 10[fd 10 rt 36] rt 10]
  wait 10
  rt 1
]

如您所见,外部循环绘制了 360 个单独的帧。绘制完每一帧后,它会等待 10 毫秒,因此您可以看到该帧。然后在清除屏幕并开始绘制下一帧之前将海龟旋转一度。如果您需要更多控制,您还可以将每帧的起始角度存储在一个变量中,如下所示:

ht
make "start 0
repeat 360
[
  cs
  rt :start
  repeat 36 [repeat 10[fd 10 rt 36] rt 10]
  wait 10
  make "start (:start + 1)
]
于 2014-11-24T11:39:29.347 回答