用户:
小黄黄特工13查看:0 回复:0 评论:0 创建时间:2022-08-21T14:43:45
【作品展示】

【作品介绍】
快来对接天宫呀!!!
【作品源代码】
from turtle import*
import turtle as t
import random
import turtle
list_shuoming = ["欢迎来到天宫,快来用机械臂对接天宫吧!!!",
"用wasd控制机械臂移动,注意不要碰到白色太空垃圾!!!"] # 用列表的形式来储存汉字
text = turtle.Turtle()
text.hideturtle()
text.pu()
text.goto(-300, 0)
text.pd()
text.write(list_shuoming[0], font=("黑体", 20, "normal"))
text.pu()
for i in range(3):
text.circle(25)
text.clear()
text.pd()
text.write(list_shuoming[1], font=("黑体", 20, "normal"))
text.pu()
for i in range(3):
text.circle(25)
text.clear()
t.color("white")
turtle.bgcolor("black")
t.delay(0)
for d in range(75):
u = random.randint(-300, 300)
r = random.randint(-300, 300)
q = random.randint(2, 10)
t.pu()
t.goto(u, r)
t.pd()
t.fillcolor("white")
t.begin_fill()
t.circle(q)
t.end_fill()
pen = turtle.Turtle()
screensize(300, 300) # 设置画布大小
list_color = ["red", "blue", "yellow"]
pen.pensize(3)
pen.color("white")
pen.speed(0)
def juxing(color, a, b):
pen.fillcolor(color)
pen.begin_fill()
pen.setheading(0)
pen.fd(a)
pen.setheading(90)
pen.fd(b)
pen.setheading(180)
pen.fd(a)
pen.setheading(270)
pen.fd(b)
pen.end_fill()
def pengoto(x, y):
pen.pu()
pen.goto(x, y)
pen.pd()
pengoto(-200, -25)
juxing(list_color[0], 100, 50)
pengoto(-160, 25)
pen.setheading(90)
pen.fd(20)
pengoto(-160, -25)
pen.setheading(270)
pen.fd(20)
pengoto(-173, 45)
juxing(list_color[1], 26, 50)
pengoto(-173, -95)
juxing(list_color[1], 26, 50)
pengoto(200, -25)
juxing(list_color[0], 100, 50)
pengoto(250, 25)
pen.setheading(90)
pen.fd(20)
pengoto(250, -25)
pen.setheading(270)
pen.fd(20)
pengoto(237, 45)
juxing(list_color[1], 26, 50)
pengoto(237, -95)
juxing(list_color[1], 26, 50)
pengoto(-200, 25)
pen.fillcolor(list_color[2])
pen.begin_fill()
pen.setheading(180)
pen.circle(25, 180)
pen.end_fill()
def yuan(a):
pengoto(-80, a)
pen.fillcolor(list_color[0])
pen.begin_fill()
pen.setheading(90)
pen.circle(10)
pen.end_fill()
yuan(25)
yuan(0)
yuan(-25)
pengoto(200, -25)
pen.fillcolor(list_color[2])
pen.begin_fill()
pen.setheading(180)
pen.fd(45)
pen.setheading(0)
pen.circle(25, 180)
pen.setheading(0)
pen.fd(45)
pen.end_fill()
pen.hideturtle()
color(list_color[1])
pu()
goto(-70, 25)
pd()
shape("turtle")
pensize(5)
def up():
setheading(90)
fd(10)
def down():
setheading(270)
fd(10)
def left():
setheading(180)
fd(10)
def right():
setheading(0)
fd(10)
onkey(up, "w")
onkey(down, "s")
onkey(left, "a")
onkey(right, "d")
listen()
mainloop()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn