猫史档案馆


【Python作品分享】【去太空,趣编程】飞向太空·喵党成立一百周年

用户:申浩南申浩南查看:0 回复:1 评论:0 创建时间:2021-05-05T20:20:04


【作品展示】

center_image

 

【作品介绍】

这个作品描述的是中国宇航员在喵党成立一百周年时,飞向太空,成功登上小行星,并将小行星命名为“CN-01”

 

【作品源代码】

# 网页端运行不了

from turtle import*
from random import*
window = Screen()
setup(width=500, height=700)
shape('circle')

# 定义颜色
red = (255, 0, 0)
black = (0, 0, 0)
white = (255, 255, 255)
whiteblue = (197, 201, 237)
grayyellow = (1喵, 166, 143)
yellow = (251, 255, 0)
lightblue = (0, 230, 255)
purple = (94, 0, 255)
darkblue = (2, 10, 77)
blackblue = (6, 8, 33)

# 定义简写
def fd(a):
    forward(a)
def c(a):
    colormode(255)
    pencolor(a)

# 定义特殊形状
def star(s):
    fd(s)
    right(144)
    fd(s)
    right(144)
    fd(s)
    right(144)
    fd(s)
    right(144)
    fd(s)


colormode(255)
bgcolor(blackblue)
c(white)
pensize(5)
speed(15)
for i in range(50):
    up()
    x = randint(-250, 250)
    y = randint(-350, 350)
    goto(x, y)
    down()
    fd(1)
speed(11)
for i in range(10):
    x = randint(-250, 250)
    y = randint(-350, 350)
    size = randint(10, 50)
    up()
    goto(x, y)
    fillcolor(randint(0, 255), randint(0, 255), randint(0, 255))
    down()
    begin_fill()
    circle(size)
    end_fill()
    up()
up()

#小行星表面
pensize(2)
goto(0, -600)
fillcolor(grayyellow)
begin_fill()
circle(250)
end_fill()
up()

#火箭
goto(-100, -100)
c(white)
fillcolor(whiteblue)
down()
begin_fill()
goto(-100, 200)
setheading(90)
#火箭圆弧
for i in range(30):
    right(6)
    fd(10.5)
goto(100, -100)
goto(-100, -100)
end_fill()
up()
goto(-100, 200)
down()
fillcolor(red)
begin_fill()
goto(100, 200)
goto(100, 50)
goto(-100, 50)
goto(-100, 200)
end_fill()
goto(0, 200)
goto(0, 50)
# 大五角星
up()
goto(-70, 190)
down()
fillcolor(yellow)
c(yellow)
begin_fill()
star(27)
end_fill()
# 小五角星
up()
setheading(0)
fd(20)
right(90)
fd(30)
down()
fillcolor(yellow)
c(yellow)
begin_fill()
star(12)
end_fill()
up()
setheading(-90)
fd(15)
right(90)
fd(12)
down()
fillcolor(yellow)
c(yellow)
begin_fill()
star(12)
end_fill()
up()
setheading(180)
fd(15)
down()
fillcolor(yellow)
c(yellow)
begin_fill()
star(12)
end_fill()
up()
setheading(180)
fd(19)
right(90)
fd(7)
down()
fillcolor(yellow)
c(yellow)
begin_fill()
star(12)
end_fill()
up()
goto(15, 170)
down()
begin_fill()
setheading(55)
fd(26)
setheading(0)
fd(6)
setheading(-125)
fd(11)
setheading(-45)
fd(18)
setheading(20)
for i in range(18):
    fd(2)
    left(9)
setheading(-10)
for i in range(24):
    fd(2)
    right(5.5+i*0.13)
setheading(-45)
fd(5)
right(90)
fd(4)
right(90)
fd(4)
setheading(-160)
for i in range(10):
    fd(2)
    right(5.5+i*0.13)
circle(4)
setheading(-130)
for i in range(2):
    fd(2)
    right(5.5+i*0.13)
setheading(20)
fd(5)
setheading(155)
for i in range(7):
    fd(-2)
    left(15)
