Python Forum

Full Version: pygame.init help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
pygame.init() the internet tells me this is initializing a module. What does that mean?
http://pygame.org/docs/tut/ImportInit.html

init initializes all the modules for you in one line instead of doing this in every game. At the same time it initializes the modules in correct order. For example some platforms require mixer to initialize after display, etc.
pygame.font.init()
pygame.display.init()
pygame.mixer.init()
pygame.joystick.init()
pygame.freetype.init()
pygame.midi.init()
pygame.cdrom.init()
pygame.scrap.init()
If you are making just an mp3 player, you dont need a display, so you dont have to initialize every module, you can just do pygame.mixer.init() for example. Or you may need to give specific values
pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=4096)

As for what init actually does you can look at the source

mixer.init
https://bitbucket.org/pygame/pygame/src/...ixer.c-315
Ah I had the same question. Thanks!