用户:
二战德国淘汰王查看:0 回复:1 评论:0 创建时间:2024-01-24T10:34:50
【作品展示】

【作品介绍】
这是我第二个作品。
【作品源代码】
import turtle
p = turtle.Pen()
grid = [[0, 0, 1, 1, 1, 0],
[0, 0, 1, 3, 1, 1],
[1, 1, 1, 2, 2, 1],
[1, 3, 4, 4, 2, 1],
[1, 1, 2, 2, 2, 1],
[0, 1, 1, 1, 1, 1]]
width = len(grid[0])
height = len(grid)
s = 70
origin_x = -(width-1)/2*s
origin_y = (height-1)/2*s
turtle.addshape('墙壁.gif')
turtle.addshape('通道.gif')
tile_shapes = ['空.gif', '墙壁.gif', '通道.gif', '目标.gif', '箱子.gif']
for i in tile_shapes:
turtle.addshape(i)
p.shape('墙壁.gif')
p.penup()
p.hideturtle()
for i in range(width):
for j in range(height):
p.goto(origin_x + i * s, origin_y - j * s)
p.shape(tile_shapes[grid[j][i]])
p.stamp()
turtle.done()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn