本文整理汇总了Python中turtle.Turtle.xcor方法的典型用法代码示例。如果您正苦于以下问题:Python Turtle.xcor方法的具体用法?Python Turtle.xcor怎么用?Python Turtle.xcor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类turtle.Turtle
的用法示例。
在下文中一共展示了Turtle.xcor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: range
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import xcor [as 别名]
for i in range(-4,5):
for j in range(-4, 5):
if i == j == 0:
continue
c = Turtle(shape="circle")
c.color("", "orange")
c.shapesize(0.5)
c.goto(40*i, 40*j)
coins.append(c)
s.tracer(True)
DRUNKENNESS = 45
t = Turtle(shape="turtle")
t.color("black","")
points = 0
while abs(t.xcor()) < 200 and abs(t.ycor()) < 200:
t.forward(5)
t.right(randint(-DRUNKENNESS, DRUNKENNESS))
found = None
for c in coins:
if t.distance(c) < 10:
found = c
break
if found:
found.hideturtle()
coins.remove(found)
t.shapesize(1+points/5., outline=1+points)
points += 1
writer.write("{0} points".format(points),
align="center", font=('Arial', 24, 'bold'))