Python精灵模块的path2points指令

所有命令 单独命令 屏幕命令 角色命令

单独命令 >> Python精灵模块的path2points指令

简介:把路径中每隔step距离的点算出来放在列表中,返回此列表。
例子:
from sprites import path2points,Screen,Sprite

A = (100,100)
B = (0,0)
C = (200,0)
points = [A,B,C,A]
path = path2points(points)

screen = Screen()
screen.setup(480,360)
screen.xy_grid()
bug = Sprite()
bug.draw_line(A,B)
bug.draw_line(C,B)
bug.draw_line(A,C)
while True:
   for x,y in path:
      screen.title(f"({round(x)},{round(y)})")
      bug.goto(x,y)
      bug.wait(0.01)

writed by lixingqiu 关注"异编程"微信公众号,获取更多关于Python精灵模块的咨讯: