如果 turtle 在一组坐标之上,我想让 turtle 回到地板上:
像这样:
floor = -323
if turtle above floor:
turtle.goto(floor)
但我不知道 'if' 语句是如何工作的,因为你不能简单地把 'if turtle above floor' 有什么帮助吗?
请您参考如下方法:
假设您的“下限”位于 y=-323,您可能会这样做:
floor = -323
if turtle.ycor() > floor:
turtle.sety(floor)
您使用 turtle.ycor() 检索 turtle 的 y 坐标,检查它是否大于 floor,如果它被设置为等于地板的 y 坐标。
