我编写了以下代码,它在两个随机位置创建了扩展方块。我想编写一个函数 f(square,seconds),这样如果用户输入f(5,10),则每隔10秒开始形成一个新的正方形,直到5形成。
我似乎无法找到任何可以让我开始新广场的东西。我可以同时制作两个表格,如下面的代码,或者一个完成,然后另一个开始形成。帮助
import sys
sys.setExecutionLimit(1000000)
import turtle
import random
wn = turtle.Screen()
#Creates alex the turtle
alex = turtle.Turtle()
alex.color('blue')
alex.pensize(3)
alex.ht()
alex.penup()
#creates bob the turtle
bob = turtle.Turtle()
bob.color('blue')
bob.pensize(3)
bob.ht()
bob.penup()
#Sets variables so that alex starts in a random location
a=random.randrange(360)
b=random.randrange(360)
x=random.randrange(50,150)
y=random.randrange(50,150)
#Sets variables so that bob starts in a random location
l=random.randrange(360)
m=random.randrange(360)
n=random.randrange(50,150)
o=random.randrange(50,150)
#Moves alex to his random starting location
alex.speed(100)
alex.left(a)
alex.forward(x)
alex.left(b)
alex.forward(y)
alex.pendown()
#Moves bob to his random starting location
bob.speed(100)
bob.left(l)
bob.forward(n)
bob.left(m)
bob.forward(o)
bob.pendown()
#Draws the 2 squares
for i in range(1,500):
alex.forward(i)
alex.left(90)
bob.forward(i)
bob.left(90)