Sid, in BGT you can use either one. You can use a standard forward slash or two backslashes to make a break between directories and files.
The point I wanted to raise is that its more common in programming to use a single forward slash rather than two backslashes for a couple of reasons. One its less typing, and other operating systems such as Mac OS or Linux will not accept a double backslash in a program and give you a file or folder not found error. So its just better practice to adopt a forward slash instead of double backslashes.
Understand using two backslashes is not wrong, especially on Windows, but you have to type a backslash, the standard escape character for programming, followed by a second backslash for the directory break. My thinking here is why do that when you can simplify it by using a single forward slash?
You can use either one in BGT as its more a matter of personal preference rather than being right or wrong. However, as I've been programming for roughly 12 years now I've found using a forward slash rather than the Microsoft Windows double backslashes more universal and less typing. Its also what professionals tend to call code safe, because you are less likely to make a mistake. Here is an example of what I mean.
Let's say you have to access a file several directories down like
Data\\Sounds\\Player\\Jump.wav
which has a total of six backslashes in that string. If you should miss even one backslash you will get a runtime error when you run your game. If you had used a forward slash like
Data/Sounds/Player/Jump.wav
you not only used three slashes instead of six backslashes, but you have less chance of making a mistake. Which is why I personally recommend not using backslashes.
mike, in order to add more sounds and music to the game all you have to do is declare more sound objects and initialize them. For example, below I will declare and initialize five sounds.
sound g_sound1;
sound g_sound2;
sound g_sound 3;
sound g_sound 4;
sound g_sound5;
void main ()
{
// Load the sounds
g_sound1.load ("Boom.wav");
g_sound2.load ("gun.wav");
g_sound3.load ("player.wav");
g_sound4.load ("enemy.wav");
sound5.load ("music.wav");
}
Basically, the entire point of object oriented programming is to be able to create as many objects as you need, in this case sounds, by calling the class name and creating a specific instance, an object, that represents the thing you need. In the program above I named the objects g_sound1 through g_sound5 but I could have given them specific names like g_boom, g_gun, g_player, g_enemy, and g_music so it would be less confusing as to which sound I'm referencing in my program. In fact, get into the habit of giving your objects good names because as your programs grow an object called s is going to be very obscure and hard to read when you have a game that is 20,000 lines long and contains a couple hundred objects and variables in use at any given time.
Plus in case you are wondering why I add a g_ before the object names that is a holdover from C and C++ programming to help the developer identify global variables from local variables. Local variables, temp variables inside the body of your function, are only temporary and just called boom, music, gun, etc, but a lot of professionals, myself included, append a g_ to global variables to help immediately identify that this program or script is calling a global variable and not a local/temp variable. Its certainly a case of personal preference, not mandatory, but just one of those things I've found extremely helpful in working with huge programs with thousands of lines of code with hundreds of objects and variables etc.
Sincerely,
Thomas Ward
USA Games Interactive
http://www.usagamesinteractive.com