This question arose out of the need to create a lot of USEREVENT type events. Since I could not find information on how to create more userevents than the limit allows I came to ask here for help.
Currently I know that the USEREVENT type event has a value of 24 and the maximum allowed id is 31. I also found that some id-s are reserved, at least in one of the comments in the official documentation (http://www.pygame.org/docs/ref/event.html#comment_pygame_event_Event).
Based on all that here is my two-parted question: can those SDL_EVENT_RESERVED event id-s be safely used as extra spaces for user-created events (for example, a timer: pygame.time.set_timer(USEREVENT + 7, 1000)) and is there a way to create an unlimited amount of separate user-created events like in the example piece of timer code?
I am sorry if the question is not understandable because of bad wording or due to other issues.
User events should be between:
pygame.USEREVENT
: 24pygame.NUMEVENTS
: 32So you can have 9 different user events.
The usual way is to define a constant:
SOME_EVENT = pygame.USEREVENT + 0
ANOTHER_EVENT = pygame.USEREVENT + 1
...
If you create your event with event(...)
you can assign attributes to the event, that way you can create many different sub-events and assign additional data to them, e.g.: key events.
Unfortunately when you use pygame.time.set_timer()
you are stuck with only an ID.