用户:
codegou查看:0 回复:1 评论:0 创建时间:2021-05-02T09:24:36
【作品展示】

【作品介绍】
这,是太空,这,是大黄鸡的家,
这,是星球的居住地,
这,是火箭的旅游区,
这,是人梦的彷徨。。。
星辰闪烁,幻想无限……
【作品源代码】
import time
import turtle
import random
star_Pen = turtle.Pen()
star_Pen.speed(0)
star_Pen.hideturtle()
moonpen = turtle.Pen()
moonpen.speed(0)
moonpen.hideturtle()
# #渲染星空
turtle.bgcolor('black')
def darws():
# #星星函数
def stars(x,y,l):
star_Pen.pensize(1.5)
star_Pen.color('white')
star_Pen.fillcolor('yellow')
star_Pen.penup()
star_Pen.goto(x, y)
star_Pen.pendown()
star_Pen.begin_fill()
for i in range(5):
star_Pen.forward(l)
star_Pen.right(144)
star_Pen.end_fill()
#尘埃
cipen=turtle.Pen()
cipen.speed(0)
cipen.hideturtle()
for i in range(int(random.uniform(150, 200))):
cipen.pencolor("brown")
cipen.penup()
cipen.pensize(int(random.uniform(1,4)))
cipen.goto(int(random.uniform(-600, 600)),int(random.uniform(400, -400)))
cipen.pendown()
cipen.forward(1)
# 绘制星星
for i in range(int(random.uniform(30, 60))):
star_Pen.left(int(random.uniform((-360), 360)))
l = int(random.uniform(10, 50))
y = int(random.uniform(350, 150))
x = int(random.uniform(-1250, 1000))
stars(x, y, l)
#大黄鸡
t = turtle.Pen()
t.speed(0)
t.hideturtle()
def dhj():
def head():
t.penup()
t.goto(0, (-100))
t.pendown()
t.begin_fill()
t.fillcolor('gold')
t.circle(100)
t.end_fill()
t.penup()
def glasses():
# 左镜框
t.penup()
t.goto(20, 50)
t.pencolor('brown')
t.pensize(10)
t.setheading(0)
t.pendown()
t.fillcolor('skyblue')
t.begin_fill()
t.forward(60)
t.circle(8, 90)
t.forward(30)
t.circle(8, 90)
t.forward(60)
t.circle(8, 90)
t.forward(30)
t.circle(8, 90)
t.end_fill()
# 右镜框
t.penup()
t.goto((-20), 50)
t.setheading(180)
t.pendown()
t.begin_fill()
t.forward(60)
t.circle((-8), 90)
t.forward(30)
t.circle((-8), 90)
t.forward(60)
t.circle((-8), 90)
t.forward(30)
t.circle((-8), 90)
t.end_fill()
# 眼镜连接
t.penup()
t.goto((-6), 70)
t.setheading(0)
t.pensize(20)
t.pendown()
t.forward(13)
# 左镜片光泽
t.penup()
t.goto(50, 65)
t.setheading(45)
t.pensize(8)
t.pencolor('white')
t.pendown()
t.forward(25)
t.penup()
t.goto(70, 65)
t.pendown()
t.forward(12)
# 右镜片光泽
t.penup()
t.goto((-50), 65)
t.setheading(45)
t.pensize(8)
t.pencolor('white')
t.pendown()
t.forward(25)
t.penup()
t.goto((-30), 65)
t.pendown()
t.forward(12)
def face():
# 右眼睛
t.pencolor('black')
t.pensize(5)
t.penup()
t.goto(55, 15)
t.pendown()
t.setheading(110)
t.circle(20, 140)
t.penup()
# 左眼睛
t.goto((-55), 15)
t.pendown()
t.setheading(70)
t.circle((-20), 140)
t.penup()
# 嘴巴(外)
t.goto((-15), (-10))
t.pensize(1)
t.pencolor('coral')
t.fillcolor('coral')
t.setheading((-90))
t.pendown()
t.begin_fill()
t.circle(15, 180)
for i in range(10):
t.forward(3)
t.left(7)
t.left(20)
t.backward(2)
t.left(20)
for i in range(10):
t.forward(3)
t.left(7)
t.end_fill()
# 嘴巴(里)
t.penup()
t.goto(12, (-10))
t.setheading(120)
t.pencolor('darkred')
t.fillcolor('darkred')
t.begin_fill()
t.circle(14, 120)
t.setheading((-60))
t.circle(14, 120)
t.end_fill()
def hands():
# 左手
t.penup()
t.goto(100, 0)
t.pensize(1)
t.pencolor('black')
t.setheading((-10))
t.pendown()
t.fillcolor('gold')
t.begin_fill()
for i in range(7):
t.forward(9)
t.right(6)
for i in range(19):
t.forward(1)
t.right(6)
for i in range(7):
t.forward(9)
t.right(5)
t.end_fill()
# 右手
t.penup()
t.goto((-100), 0)
t.setheading(190)
t.pendown()
t.fillcolor('gold')
t.begin_fill()
for i in range(7):
t.forward(9)
t.left(6)
for i in range(19):
t.forward(1)
t.left(6)
for i in range(7):
t.forward(9)
t.left(5)
t.end_fill()
def hat():
# 蓝色部分
t.penup()
t.goto(50, 96)
t.pencolor('deepskyblue')
t.fillcolor('deepskyblue')
t.pensize(1)
t.pendown()
t.begin_fill()
t.setheading(90)
t.circle(10, 90)
t.forward(10)
t.setheading(90)
t.forward(10)
t.circle(5, 90)
t.forward(50)
t.circle(5, 90)
t.forward(10)
t.setheading(180)
t.forward(10)
t.circle(10, 90)
t.setheading(0)
t.forward(100)
t.end_fill()
# 棕色部分
t.penup()
t.goto(20, 122)
t.pencolor('brown')
t.fillcolor('brown')
t.setheading(90)
t.pendown()
t.begin_fill()
t.forward(15)
t.circle(5, 90)
t.forward(30)
t.circle(5, 90)
t.forward(15)
t.end_fill()
def engines(size=20):
def engine(x, y):
t.pensize(1)
t.setheading(0)
# 外圆位置
t.penup()
t.goto(x, y)
t.pendown()
# 画外圆
t.color("black", "yellow")
t.begin_fill()
t.circle(-size)
t.end_fill()
# 内圆位置
t.penup()
t.goto(x, y - 4)
t.pendown()
# 画内圆
t.setheading(0)
t.color("black", "brown")
t.begin_fill()
t.circle(-size + 4)
t.end_fill()
# 左引擎
engine(-100, -40)
engine(-130, -40)
# 右引擎
engine(100, -40)
engine(130, -40)
def draw():
head()
face()
hat()
glasses()
hands()
engines()
draw()
dhj()
#月球
#moonpen = turtle.Pen()
#moonpen.speed(0)
#moonpen.hideturtle()
moonpen.pensize(5)
moonpen.color("silver")
moonpen.fillcolor("gray")
moonpen.up()
moonpen.goto(650,-550)
moonpen.down()
moonpen.begin_fill()
moonpen.circle(200)
moonpen.end_fill()
moonpen.up()
moonpen.goto(530,-240)
moonpen.down()
moonpen.setheading(45)
moonpen.pensize(8)
moonpen.pencolor('white')
moonpen.forward(50)
moonpen.up()
moonpen.goto(530, -300)
moonpen.pendown()
moonpen.forward(125)
# # 火箭
image = "火箭.gif" # 要插入的图片
huojian = turtle.Pen()
screen = turtle.Screen()
screen.addshape(image)
huojian.up()
huojian.goto(-500,-100)
huojian.down()
huojian.shape(image)
darws()
time.sleep(5)
def say():
b = "航天,又称空间飞行、太空飞行、宇宙航行或航天飞行 \n是指进入、探索、开发和利用太空(即地球大气层以外的宇宙空间,又称外层空间)以及地球以外天体各种活动的总称."
print(b)
time.sleep(3)
c = "再说嫦娥五号\n嫦娥五号月球探测器简称嫦娥五号,是负责嫦娥三期工程“采样返回”任务的中国首颗地月采样往返探测器。也是“绕,落,回”中的第三步。嫦娥五号由轨道器、返回器、着陆器、上升器等多个部分组成\n由于体积庞大,故将使用中国新一代的重型运载火箭-长征五号发射。"
print(c)
a = turtle.textinput('对话框', '是否进行对航天的科普?(是输入1)')
if a == "1":
say()
time.sleep(5)
print("作品完成,感谢观看")
else:
print("作品完成,感谢观看")
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn