shapes = ["square", "triangle", "circle"]
我想用使用 onkey 函数制作的列表来改变海龟的形状。我的意思是每当我按下一个按钮时,例如 h,我将如何制作它,以便每当我按下 h 时它都会穿过每个形状。我将使用该turtle.shape ()
功能来实现这一点。
到目前为止,我所做的是创建了一个形状列表,但我不知道如何实现我想要实现的下一个目标。
def turtle1 ():
shapes = ["square", "triangle", "circle", "pentagon", "star", "octagon"]
shapeiter = itertools.cycle(shapes)
next(shapeiter)
1
shape(next(shapeiter))
next(shapeiter)
2
shape(next(shapeiter))
next(shapeiter)
3
shape(next(shapeiter))
next(shapeiter)
4
shape(next(shapeiter))
next(shapeiter)
5
shape(next(shapeiter))
next(shapeiter)
6
shape(next(shapeiter))
onkey(turtle1, "h")