用户:
花金柔查看:0 回复:0 评论:0 创建时间:2021-05-02T12:15:47
【作品展示】

【作品介绍】
太空飞车
【作品源代码】
import random
import turtle as t
# 初始化
t.hideturtle()
t.speed(0)
t.pensize(5)
#背景
t.hideturtle()
t.bgcolor('black')
t.pencolor("#ffffff")
for a in range(20):
t.penup()
x = random.randint(-300, 300)
y = random.randint(-300, 300)
s = random.randint(2, 10)
t.goto(x, y)
t.pendown()
t.dot(s)
# 主体
t.up()
t.goto(130,100)
t.color('black','#cccccc')
t.begin_fill()
t.setheading(180)
t.down()
t.forward(300)
t.circle(100,90)
t.circle(50,90)
t.forward(350)
t.circle(30,90)
t.forward(90)
t.circle(30,90)
t.end_fill()
# 窗
t.up()
t.color('#000099','#33ccff')
t.goto(-170,80)
t.begin_fill()
t.down()
t.circle(50,90)
t.setheading(0)
t.forward(50)
t.left(90)
t.forward(50)
t.end_fill()
for a in range(4):
t.penup()
t.setheading(0)
t.forward(60)
t.setheading(180)
t.begin_fill()
t.pendown()
for i in range(4):
t.circle(15,90)
t.forward(20)
t.end_fill()
# 灯
t.color('yellow')
t.up()
t.goto(-230,-5)
t.down()
t.dot(20)
t.up()
t.goto(-210,-20)
t.setheading(0)
for a in range(8):
t.dot(10)
t.forward(50)
# 火
color = ['#ff0000', '#ff0000', '#ff6666', '#ffcc66', '#ffff33']
for a in range(50):
t.up()
x = random.randint(150,280)
y = random.randint(-50,110)
a = random.randint(1,4)
b = random.randint(-90,-45)
t.color(color[a])
t.goto(x, y)
t.pendown()
t.setheading(b)
t.circle(10,360,4)
t.done()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn