Accessing Wave Sounds


You learned in the previous hour that wave sounds are stored in files with a .WAV file extension. So, if you record a wave using Sound Recorder or some other sound utility, the end result will be a file with a .WAV file extension. Hopefully by now you've already recorded a few sounds or maybe found a few on the Internet. Either way, you understand that a wave sound is stored in a file on disk, kind of like how bitmap images are stored. Similar to bitmaps, it's possible to load a wave directly from a file in a game. However, this isn't the most advantageous way to use waves in games .

If you recall from earlier in the book, I showed you how to include bitmaps as resources in your games. In fact, every program example you've seen thus far that uses bitmaps, such as the Henway game in Hour 12, has included them as resources that are stored directly in the executable program file. Waves are also resources, and can therefore be included in the resource script of a program and compiled into the executable program file. Playing the wave sound is slightly different depending on whether the wave is stored in a file or placed directly within the program as a resource. It's ultimately up to you how you want to access waves, but organizationally I think it's much better to use them as resources so that you don't have to worry about distributing separate wave files with your games.



Sams Teach Yourself Game Programming in 24 Hours
Sams Teach Yourself Game Programming in 24 Hours
ISBN: 067232461X
EAN: 2147483647
Year: 2002
Pages: 271

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net