猫史档案馆


【Python作品分享】U2-创作【作品秀】

用户:月辰K5EF月辰K5EF查看:30 回复:0 评论:0 创建时间:2021-08-12T15:57:56


【作品展示】

center_image

 

【作品介绍】

.。。。

 

【作品源代码】

# 导入库
import turtle,random
# 创建画布
ms = turtle.Screen()
# 画布大小
ms.setup(1200,800)
# 画布背景图片
ms.bgpic('bg.gif')
#关闭动画
ms.tracer(0)
#导入
ms.addshape('box.gif')
ms.addshape('喵.gif')
box_list=[]
喵_list=[]
# 创建
def create(shape):
    p = turtle.Pen()
    p.hideturtle()
    p.shape(shape)
    x=random.randint(-500,500)
    y = random.randint(-300, 300)
    p.penup()
    p.goto(x,y)
    if shape=='box.gif':
        box_list.append(p)
    if shape=='喵.gif':
        喵_list.append(p)
    ms.update()
for i in range(20):
    create('box.gif')
for i in range(5):
    create('喵.gif')
d=turtle.Pen()
d.color('gold')
d.shape('circle')
def move(x,y):
    d.color('gold')
    d.penup()
    d.goto(x,y)
    for box in box_list:
        if d.distance(box.xcor(),box.ycor())<30:
            d.color('green')
            print('find it')
            box.showturtle()
    for 喵 in 喵_list:
        if d.distance(喵.xcor(), 喵.ycor()) < 30:
            d.color('red')
            print('oh on')
            喵.showturtle()
            ms.onclick(None, btn=1)
            print('GAME OVER!!!!!!!!!!!!!!!!!')
    ms.update()
ms.onclick(move,btn=1)
# 固定
turtle.done()

 

【提示】

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

https://python.codemao.cn


回复

上一页第 1 页 / 共 0 页下一页