Frightening pygame.time.set_timer?

So, I have a problem, I do not quite understand the event that needs to be provided to the timer team anyway, it does not say anywhere on the Internet where I searched for the clock. So I just used what most people seemed to use "USEREVENT + 1". I am not sure if this is correct, but my timer is not working. Am I using it correctly? Here is my code:

nyansecond=462346
nyanint=0
spin=0
aftin=452345

def nyanmusic(nyansecond,nyanint,spin):
    if nyanint == 0:
        nyansound.play()
        nyanint= 1
    elif nyanint == 1:
        nyansecond = pygame.time.set_timer(USEREVENT+1,7000)
    if nyansecond < 200 and spin == 1:
        spin = 0
        nyansecond = pygame.time.set_timer(USEREVENT+1,7000)
    elif nyansecond > 6500 and nyansecond < 100000 and spin == 0:
        spin = 1
        nyansoundm.play()

    return nyansecond,nyanint,spin

, ( ). nyansound, nyansoundm 6,5 (6500 ). , python pygame, . , nyan cat , youtube . .

, , , , :

#music
        nyansecond,nyanint,spin = nyanmusic(nyansecond,nyanint,spin)
+5
1

, pygame.time.set_timer :

pygame.time.set_timer (eventid, ): return None

, , . , .
, . pygame.USEREVENT pygame.NUMEVENTS.

pygame.USEREVENT pygame.NUMEVENTS (24 32), eventid, pygame.time.set_timer, 24 32.

pygame.USEREVENT+1 - 25, .

pygame.time.set_timer(USEREVENT+1,7000), eventid 25 7000. , , , .

, pygame.time.set_timer None,

nyansecond = pygame.time.set_timer(USEREVENT+1,7000)

, nyansecond None , ,

if nyansecond < 200 ...

.


6,5 , simpy pygame.time.set_timer (!):

PLAYSOUNDEVENT = USEREVENT + 1
...
pygame.time.set_timer(PLAYSOUNDEVENT, 6500)

:

while whatever: # main loop
    ...
    # event handling
    if pygame.event.get(PLAYSOUNDEVENT): # check event queue contains PLAYSOUNDEVENT 
        nyansoundm.play() # play the sound
+8

All Articles