Game Development Reference
In-Depth Information
Chapter 8. Aural Integration
In this chapter, you will learn about adding audio in our game in various ways. Com-
bining the usage of background music, atmospheric sounds, and event-driven sound
effects, you will have a game that feels very much alive. Audio plays a major role in
how players perceive the game world, and can be as important as graphics in setting
the mood of a scene.
In this chapter, you will learn about the following things:
• How to create a random music system
• How to create a playlist-styled music system
• How to integrate and manage atmospheric sounds
• How to create an event-driven sound effects system
Background music
The first part of audio that we will cover will be the background music. Having music in
your background can set the mood of a scene, keep the player entertained on a sub-
conscious level, or even be gameplay mechanics that the player interacts with. We
will create a dynamic system that will allow us to play songs randomly or in a playlist
style.
Creating a random system
The first step in creating our background music system will be to create a new C#
script and name it BG_Music_Manager . Before we start scripting, add the using
statement to the top of the script using the other using statements:
Using System.Collections.Generic;
We will need the using statement so that we can use lists. Next, we will create a few
variables and add these to our script:
Search WWH ::




Custom Search