Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What does it mean when pygame is initialized?

The pygame documentation says that pygame.init() Initializes all pygame modules which need to be initialized. What does it mean to initialize a pygame module in Python.

I understand that pygame.init() ‘starts everything up’ but what is it meant by ‘starts everything up’?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

pygame.init() does indeed initiate all Pygame modules. They don’t come initiated or "started" when you import Pygame because starting every module when you import Pygame can make your code slow. By having to use pygame.init(), your code will only run Pygame modules if you want it to.
You can also start specific modules in Pygame. pygame.mixer.init() for example, only starts the mixer module in Pygame and not everything else.

Note that this is a Pygame feature, and .init() is not for every module in Python. Some Pygame source code is run when you call pygame.init().

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading