Thursday, June 18, 2009

Breakout (XNA) - Update 6: Adding Sound

I finished my 3D tutorial which was really cool. I'm starting to think that the move from 2D to 3D won't be too bad. My 3D modeling skills with Blender still aren't the greatest, but maybe they'll come along. Hopefully I'll run into someone with artistic ability before that though, since mine is certainly a long way away.

Anyway, other than being cool, the 3D tutorial taught me how to use sound with XNA Game Studio. It's really quite simple... at least for the basics. Just open up the Cross-Platform Audio Creation Tool (using the correct version), start a new project and save it in the audio content folder of your XNA project, create a new sound and wave bank, add .wav files to the wave bank, and then just copy and drag them to the sound bank. Then you just basically load them into your XNA project much like you would image files. Simple as that. If you want to know how to load sound, but don't care for the 3D aspect of game programming yet, just check out the sound section of the 3D tutorial.

I've also made a few other small improvements to how the game works. I added separate screens for the title screen, pause screen and game over screen. I also had to create class that inherits the EventArgs class so I could pass arguments (which was necessary so the game knew whether the pause button 'P' was pressed or the game was over). That took a while to figure out, but a decent example can be found in here in the MSDN Library.

Other than that, I've come across another problem. When the ball hits the top, it kind of just doesn't come back down. I think I need to find a better way to work the collision detection... actually I know I do. Maybe I'll look into that in the next little while.

Oh, and sorry the sound is kind of dull. At least it's a sound that works.

No comments:

Post a Comment