猫史档案馆


【Python作品分享】见缝插针【作品秀】

用户:CHZS勇敢的蓝雀kKVoCHZS勇敢的蓝雀kKVo查看:0 回复:0 评论:0 创建时间:2021-06-05T17:46:05


【作品展示】

center_image

 

【作品介绍】

按空格发射

按回车重启

 

【作品源代码】

import pgzrun
import os
zhen = Actor("needle",anchor = (170 +30,1.5))
WIDTH = 900
HEIGHT = 600
zhen.x = 200
zhen.y = 300
zhens = []
os.environ['SDL_VIDEO_CENTERED'] = "1"
su = 1
score = 0

def draw():
    screen.fill("green")
    screen.draw.filled_circle((700,300),80,"blue")
    screen.draw.text(str(score),(20,200),fontsize=50,color='black')
    zhen.draw()
    for z in zhens:    
        z.draw()


def update():
    for z in zhens:
        z.angle += su

def on_key_down(key):
    global score, su,zhens
    if key == keys.SPACE:
        newzhen = Actor("needle",anchor=(170 + 30,1.5))
        newzhen.x = 700
        newzhen.y = 300
        for z in zhens:
            if newzhen.colliderect(z):
                print("游戏失败")
                su = 0
        if su != 0:
        score += 1
        zhens.append(newzhen)
    if key ==keys.RETURN:
        zhens =[]
        score = 0
        su = 1
pgzrun.go()

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页