猫史档案馆


【Python作品分享】庆祝建党一百周年【去太空,趣编程】【作品秀】

用户:ReijiReiji查看:0 回复:0 评论:0 创建时间:2021-05-01T19:24:49


【作品展示】

center_image

 

【作品介绍】

火箭喵,庆祝建党一百周年

 

【作品源代码】

import turtle
import random
import time
print("温馨提醒:请勿隐藏或遮挡终端,终端随时有惊喜")
print("温馨提醒:请勿改变窗口大小,以免影响效果")
t = turtle.Pen()
t1 = turtle.Pen()
x = turtle.Pen()
b = turtle.Pen()
c = turtle.Pen()
c.speed(0)
c.hideturtle()
b.speed(0)
b.hideturtle()
x.speed(0)
x.hideturtle()
t.hideturtle()
t1.hideturtle()
turtle.bgcolor("#000099")
co = ['white', 'red', 'green', 'orange', 'skyblue', 'yellow', 'blue']
def w(l):
    x.pencolor(co[5])
    x.fillcolor(co[3])
    x.begin_fill()
    for i in range(5):
        x.forward(l)
        x.left(144)
    x.end_fill()
for i in range(random.randint(20, 30)):
    x.penup()
    x.goto(random.randint((-300), 300), random.randint((-300), 300))
    x.pendown()
    w(random.randint(5, 10))
print('让我们用火箭飞向太空!')
def s():
    t.penup()
    t.goto((-50), (-50))
    t.pendown()
    t.pencolor('yellow')
    t.fillcolor('yellow')
    t.begin_fill()
    for i in range(4):
        t.forward(100)
        t.left(90)
    t.end_fill()
    t.penup()
    t.goto((-25), 50)
    t.pendown()
    t.pencolor('green')
    t.fillcolor('green')
    t.begin_fill()
    for i in range(2):
        t.forward(50)
        t.left(90)
        t.forward(100)
        t.left(90)
    t.end_fill()
    t.penup()
    t.goto((-50), 150)
    t.pendown()
    t.pencolor('yellow')
    t.fillcolor('yellow')
    t.begin_fill()
    for i in range(2):
        t.forward(100)
        t.left(90)
        t.forward(80)
        t.left(90)
    t.end_fill()
    t.penup()
    t.goto((-50), 230)
    t.pendown()
    t.pencolor('red')
    t.fillcolor('red')
    t.begin_fill()
    for i in range(3):
        t.forward(100)
        t.left(120)
    t.end_fill()
def r(num, l):
    for i in range(2):
        num.forward(l)
        num.right(120)
def r1(num, l):
    for i in range(2):
        num.forward(l)
        num.left(120)
def fire(num, y, color):
    num.penup()
    num.goto((-50), (-50 + y))
    num.pendown()
    num.pencolor(color)
    num.fillcolor(color)
    if (color == 'yellow'):
        num.right(60)
        r1(num, 20)
        num.setheading(0)
    else:
        num.begin_fill()
        r(num, 20)
        num.setheading(0)
        num.end_fill()
    num.penup()
    num.goto((-30), (-50 + y))
    num.pendown()
    if (color == 'yellow'):
        num.right(60)
        r1(num, 60)
        num.setheading(0)
    else:
        num.begin_fill()
        r(num, 60)
        num.setheading(0)
        num.end_fill()
    num.penup()
    num.goto(30, (-50 + y))
    num.pendown()
    if (color == 'yellow'):
        num.right(60)
        r1(num, 20)
        num.setheading(0)
    else:
        num.begin_fill()
        r(num, 20)
        num.setheading(0)
        num.end_fill()
t.speed(0)
s()
b.pensize(2)
c.pensize(5)
fire(b, (-2), 'red')
for i in range(5):
    fire(c, (-7), 'yellow')
    time.sleep(0.15)
    c.clear()
    time.sleep(0.15)
t.speed(0)
c.clear()
b.clear()

t.penup()
t.goto(-350, 0)
t.pendown()
time.sleep(0.5)
t.clear()
string = "热烈庆祝祖国建党一百周年,喵党万岁!"
for i in range(len(string)):
    t.pencolor(co[random.randint(0, 5)])
    t.write(string[i], font=('Arial', 30, 'bold'))
    t.forward(37)
print('登陆月球!')
print(string)
for i in range(random.randint(3, 6)):
    t.penup()
    t1.penup()
    t.goto(random.randint((-300), 300), random.randint(120, 300))
    t1.goto(random.randint((-300), 300), random.randint(120, 300))
    t.pendown()
    t1.pendown()
    ran = random.randint(5, 10)
    t.speed(5)
    t1.speed(5)
    for i in range(ran):
        t.dot(((ran - i) * 10), co[random.randint(0, 6)])
        t1.dot(((ran - i) * 10), co[random.randint(0, 6)])
    t.speed(0)
    t1.speed(0)
    for i in range((ran + 1)):
        t.dot((i * 10), "#000099")
        t1.dot((i * 10), "#000099")
turtle.done()

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页