I Wanna Community
Fangames => Game Design => Programming Questions => Topic started by: bananaguy12 on August 05, 2015, 02:58:43 PM
-
In games like 'kill the needle games 2' or 'kamilia 3' :denKamilia_v2: I noticed there is a separate folder where all the bgm is stored, and the bgm is not stored in the gamemaker file. Somehow the game pulls the music from the folder or something. I was wondering how do I do this? Thanks.
-
Either external .ogg loaders (FMOD, SuperSound) or sound_add();
-
This method only works for GM8/8.1:
bgm = sound_add(working_directory+"\BGM\song.mp3",3,0);
if(!sound_isplaying(bgm)){
sound_loop(bgm);
}
Obviously change the first line to match your folder name + song name, but if it's inside the folder where the game is you should be set. Might need a little tweaking to get it to work with your specific sound engine though.
-
Note that if you're doing sound_add, you should only do this once in your game, say at game start (and it will take time, so you should only load one song per step, otherwise the game will look like it's freezing). This is what's happening during that loading bar at the beginning of K3 - it's adding one sound, then ticking the loading bar, adding another sound, ticking the loading bar, until it's done.
Never load sounds elsewhere! If, for example, you tried to load the sound on room start in the room you want to play the music in, it's going to create a new copy of the sound every time you load that room! You'll notice the slow restart time, and it probably wouldn't take long for the game to crash from memory errors due to the memory being full of the songs you loaded. (Note that this advice doesn't apply to you if you're advanced enough to understand the tradeoffs and always release any allocated memory)
tl;dr only use sound_add at the start of your game, never anywhere else
-
Yeah I really should have clarified a lot of that when I wrote my response, thank you Klazen :~)
-
no problem, just want to save everyone the pain I've had to go through :Kappa:
-
no problem, just want to save everyone the pain I've had to go through :Kappa:
Are there any benefits to using the sound folder outside of gm. Because in my last game i just put all the music in the .exe.
-
Players can replace the music with something else, or choose to not load it at all to lower startup time (like K3 does with FMOD)
Also keeps your .exe file much smaller and (probably?) makes it easier to switch out music during development.
-
In my experience if you set it up right (as Klazen was suggesting), the game does run noticeably faster, in the sense that it doesn't lag when loading the music.
Also on a purely aesthetic side note, it make me feel special when I see my game has folders within the game folder. It feels like a proper product to me for some reason.
-
no problem, just want to save everyone the pain I've had to go through :Kappa:
Are there any benefits to using the sound folder outside of gm. Because in my last game i just put all the music in the .exe.
The biggest benefit to loading music externally is memory management. If you intend to make a very large game and you don't manage your memory usage, you're going to run into a lot of problems. GameMaker by default will load everything you put in the GMK into the memory when starting the game. If the memory overloads this can cause bugs, missing music or sounds, surfaces or particles not loading properly and more.