[ Team LiB ] |
ExercisesExercise 30.1: Changing the sounds of SpacewarFirst of all, get sound working on your computer so that you can hear the Pop Framework sounds. (You need to have a sound card with speakers, and the speakers need to be plugged in. If you double-click the little speaker icon on the upper right of your Windows taskbar, the Mute button needs to not be checked. Also don't forget to see if your speaker has a manual, physical control.) Now try removing the SND_ASYNC from the playSound Now find some other *.wav file and incorporate it into the program. Where to find a *.wav file? First you can use Start | Find to look for them on your hard disk. Second, it's pretty easy to search the web for sites that have *.wav files for download. When picking sounds for effects in a game, avoid long sounds. For instance, once a student wrote a game where every time you shot something the game said 'Hasta la vista, baby,' and although that was funny the first few dozen times, it then got really old. So get the *.wav, put it in the res subdirectory and add it to the resources. Give it a name like, say, 'Newsound.' Now change the code so that when you shoot an asteroid it will make the 'Newsound' sound if the radius is bigger than some value, and it will make a 'Ding' sound if the radius is smaller than some value. What value? Look for some value that separates the big from the small asteroids. Exercise 30.2: Using system soundsSince the Ta-da sound usually lives in Windows\System directory you might get away with not including it as a resource and instead looking for the file externally with a call playSound("Tada.wav", SND_ASYNC). See if this works. Exercise 30.3: Encapsulating the playSound callIt's kind of a drag to have to write that stupid ((CPopApp*)::AfxGetApp())->. all the time. Assuming that it's normally a cCritter |
[ Team LiB ] |
No comments:
Post a Comment