猫史档案馆


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

用户:科技攀岩者科技攀岩者查看:0 回复:1 评论:0 创建时间:2021-05-05T22:18:28


【作品展示】

center_image

 

【作品介绍】

送给祖国的画

 

【作品源代码】

import turtle

plane_pen = turtle.Pen()# 画飞机的画笔
Sun_pen = turtle.Pen()
interface_pen = turtle.Pen()# 画界面的画笔
myscreen = turtle.Screen()# 界面工具
sense_pen = turtle.Pen()# 侦测的画笔
sense_pen.hideturtle()
returned_value = False
turtle.bgcolor('black')

def sense(x,y):
    global returned_value
    sense_pen.goto(x, y)
    if sense_pen.xcor() > -71 and sense_pen.xcor() < 75:
        if sense_pen.ycor() > -70 and sense_pen.ycor() < -21:
            returned_value = True
            plane_pen.speed(0)
            interface_pen.clear()
            plane_pen.pencolor('red')
            plane_pen.fillcolor('red')
            plane_pen.right(180)
            plane_pen.begin_fill()
            plane_pen.circle(30, steps=3)
            plane_pen.end_fill()
            plane_pen.setheading((-90))
            plane_pen.forward(45)
            plane_pen.setheading(0)
            plane_pen.forward(25)
            plane_pen.setheading((-90))
            plane_pen.pencolor('black')
            plane_pen.fillcolor('white')
            plane_pen.begin_fill()
            for __count in range(2):
                plane_pen.forward(200)
                plane_pen.right(90)
                plane_pen.forward(50)
                plane_pen.right(90)
            plane_pen.end_fill()
            plane_pen.forward(100)
            plane_pen.setheading(0)
            plane_pen.penup()
            plane_pen.forward(25)
            plane_pen.pendown()
            plane_pen.pencolor('red')
            plane_pen.fillcolor('red')
            plane_pen.right(180)
            plane_pen.begin_fill()
            plane_pen.circle(30, steps=3)
            plane_pen.end_fill()
            plane_pen.setheading((-90))
            plane_pen.forward(45)
            plane_pen.setheading(0)
            plane_pen.forward(25)
            plane_pen.setheading((-90))
            plane_pen.pencolor('black')
            plane_pen.fillcolor('white')
            plane_pen.begin_fill()
            for __count in range(2):
                plane_pen.forward(100)
                plane_pen.right(90)
                plane_pen.forward(50)
                plane_pen.right(90)
            plane_pen.end_fill()
            plane_pen.penup()
            plane_pen.goto(24.999999999999932, (-145))
            plane_pen.pendown()
            plane_pen.setheading(180)
            plane_pen.penup()
            plane_pen.forward(75)
            plane_pen.pendown()
            plane_pen.pencolor('red')
            plane_pen.fillcolor('red')
            plane_pen.begin_fill()
            plane_pen.circle(30, steps=3)
            plane_pen.end_fill()
            plane_pen.setheading((-90))
            plane_pen.forward(45)
            plane_pen.setheading(0)
            plane_pen.forward(25)
            plane_pen.setheading((-90))
            plane_pen.pencolor('black')
            plane_pen.fillcolor('white')
            plane_pen.begin_fill()
            for __count in range(2):
                plane_pen.forward(100)
                plane_pen.right(90)
                plane_pen.forward(50)
                plane_pen.right(90)
            plane_pen.end_fill()
            Sun_pen.goto(-100,100)
            Sun_pen.pencolor("yellow")
            Sun_pen.dot(30)
        else:
            returned_value = False
    else:
        returned_value = False


plane_pen.penup()
interface_pen.penup()
interface_pen.pencolor('white')
interface_pen.goto((-160), 100)
interface_pen.write("送给祖国的一幅画", font=("文泉驿正黑", 50))
interface_pen.goto(-105, 30)
interface_pen.write("————一名小学生", font=("文泉驿正黑", 30))
interface_pen.goto(-50, -50)
interface_pen.pensize(50)
interface_pen.pendown()
interface_pen.forward(100)
interface_pen.penup()
interface_pen.goto(-65, -65)
interface_pen.pencolor('black')
interface_pen.write(" 开始 ", font=("文泉驿正黑", 30))
myscreen.onclick(sense)

    
turtle.done()

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
无题_无题_

很有创意,加上了初始界面以及鼠标点击效果。
但是绘制完成后,鼠标继续随意点击,会出现异常图像,可以自己检查发现问题。

点赞0


评论