猫史档案馆


【Python作品分享】[去太空,趣编程]火箭发射【作品秀】

用户:活泼的重金怪gdte活泼的重金怪gdte查看:0 回复:0 评论:0 创建时间:2021-05-05T18:38:40


【作品展示】

center_image

 

【作品介绍】

倒计时开始,火箭发射。在天空中,火箭徐徐上升。

 

【作品源代码】

import turtle
import random

mypen = turtle.Pen()
mypen.speed(0)
myscreen = turtle.Screen()
myscreen.tracer(0)
myscreen.setup(800, 600)
start = False

class Draw():
    def draw_circle(pos_x, pos_y, radius, pensize, color):
        mypen.pencolor(color)
        mypen.pensize(pensize)
        mypen.penup()
        mypen.goto(pos_x, pos_y)
        mypen.pendown()
        mypen.circle(radius)

    def draw_rectangle(pos_x, pos_y, width, height, pensize, color):
        mypen.pencolor(color)
        mypen.pensize(pensize)
        mypen.penup()
        mypen.goto(pos_x, pos_y)
        mypen.pendown()
        for i in range(2):
            mypen.forward(width)
            mypen.left(90)
            mypen.forward(height)
            mypen.left(90)

    def draw_filled_rectangle(pos_x, pos_y, width, height, pensize, color):
        mypen.pencolor(color)
        mypen.pensize(pensize)
        mypen.penup()
        mypen.goto(pos_x, pos_y)
        mypen.pendown()
        mypen.fillcolor(color)
        mypen.begin_fill()
        for i in range(2):
            mypen.forward(width)
            mypen.left(90)
            mypen.forward(height)
            mypen.left(90)
        mypen.end_fill()

    def draw_filled_circle(pos_x, pos_y, radius, color):
        mypen.pencolor(color)
        mypen.penup()
        mypen.goto(pos_x, pos_y)
        mypen.pendown()
        mypen.dot(radius)

    def write(pos_x, pos_y, writing, color, size):
        mypen.pencolor(color)
        mypen.penup()
        mypen.goto(pos_x, pos_y)
        mypen.pendown()
        mypen.write(writing, font=("文泉驿正黑", size))

    def draw_filled_s_out(lenth):
        mypen.fillcolor("orange")
        mypen.pencolor("orange")
        mypen.begin_fill()
        mypen.right(60)
        mypen.forward(lenth)
        mypen.left(120)
        mypen.forward(lenth)
        mypen.left(120)
        mypen.forward(lenth)
        mypen.right(180)
        mypen.end_fill()

    def draw_star():
        pensize = 1
        mypen.pensize(pensize)
        for i in range(40):
            x = [66, 295, -156, -47, -145, 195, -17, -91, 31, 283, -4, 167, -152, 144, 107, 151, -186, -11, 84, 289, 112, -61, 163, 154, 228, -16, 29, -27, -105, -153, 209, 128, 211, -251, 103, -207, 165, -169, 171, -16]
            y = [169, -141, -271, 257, 207, -118, 129, 8, -206, 15, 13, -76, -222, -265, -48, -175, 98, -167, 173, 143, -93, 90, -喵, 68, 267, 192, 175, 94, -127, -36, 25, -259, 122, -107, -5, 68, -240, 2, -143, -191]
            mypen.penup()
            mypen.goto(x[i],y[i])
            mypen.pendown()
            sizes = [7, 5, 6, 8, 10]
            size = random.choice(sizes)
            mypen.pencolor("gold")
            mypen.begin_fill()
            mypen.fillcolor("gold")
            for j in range(5):
                mypen.forward(size)
                mypen.left(72)
                mypen.forward(size)
                mypen.right(144)
            mypen.end_fill()

    def draw_time(pos_x,w):
        for i in range(20):
            Draw.write(pos_x, -330, w, "blue", 500)
        myscreen.clear()

start = myscreen.textinput("是否发射", '''是否发射,"ok"为"是":''')
if start == "ok":
    Draw.draw_time(-330,10)
    Draw.draw_time(-165,9)
    Draw.draw_time(-165,8)
    Draw.draw_time(-165,7)
    Draw.draw_time(-165,6)
    Draw.draw_time(-165,5)
    Draw.draw_time(-165,4)
    Draw.draw_time(-165,3)
    Draw.draw_time(-165,2)
    Draw.draw_time(-165,1)
    Draw.draw_time(-165,0)
    myscreen.bgcolor("midnightblue")
    myscreen.tracer(0)
    Draw.draw_star()
    for i in range(50):
        Draw.draw_filled_rectangle(-20, -200+i, 40, 230, 5, "red")
        Draw.draw_filled_s_out(40)
        Draw.draw_filled_rectangle(-60, -200+i, 30, 100, 5, "red")
        Draw.draw_filled_s_out(30)
        Draw.draw_filled_circle(-45, -100+i, 35, "red")
        Draw.draw_filled_rectangle(30, -200+i, 30, 100, 5, "red")
        Draw.draw_filled_s_out(30)
        Draw.draw_filled_circle(45, -100+i, 35, "red")
        Draw.draw_filled_rectangle(-20, 30+i, 40, 50, 5, "blue")
        Draw.draw_filled_circle(0, 80+i, 45, "blue")
        Draw.draw_filled_circle(0, 5+i, 25, "skyblue")
        Draw.draw_filled_circle(0, -25+i, 25, "skyblue")
        Draw.write(-12, -185+i, "中\n国\n航\n天", "gold",20)
turtle.done()








#倒计时开始,火箭发射。在天空中,火箭徐徐上升。

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页