Game Development Reference
In-Depth Information
m_pView->m_pProcessManager->Attach(sfx1);
sfx1->SetNext(sfx2);
sfx2->SetNext(sfx3);
Other Technical Hurdles
There are a few more wires to connect, in code and in your brain, before you ' re ready
to install a working sound system in your game. Most sounds are tied directly to
game objects or events. Even music is tied to the intensity of the game or, even bet-
ter, the impending intensity of the game! Tying sounds to game objects and synchro-
nization are critical problems in any game sound system. If you have multiple effects
at one time, you
'
ll also have to worry about mixing issues.
Sounds and Game Objects
Imagine the following game situation: A wacky machine in a lab is active and makes
some kind of wub-wub-wub sound tied to an animation. Your hero, armed with his
favorite plasma grenade, tosses one over to the machine and stands back to watch the
fun. The grenade explodes, taking the wacky machine and the
wub-wub-wub
noise
'
with it. What
s really going on in the background?
Your game has some grand data structure of game actors, one of which is the doomed
machine. When the grenade goes off, there
slikelyabitofcodeorscriptthatsearches
the local area for actors that can be damaged. Each actor in the blast radius will get
some damage, and the code that applies damage will notice the machine is a gonner.
What happens next is a core technical problem in computer games: When the
machine is destroyed, related game actors or systems should be notified. This can
include things like sound effects or animation processes. Most games solve this with
the trigger/event system, and this is no exception.
For purposes of clarity, the audio system code presented in this chapter has no such
hook, but the event system you read about in Chapter 11,
'
Game Event Manage-
ment,
ll see how these two sys-
tems are tied together in Chapter 21, A Game of Teapot Wars.
is exactly what is needed to solve this problem. You
'
Timing and Synchronization
Imagine the following problem: You have a great explosion graphics effect that has a
secondary and tertiary explosion after the initial blast. How could you synchronize
the graphics to each explosion? The pacing of the sound is pretty much constant, so
the graphics effect should monitor the progress of the sound and react accordingly.
We can use the Process class to make this work:
 
 
 
 
Search WWH ::




Custom Search