1
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

It's my code to change to fever_mode for 5sec if you reach at specific score so I made some timers EX) pygame.time.get_ticks() and pygame.time.set_timer() but These stuff doesn't work for me. How can I do to solve it..

Rabbid76
  • 202,892
  • 27
  • 131
  • 174

1 Answers1

0

The time argument of pygame.time.set_timer must be specified in milliseconds and not in seconds (5000 milliseconds = 5 seconds):

pygame.time.set_timer(pygame.USEREVENT, 5)

pygame.time.set_timer(pygame.USEREVENT, 5000)  

Minimal example: blinking object

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()

See also Spawning multiple instances of the same object concurrently in python.

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
  • @JPKO No. Please read the documentation. The first argument is not a function it is the event ID. You get the `pygame.USEREVENT` event in the event loop. – Rabbid76 Oct 15 '21 at 20:42