I’ve started looking into other ways to use sound in games. Since Blender’s internal sound system is very limited and buggy, and no one is actively developing it. For the game I’m working on now I definately want a good range of sounds included, as well as music!
Pygame seems a good method of achieving this, but I haven’t had the time to play with it yet. Has anyone else got sound and music working in their games through using Pygame? What are it’s pros and cons?
What pygame!? pfff!!! ITs like the next best thing to makeing 2d/3d games in python!!! DUDE www.pygame.org
i dont know how the sound works in Pygame, But i think you could use WinSound module,
An update, I have Pygame installed and music playing in my game! 4 lines of Python is all it takes to play mp3 and ogg files inside the game engine. I’ll finally be able to have some decent sound & music in my games 8)
If you’re not on windows you may require some of the SDL library files as well as Pygame. It’s all pretty well explained on the Pygame site though.
Andy, can I please take a look at these lines?
Add these in a python script and run whenever you want music to play:
Then to stop it you can use one of these methods:
You need python 2.3.x installed as well as pygame 1.6. Note this only works inside Blender. I cannot get it to work with a runtime, but I’m working on it.
I’m also trying to figure out which files are needed so I can include them in a zip with my games. That way people won’t need anything else installed to play. If anyone thinks they could help me out with this I’d appreciate any input you could give
Thanks a lot!
That´s great. I´m still reading Dive into Python… if I find anything useful I´ll let you know.
Have you tried running the blend file with the BlenderPlayer?
Trying to import the pygame modules within the Blenderplayer causes it to crash. This is before anything is output to the console so I’m having trouble finding the cause. It may be a bug in the player itself.
Another issue is file paths. If you open a .blend from inside Blender it will search for the sound files in the Blender installation directory, but if you open a .blend directly it will search for the files in that directory.
I shall continue working on this… I want people who download my games to be able to just click the runtime and everything works. Without the need to install and configure anything else.
Yeah, that´s the way to do it !