Quick update on how TRAUMA is coming along. It now loads sounds.
Ok, it kinda was loading sounds before but now it also keeps track of them. Warning! Technical explanation: As you might remember, the game really just loads 4 different kinds of files: XMLs, images, sounds and videos. I already had taken care of XMLs. Today I took care of sounds. As always, each step has it’s own unique challenges. In case of sounds, it was the fact that they are loaded at 3 different places. Each of the 3 places wasn’t even remotely keeping track of them. So I basically wrote the same feature 3 times today.
Flash is really deceptive especially when it comes to sound. It treats each sound file as a stream. So especially when the sound files are stored locally, you can just haphazardly load and play sounds without keeping track of the loading progress whatsoever. Even if the file is only partially loaded, it will start playing just fine. This encourages a very sloppy approach to sound data management which comes back to haunt me now, when I’m moving things to the Web. TRAUMA has 18MB of sound data. It is entirely plausible that some files may simply not load in time, especially when there is other data coming in at the same time.
And of course things get complicated when there are 3 different places where sounds are being loaded. There are what I call “System Sounds” which are general sound effects associated with the interface. Those need to be loaded even before the main menu shows up. But I didn’t want to include them in the game file in order to be able to easily swap out sounds with different quality for different versions. Next, there is background music. It is level-specific and really only needs to load when a certain level requires it. After all, this makes up almost half of the entire sound data in volume. Finally, there are the voice-overs. Again, those are level-specific. Surprisingly, they are only 5MB in total but there are 80 different files. If only one of them fails, the program needs to react accordingly.
As always, it took more time than I thought. But building on the previous work I had already done I was able to implement solid solutions for all 3 cases. As an added benefit, the loading is much more smoother now as the game doesn’t try to load ALL sound files at once anymore. The game loads all the sound files from the web now and the loading time is not noticeable so far. Tomorrow I will be moving to the images and the video files. Not quite sure yet which ones I do first but I’ll let you know soon enough.