基本信息
源码名称:飞船飞飞飞(入门级示例源码)
源码大小:0.69M
文件格式:.zip
开发语言:Python
更新时间:2021-08-04
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 3 元×
微信扫码支付:3 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
这是一个新的python游戏,我是新手,请多多指教!Thanks♪(・ω・)ノ
规则:点击“空格键”让飞船飞起来~
如果没有安装pgzrero的同志,请看下面的网址进行下载哦~~~:
pgzero下载教程:https://blog.csdn.net/fengbohello/article/details/114993234
import pgzrun import random WIDTH = 600 HEIGHT = 450 bg = Actor('背景.png') rock = Actor('石块.png') zy = Actor('壮猿.png', [80, 100]) over = Actor('游戏失败.png') pList = [] n = 150 for i in range(0, 4): m = random.randint(380, 550) p = Actor('柱子.png', [n, m]) pList.append(p) n = 150 state = '运行' def draw(): if state == '运行': bg.draw() rock.draw() zy.draw() for p in pList: p.draw() elif state == '失败': over.draw() screen.draw.text(str(score), center = [320, 40],fontsize = 60) score = 0 step = 2 def update(): global state global score global step if state == '运行': if zy.colliderect(rock): state = '失败' for p in pList: if zy.colliderect(p): state = '失败' for p in pList: p.x -= step if p.x <= 0: p.x = 600 p.y = random.randint(380, 550) score = 1 if score % 4 == 0: step = 0.5 zy.y = 2 if keyboard.K_SPACE == True: zy.y -= 5 pgzrun.go()