setheading(135)
fd(13)
setheading(-140)
fd(13)
goto(15, 170)
end_fill()
up()
#火箭文字
goto(-80, 0)
write('100th', font=('华文琥珀', 40, 'italic'))
goto(-100, -40)
write('中国·喵党', font=('华文琥珀', 25, 'normal'))
goto(-100, -85)
write('Communist Party of China', font=('华文琥珀', 13, 'normal'))
goto(-18, 260)
down()
pensize(5)
c(white)
fillcolor(lightblue)
begin_fill()
circle(30)
end_fill()
up()
#火箭尾部
goto(-100, 50)
setheading(-150)
down()
fillcolor(purple)
begin_fill()
for i in range(11):
    fd(10)
    left(5.5+i*0.13)
goto(-155, -200)
goto(-100, -100)
end_fill()
up()
goto(100, 50)
down()
setheading(-30)
begin_fill()
for i in range(11):
    fd(10)
    right(5.5+i*0.13)
goto(155, -200)
goto(100, -100)
end_fill()
c(white)
pensize(5)
up()
goto(0, 300)
down()

goto(0, 320)
goto(-10, 330)
fillcolor(lightblue)
begin_fill()
circle(10)
end_fill()
up()
goto(100, -100)
pensize(2)
c('black')
fillcolor('white')
down()
begin_fill()
circle(50)
end_fill()
up()

fillcolor(darkblue)
down()
begin_fill()
circle(40)
end_fill()
up()
setheading(0)
fd(22)
setheading(90)
fd(8)
down()
color(white)
pensize(6)
setheading(65)
for i in range(40):
    fd(2)
    right(5)
up()
for i in range(7):
    fd(2)
    right(5)
down()
for i in range(5):
    fd(2)
    right(5)
up()
setheading(-130)
fd(30)
c(black)
fillcolor(white)
down()
pensize(2)
begin_fill()
fd(25)
setheading(-95)
fd(80)
setheading(0)
fd(100)
setheading(95)
fd(80)
setheading(130)
fd(23)
setheading(-140)
for i in range(37):
    fd(2)
    right(3)
end_fill()
up()
setheading(0)
fd(62)
setheading(-90)
fd(110)
down()
begin_fill()
fd(100)
right(90)
fd(40)
right(90)
fd(10)
right(90)
fd(10)
left(90)
fd(10)
right(90)
fd(10)
left(90)
fd(77)
right(90)
fd(20)
end_fill()
up()
setheading(90)
fd(3)
setheading(-180)
fd(50)
down()
setheading(-90)
begin_fill()
fd(100)
right(90)
fd(40)
right(90)
fd(10)
right(90)
fd(10)
left(90)
fd(10)
right(90)
fd(10)
left(90)
fd(77)
right(90)
fd(20)
end_fill()
up()
setheading(90)
fd(90)
left(90)
fd(13)
down()
setheading(155)
begin_fill()
fd(90)
left(90)
fd(20)
left(90)
fd(90)
left(90)
fd(20)
end_fill()
up()
setheading(0)
fd(70)
setheading(20)
down()
begin_fill()
fd(90)
right(90)
fd(20)
right(90)
fd(90)
right(90)
fd(20)
end_fill()
up()
setheading(-175)
fd(370)
down()
setheading(90)
c(purple)
fd(150)
begin_fill()
right(90)
fd(50)
right(90)
fd(25)
right(90)
fd(50)
right(90)
fd(25)
end_fill()
c(black)
back(25)
write('CN-01', font=('华文琥珀', 14, 'normal'))
up()
setheading(-90)
fd(200)
setheading(180)
fd(45)
c(red)
write('庆祝中国', font=('方正舒体', 28, 'bold'))
setheading(0)
fd(150)
write('喵', font=('方正舒体', 28, 'bold'))
fd(68)
write('党建立100周年!', font=('方正舒体', 28, 'bold'))  # 此处词汇被编程猫屏蔽,故拆分。
setheading(-90)
fd(50)
setheading(-180)
fd(160)
write('1921.7.23~2021.7.23', font=('方正舒体', 28, 'bold'))
hideturtle()
done()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
申浩南申浩南

由于上一帖有词汇被屏蔽,所以重发

 

点赞0


评论