Python乌龟设置起始位置 [英] Python turtle set start position

查看:43
本文介绍了Python乌龟设置起始位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在启动代码时设置 startpos(乌龟方块的左上角)?

How do I set the startpos (topleft of my turtle square) when starting my code?

我并不是说它从中间开始,然后到那个位置.

And I don't mean that it starts from the middle and then goes to that position.

我希望乌龟从那里开始.

I want the turtle to start there.

推荐答案

您可以将世界坐标设置为其他内容.例如,要从左下角附近开始,请执行以下操作:

You can set the world coordinates to something else. For example, to start near the lower left corner, do:

turtle.setworldcoordinates(-1, -1, 20, 20)

这将使整个窗口为 21x21单位",并将原点放置在距底部和左侧边缘一个单位的位置.您命令的任何位置也将使用这些单位(而不是像素).

This will make the entire window be 21x21 "units" and place the origin one unit from the bottom and left edges. Whatever position you command will also be in terms of these units (rather than pixels).

这篇关于Python乌龟设置起始位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