Tham khảo tài liệu 'beginning game programming (phần 5)', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 180 Chapter 8 Advanced Sprite Programming On Your Own The following exercises will help to challenge your grasp of the information presented in this chapter. Exercise 1. The Trans_Sprite program animates a running cat on the screen. Modify the program so that it uses a new background of your own design and change the animation rate of the cat sprite. Exercise 2. The Tiled_Sprite program features a running caveman. Modify the caveman s movement rate and animation rate so that he runs really fast Sound and music are vital parts of any game they help to really make the game feel more immersive and can add an enormous amount of emotion to a game. There is just a completely different reaction to any type of game when it features dynamic powerful sound effects and appropriate background music. This chapter will show you how to use DirectSound to audibly enhance a game and give it some mood. 181 182 Chapter 9 Jamming with DirectX Audio Here is what you will learn in this chapter How to initialize DirectSound. How to load a wave file. How to play a static sound with mixing. How to play a looping sound with mixing. Using DirectSound DirectSound is the DirectX component that handles all sound output for your game and features a multi-channel sound mixer. Basically you just tell DirectSound to play a sound and it takes care of all the details including combining that sound with any currently playing sounds . The code required to create initialize load and play a wave file using Direct-Sound is even more involved than the bitmap and sprite code you learned about in the last several chapters. For this reason and in the interest of re-inventing the wheel I will show you how to use Microsoft s own wrapper for DirectSound. Using a wrapper is generally against my own instincts as a programmer as I prefer to know everything about the code I m using and often prefer to write my own rather than use someone else s code. However there comes a time when in the interest of time you have .