博客
关于我
2021年5月11日python的小游戏(5)见缝插针
阅读量:565 次
发布时间:2019-03-09

本文共 1099 字,大约阅读时间需要 3 分钟。

import pgzrunTITLE ='见缝插针'Startneedle = Actor('needle',anchor=(170+50,1.5))Startneedle.x=220 #初始位置的针,保持不动即可,动后面的针Startneedle.y=300needles=[]#绘制多根针存储列表,存储信息rotateSpeed=1score = 0def draw():    screen.fill('white')#白色背景    Startneedle.draw()    for needle in needles: #needle相当于变量x        needle.draw()#画出针     screen.draw.filled_circle((400,300),80,'red')    screen.draw.text(str(score),(50,250),fontsize=50,color='blue')    if rotateSpeed==0:        screen.draw.text("Game Over!",(10,320),fontsize=50,color='red')def on_key_down():    global score,rotateSpeed    if rotateSpeed>0:        music.play_once('弹簧')    Newneedle=Actor('needle',anchor=(170+50,1.5))#新建指针    Newneedle.x=400#原来建的那根针是不动的,动的是后来添入的针    Newneedle.y=300    for needle in needles:        if Newneedle.colliderect(needle):            rotateSpeed=0#停止旋转            music.play_once('溜走')            print('游戏失败')    needles.append(Newneedle)#把针加入列表    if rotateSpeed>0:  #按下键盘后判断,所以不会一直增加        score=score+1def update():    for needle in needles:        if needle.x==400:            needle.angle=needle.angle+rotateSpeedpgzrun.go()

转载地址:http://tmlpz.baihongyu.com/

你可能感兴趣的文章
memset初始化高维数组为-1/0
查看>>
Metasploit CGI网关接口渗透测试实战
查看>>
Metasploit Web服务器渗透测试实战
查看>>
Moment.js常见用法总结
查看>>
MongoDB出现Error parsing command line: unrecognised option ‘--fork‘ 的解决方法
查看>>
MongoDB学习笔记(8)--索引及优化索引
查看>>
ms sql server 2008 sp2更新异常
查看>>
MS UC 2013-0-Prepare Tool
查看>>
msbuild发布web应用程序
查看>>
MSCRM调用外部JS文件
查看>>
MSEdgeDriver (Chromium) 不适用于版本 >= 79.0.313 (Canary)
查看>>
msf
查看>>
MSSQL数据库查询优化(一)
查看>>
MSSQL日期格式转换函数(使用CONVERT)
查看>>
MSTP多生成树协议(第二课)
查看>>
MSTP是什么?有哪些专有名词?
查看>>
Mstsc 远程桌面链接 And 网络映射
查看>>
Myeclipse常用快捷键
查看>>
MyEclipse用(JDBC)连接SQL出现的问题~
查看>>
myeclipse的新建severlet不见解决方法
查看>>