Ответ:
import turtle
import random
wn = turtle.Screen()
wn.bgcolor("white")
wn.title("Втеча черепашок")
turtles = []
colors = ["red", "blue", "green", "purple", "orange", "brown", "pink", "gray"]
for i in range(8):
t = turtle.Turtle()
t.color(colors[i % len(colors)])
t.shape("turtle")
t.penup()
t.setposition(random.randint(-200, 200), random.randint(-200, 200))
t.pendown()
turtles.append(t)
def click_handler(x, y):
for t in turtles:
angle = t.towards(x, y)
t.setheading(angle)
t.forward(50)
wn.onclick(click_handler)
turtle.mainloop()
Объяснение:
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
import turtle
import random
wn = turtle.Screen()
wn.bgcolor("white")
wn.title("Втеча черепашок")
turtles = []
colors = ["red", "blue", "green", "purple", "orange", "brown", "pink", "gray"]
for i in range(8):
t = turtle.Turtle()
t.color(colors[i % len(colors)])
t.shape("turtle")
t.penup()
t.setposition(random.randint(-200, 200), random.randint(-200, 200))
t.pendown()
turtles.append(t)
def click_handler(x, y):
for t in turtles:
angle = t.towards(x, y)
t.setheading(angle)
t.forward(50)
wn.onclick(click_handler)
turtle.mainloop()
Объяснение: