i = 1 ## fever_interval = 3
if score > i * 100:
pygame.time.set_timer(pygame.USEREVENT, 5)
mino = randint(1, 1)
next_mino = randint(1, 1)
next_fever = (i + fever_interval) * fever_score # 피버모드 점수 표시
# fever time
if blink:
screen.blit(pygame.transform.scale(ui_variables.fever_image,
(int(SCREEN_WIDTH * 0.5), int(SCREEN_HEIGHT * 0.2))),
(SCREEN_WIDTH * 0.1, SCREEN_HEIGHT * 0.1))
blink = False
else:
blink = True
i += fever_interval
这是我要更改的代码fever_mode
如果您达到特定分数,则持续 5 秒
所以我做了一些计时器 EX)pygame.time.get_ticks()
and pygame.time.set_timer()
但这些东西对我不起作用。
我该怎么办才能解决..
The time的论证pygame.time.set_timer必须以毫秒为单位指定,而不是以秒为单位(5000 毫秒 = 5 秒):
pygame.time.set_timer(pygame.USEREVENT, 5)
pygame.time.set_timer(pygame.USEREVENT, 5000)
最简单的例子:闪烁的物体
import pygame
pygame.init()
window = pygame.display.set_mode((200, 200))
pygame.time.set_timer(pygame.USEREVENT, 500)
blink = True
run = True
clock = pygame.time.Clock()
while run:
clock.tick(60)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
elif event.type == pygame.USEREVENT:
blink = not blink
window.fill(0)
if blink:
pygame.draw.circle(window, (255, 0, 0), (100, 100), 80)
pygame.display.flip()
pygame.quit()
exit()
也可以看看在Python中同时生成同一对象的多个实例.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)