【问题标题】:How do i calculate the location of Turtle on the screen [duplicate]我如何计算乌龟在屏幕上的位置[重复]
【发布时间】:2021-09-23 13:31:11
【问题描述】:

enter image description here

#Need to figure out turtle's location.
#Need to know it's x/z location in a variable and it's y co-ordinate in another variable seperatley to the x/z co-ordinate

我需要类似的东西 龟X = ... TurtleY = ...

所以我可以在我的游戏中使用这些。

【问题讨论】:

  • 不要发布代码图片。代码应作为格式化文本(即代码块)发布到问题本身中。阅读minimal reproducible example 了解需要包含的内容。

标签: python turtle-graphics python-turtle


【解决方案1】:

如果我理解正确,试试这个

>>> turtle.pos()     # -> (x, y)
>>> turtle.xcor()    # -> x
>>> turtle.ycor()    # -> y

如果您需要更多信息,我强烈推荐site

【讨论】:

  • 太棒了!有没有办法将这些存储为变量?没有也没关系。
  • 当然! x = turtle.xcor()
  • Turtle 移动时值不变!是故意的吗?
  • 只是阅读文档,伙计。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-03
  • 2017-12-19
  • 2018-04-25
相关资源
最近更新 更多