Python Forum
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pygame.init help
#1
pygame.init() the internet tells me this is initializing a module. What does that mean?
Reply
#2
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
Recommended Tutorials:
Reply
#3
Ah I had the same question. Thanks!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pygame why init() & not __init__()? ryfoa6 1 1,800 Apr-17-2020, 04:47 AM
Last Post: buran
  pygame.mixer.init() devicename issue wanhr 2 4,729 Sep-15-2019, 09:08 AM
Last Post: wanhr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020