Your code appears to be complicated by the fact that Audience
contains a turtle instance when it might be simpler for Audience
to be a Turtle
subclass:
from turtle import Screen, Turtle
class Audience(Turtle):
def __init__(self, heading, position):
super().__init__(visible=False)
self.speed('fastest')
self.shape('turtle')
self.color('#bab86c')
self.penup()
self.goto(position)
self.setheading(heading)
self.shapesize(stretch_wid=2, stretch_len=2)
self.showturtle()
screen = Screen()
screen.title('Turtle')
screen.bgcolor('#1c2e4a')
screen.setup(width=800, height=600)
audience1 = Audience(180, (0, -260))
screen.mainloop()
Of course, as @Carcigenicate comments (+1) you're setting properties when you should be invoking methods, and you're redefining existing names. And avoid that while True:
and update()
model, you're heading the wrong direction. Consider ontimer()
, and other events, instead.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…