I think choose() does not operate with strings.
Reducing file size
Started by sonosublime, Mar 17 2012 02:48 AM
26 replies to this topic
#21
Posted 24 March 2012 - 02:02 PM
#22
Posted 24 March 2012 - 06:44 PM
So would you recommend something like this?
var choice snd1='sound_effects/OOT_AdultLink_Jump1.wav' snd2='sound_effects/OOT_AdultLink_Jump2.wav' choice=choose(snd1, snd2) sound_add(choice, 1, 0)
#23
Posted 25 March 2012 - 10:11 AM
Still same thing.
var ID,list; list[0]="SFX/blah"; list[1]="SFX/blah2"; ID=choose(0,1); sound_add(list[ID],1,0);
#24
Posted 25 March 2012 - 07:01 PM
Since IMP and TheUlt posted here I feel obligated.
1. Build a shrink ray
2. Aim it at your filesize
3. Win
But in all seriousness there are some good suggestions here, the more efficient you can learn to make a small game, the better it will be later. Case and point, SBX is HORRIBLY inefficient. But it's not too big so it works out. But yeah I have sprites and objects for EVERYTHING. I learned how to be a little more efficient over the past year
; JD uses much more scaling and rotations to solve easy adjustments and color blending etc will be used as well to avoid more sprites than necessary.
1. Build a shrink ray
2. Aim it at your filesize
3. Win
But in all seriousness there are some good suggestions here, the more efficient you can learn to make a small game, the better it will be later. Case and point, SBX is HORRIBLY inefficient. But it's not too big so it works out. But yeah I have sprites and objects for EVERYTHING. I learned how to be a little more efficient over the past year
#25
Posted 26 March 2012 - 07:06 AM
var choice
choice=choose('sound_effects/OOT_AdultLink_Jump1.wav', 'sound_effects/OOT_AdultLink_Jump2.wav')
sound_add(choice, 1, 0)
Just for the future reference, you got the error because you didn't finish the declaration of var at the previous line.var choice; // <-- A semicolon is required here!Since var can take multiple variables, Game Maker will keep looking for variable names until it finds a semicolon. It will read the code as if you write (complementing missing commas for you):
var choice, choice, =, choose, ...And complains that "=" can't be used there. When you omit semicolons, Game Maker makes an effort to figure out where each statement actually ends, but mind that it will fail in some occasions.
By the way, you also need to store the return value of sound_add so you can actually play it later on.
sound = sound_add(choice, 1, 0); ... sound_play(sound);And don't forget to delete the sound when it is no longer used. Otherwise, if you simply replace sound_play with that code, it will end up in creating a new sound resource every time you play a sound, taking up more and more memory. I think you'd better load both of sounds at the beginning of the game, then choose one whenever you play a sound.
// Game start
for (i = 1; i <= 2; i += 1) {
jump_sound[i] = sound_add("sound_effects\OOT_AdultLink_Jump" + string(i) + ".wav", 1, 0);
}// To play the sound sound_play(jump_sound[irandom_range(1, 2)]);
Edited by torigara, 26 March 2012 - 12:22 PM.
#26
Posted 26 March 2012 - 08:11 PM
One thing to note here, is that just because you are externally loading things, it doesn't really make the game size smaller in general. An exception would be if you load jpg(or other higher compressed graphics) because GM stores in a similar to PNG format. The difference is that you don't have to have the longer loading time with GM's load bar, but then you still have to spend the time loading things in anyway. But, you can show your first room, do it with animations at the same time, whatever, so you can get advantages there. Also, you can load things by "levels" where you unload things from one level before loading things from another, so it isn't all in running memory at once. But regardless, if your game has 25MB of graphics, it will still have them even if you load them externally, so don't forget that.
Also, MIDIs are usually very small, but remember that you sacrifice quality because they don't sound the exact same on all computers. On the other hand, if you don't really care about that, it is probably the most efficient way to store and use music.
WAVs are general bigger files, but much of the time, they don't have to be. You can use a program like Audacity to shrink them, by making them mono instead of stereo, lowering the sampling speed(Mhz I think), and GM will save the files the same as you put them in I think.
Last thing, whatever you externally load, make sure you do it before the things are needed. If you try to load a sound each time you are doing to play it(even if you delete it each time) you are wasting CPU, badly. Just load it once into a global variable, and then play it from there. So you'd load all the needed sounds into variables, and then you can use the "choose" function on those variables instead of strings, and save CPU at the same time.
Also, MIDIs are usually very small, but remember that you sacrifice quality because they don't sound the exact same on all computers. On the other hand, if you don't really care about that, it is probably the most efficient way to store and use music.
WAVs are general bigger files, but much of the time, they don't have to be. You can use a program like Audacity to shrink them, by making them mono instead of stereo, lowering the sampling speed(Mhz I think), and GM will save the files the same as you put them in I think.
Last thing, whatever you externally load, make sure you do it before the things are needed. If you try to load a sound each time you are doing to play it(even if you delete it each time) you are wasting CPU, badly. Just load it once into a global variable, and then play it from there. So you'd load all the needed sounds into variables, and then you can use the "choose" function on those variables instead of strings, and save CPU at the same time.
#27
Posted 28 March 2012 - 04:03 AM
Thank you all for your help, it is VERY much appreciated.
I just spent a long time replacing all my sound_play() codes with:
snd=sound_add()
sound_play()
But from what I'm hearing, that is going to cause severe problems? What I should do instead is externally load everything at the game start?
I just spent a long time replacing all my sound_play() codes with:
snd=sound_add()
sound_play()
But from what I'm hearing, that is going to cause severe problems? What I should do instead is externally load everything at the game start?
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











