Re: How to Handle Sounds in BGT

TJ.Breitenfeldt wrote:

1. What is Preloading sounds  mean? I have seen this on the forms a couple times, as well as in the documentation, but I am not sure if I fully get the purpose, and the application for this.

Creating a sound class doesn't need alot of time, since this just creates a class in memory, but calling the load() method of a sound object accesses the hard drive, if not even needs to decrypt an encrypted sound file, and that is, compared to other operations, extremely time consuming.
Playing a FPS and having to load sounds within the game might, if the amount of sounds is rather high and the device the game is running on is rather slow, result in getting killed, since your game will stuck while the sounds slip into their place, without you being able to react onto your enemy's movements. That's why people usually preload the sounds, meaning they create the classes and load all files into memory before the actual game starts (e.g. right at the startup of the game). In this case you can use existing objects when in game without the need of loading them from hard drive when playing actively.

TJ.Breitenfeldt wrote:

2. Is there a good way to load sounds without using global variables? I am a computer science major, and in all of my classes thus far have encourage avoiding using global variables because it is bad design?

That's a question you should be able to answer yourself, since it's one of the most common global variable avoidance strategies. Just create a class which does all the sound storing for you, create an object of that class in a function you like, and handle all this stuff there. Or create a singleton class which contains a handle to itself and return it by a simple function/method call or such stuff.
You're right, global variables are bad code nowadays, not just in multithreaded environments. That's why you are right, you should avoid them where possible, but it's not forbidden to use them, so if you think it's okay to use them, just do so. But it's better to use as less globals as possible, that means having one object as global variable is nicer than having 200 sounds with each sound as another global variable.

TJ.Breitenfeldt wrote:

3. What is the listener and source? In the play methods, the documentation talks about listener and source  positions, but it doesn't exactly explain anywhere I saw what these mean. I am guessing listener means the person playing the game, but I don't know about source.

That's rather simple. The listener usually is the player, while the sounds are positioned somewhere around the listener. Just imagine that to be in your room. The listener is you, while you might have a door (a source) to your far left, and a window (another source) to your far right. You define some coordinates (x y) for those two sources. When you move, you now just need to move yourself (the listener), since the door and the window are statics (they don't move), and the sounds will change anyway. If you move e.g. right, the door left will get more quiet (it's now very far left), while the window is quite loud and is now directly right from you. That simplifies sound positioning, because the engine will do all the sound positioning for you and the only thing you have to do is move the listener (yourself) and not all the possible tens or hunderets of sources around you to achieve a more or less realistic audio environment.

Best Regards.
Hijacker

_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : TJ . Breitenfeldt via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : TJ . Breitenfeldt via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : TJ . Breitenfeldt via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : TJ . Breitenfeldt via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector

Reply via email to