猫史档案馆


【Python作品分享】【去太空,趣编程】

用户:Jim_shooterJim_shooter查看:0 回复:0 评论:0 创建时间:2021-04-30T21:52:36


【作品展示】

center_image

 

【作品介绍】

中国航天,一飞冲天!

中国航天,冲向云巅!

中国航天,世界领先!

 

【作品源代码】

import turtle as t
import random

t.bgcolor("black")

t.speed(0)

#星星
t.fillcolor("gold")
t.color('gold')
star_x, star_y = 0, 0
for i in range(50):
    t.penup()
    t.goto(random.randint(-300, 300), random.randint(-300, 300))
    t.setheading(random.randint(0, 180))
    t.down()   
    t.begin_fill()
    for i in range(5):
        t.forward(10)
        t.left(72)
        t.forward(10)
        t.right(144)

    t.end_fill()

#火箭顶端
t.setheading(0)
t.fillcolor("yellow")
t.color('yellow')
t.penup()
t.goto(0, 300)
t.down()
t.begin_fill()
t.right(60)
t.forward(80)
for i in range(2):
    t.right(120)
    t.forward(80)
t.end_fill()

#火箭第二层(载人+窗户)
t.setheading(0)
t.fillcolor("dodger blue")
t.color('dodger blue')
t.penup()
t.goto(-25, 230)
t.down()
t.begin_fill()
for i in range(2):
    t.forward(50)
    t.right(90)
    t.forward(130)
    t.right(90)
t.end_fill()

t.pencolor("white")
t.penup()
t.goto(0, 230 - 65)
t.pensize(3)
t.down()
t.circle(10)

#火箭第三层(主推进器)
t.setheading(0)
t.pensize(1)

t.fillcolor("blue")
t.color('blue')
t.penup()
t.goto(-40, 100)
t.down()
t.begin_fill()
t.forward(80)
t.right(90)
t.forward(200)
t.right(90)
t.forward(80)
t.right(90)
t.forward(200)
t.right(90)
t.end_fill()

#副推进器
t.setheading(0)
t.fillcolor("sky blue")
t.color('sky blue')
p = 1
for i in range(2):
    t.penup()
    if p == 1:
        t.goto(-100, 10)
        p += 1
    else:
        t.goto(40, 10)
    t.down()
    t.begin_fill()
    for i in range(2):
        t.forward(60)
        t.right(90)
        t.forward(110)
        t.right(90)
    t.end_fill()

#火焰
t.setheading(0)
t.fillcolor("orange")
t.color('orange')
x, y = 0, 0
w = 1
for i in range(3):
    t.setheading(0)
    t.penup()
    if w == 1 or w == 3:
        if w == 1:
            x, y = -100, -105
            w += 1
        if w == 3:
            x, y = 40, -105

        t.goto(x, y)
        t.down()
        t.begin_fill()
        t.forward(60)
        t.right(100)
        for i in range(2):
            t.forward(150)
            t.right(158)


        t.end_fill()

    else:
        x, y = -42, -105
        w += 1
        t.goto(x, y)
        t.down()
        t.begin_fill()
        t.forward(80)
        t.right(100)
        for i in range(2):
            t.forward(200)
            t.right(158)

        t.end_fill()

#写字
t.penup()
t.goto(-20, 70)
t.pendown()
t.write("中", align='center', font=('fangzheng', 20))
t.penup()
t.goto(-20, 45)
t.pendown()
t.write("国", align='center', font=('fangzheng', 20))
t.penup()
t.goto(-20, 20)
t.pendown()
t.write("载", align='center', font=('fangzheng', 20))
t.penup()
t.goto(-20, -5)
t.pendown()
t.write("人", align='center', font=('fangzheng', 20))
t.penup()
t.goto(-20, -30)
t.pendown()
t.write("航", align='center', font=('fangzheng', 20))
t.penup()
t.goto(-20, -55)
t.pendown()
t.write("天", align='center', font=('fangzheng', 20))


t.hideturtle()
t.done()

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页