我正在为flappy bird做一个克隆,但是当我想让翅膀拍打时,它们会疯狂地快速拍打,所以有没有办法让它们在换下一张之前在一张图片上停顿几秒钟?这是我的密码
first=1
if first==1:
playern=1
comeback=False
first=2
if obspeed==1 and playern==1:
imagefile="player1"
player=pygame.image.load(imagefile+".png")
screen.blit(player, [x, int(y)])
y+=3
playern=2
pygame.display.update()
if obspeed==1 and playern==2 and comeback==False:
imagefile="player"
player=pygame.image.load(imagefile+".png")
screen.blit(player, [x, int(y)])
y-=2
playern=3
pygame.display.update()
if obspeed==1 and playern==3:
imagefile="player3"
player=pygame.image.load(imagefile+".png")
screen.blit(player, [x, int(y)])
y-=3
playern=2
comeback=True
pygame.display.update()
if obspeed==1 and playern==2 and comeback==True:
imagefile="player"
player=pygame.image.load(imagefile+".png")
screen.blit(player, [x, int(y)])
y+=2
playern=1
comeback=False
pygame.display.update()
if obspeed==0:
imagefile="player2"
player=pygame.image.load(imagefile+".png")
screen.blit(player, [x, int(y)])`
您应该这样设置帧速率限制:
然后在主循环的最后,输入:
你也不需要打电话pygame.displayupdate文件()在每个条件语句中,您知道游戏循环每秒执行60次,如果您将限制设置为60,那么它的速度足以更新循环中发生的所有事情。你知道吗
我建议您阅读以下内容: http://inventwithpython.com/pygame/chapters/
那本在线书很好地解释了如何使用pygame 我希望这能帮助你:)
相关问题 更多 >
编程相关推荐