This is a free wrapper for the default PyGame event wrapper, with a range of functions allowing for a more streamlined use of the event system. It minimizes overdrawing - where other parts of the code take out events that are needed to be acted upon by another system. It instead uses function-based code calling on event entering.
All the code is in event_manager.py
.
Look at the wiki for more advanced usage of event_manager.
- Copy the code from
event_manager.py
into your PyGame game - Call
name_of_var = events_sync()
- Use the
listen
function to provide actions to be performed on certain events e.g. For a keyboard down event with a specific key you would use:name_of_var.listen(pygame.KEYDOWN, name_of_function, pygame.K_a)
or using key remapping:name_of_var.config('up', pygame.K_w)
then,name_of_var.listen(pygame.KEYDOWN, name_of_function, 'up')
. - Instead for a basic function you can just use:
name_of_var.listen(pygame.QUIT, name_of_function, None, var_passed_into-name_of_function)
- Call
name_of_var()
in the update loop of your game to run all the events through it