time - 如何添加 1 秒延迟?
问题描述
嘿,我正在制作这个游戏,我需要 1 秒或更多的延迟?有什么想法吗?
这里我需要在 tx3 = 1000 和 cheesyx = 1000 之间延迟。
if x < 300 and y < 300 and not duringfight:
win.blit(cheesyt3, (tx3, ty3))
if x < 250 and y < 250 and not duringfight:
tx3 = 1000
cheesyx = 1000
if cheesyx == 1000:
deathx -= 5
if deathx == 600:
deathx += 5
deathmove = False
wmx = 1000
win.blit(deathtext, (dtext, 400))
if x > 400:
dtext = 1000
win.blit(deathhanpup, (deathx, deathy))
deathy = 1000
解决方案
游戏时间
在 pygame 中,time.sleep(1)
效果不好,所以你可以这样做pygame.time.delay(1)
,效果很好。
链接:https ://www.pygame.org/docs/ref/time.html#pygame.time.delay 。
推荐阅读
- css - Angular 样式不适用于表单
- c++ - 堆上的一个元素是否有一些 STL“容器”?
- mongodb - 如何从MongoDB管道中的对象数组中获取特定字段
- javascript - 无法从 MongoDB Atlas 触发器中的集合中读取数据
- php - 如何将点分隔文本转换为数组?
- proxy - 如何让两个 Telethon 客户端各自使用不同的 IP
- java - 我究竟做错了什么?我需要 Springboot 不要求在特定 url 登录
- google-people-api - 传递日期对象时,人员 API 未创建生日
- python - django中的数据库设计和规范化
- c# - Nethereum Wallet.GetAccount() 给出 EntryPointNotFound 异常