ZFGC
Resources => Coding => Topic started by: Mewgull on June 23, 2007, 09:23:58 pm
-
Hey
I feel like an idiot asking this question, but how would I make a sound loop when the hearts are low, on Goodnight's Oot heart engine?
I think I might have the solution but I don't know if it's right, and it may consistantly play the sound, so here it is:
if global.Heart<=2.75{
sound_loop(global.lowheart_S)}
Thanks a lot:
Mewgull
-
Surely you could add a second bit of code that if global.Heart>2.75, you could end the loop? I dunno, I'm none too good at coding...
-
the thing is when it plays changes depending on the amount of Heart containers you have. so you'll have to add that variable too.
-
Bump...
-
That looks right, try it it should work.
-
if I put it in the step event, it will make an annoying sound playing the sound constantly for every step of frames.
But I'll try anyways ;)
EDIT: Just as I suspected... didn't work...
-
change it to sound_play, then add an additional check to see if the sound is playing
-
Thanks.
But what would I have to put to do the check? DX
I am just a little stressed right now, so I can't think properly, sorry.
-
I think it's something like if the hearts are less than 1/3 of the total, then the sound plays. So maybe check if the heart number is less than the total div 3 or just divided by 3.
-
what would be the code for that? sorry for asking :\
-
like this
if (global.heart)<=(global.totalheart div 3){
if !sound_playing {
sound_play(global.lowheart_S)
}
}
-
I had to make a few modification to that code, but thanks for it! :)
I always forget about that little "!" XD
EDIT: It's playing three of the sounds at a time, now :\
-
if you want send me the source and ill fix it.
-
I won't send my file that I am actually making my game in, but I will send the engine I used for the hearts.
The code doesn't work there either.
Give me a sec, and I'll upload it in the edit of this post.
EDIT:
Here ya go :):
http://www.freewebs.com/mewgull/OOT%20Heart%20Engine%20v3.gmk (http://www.freewebs.com/mewgull/OOT%20Heart%20Engine%20v3.gmk)
-
Create a variable called "playcount" in your create event, and set it to 0. Then, in the step event, use this code:
if (global.hearts)<=(global.totalhearts div 3){
playcount = (playcount + 1) mod 30;
if(playcount == 0) {
sound_play(Low);
}
} else {
playcount = 0;
}
It plays it once a second (with a room speed of 30).
-
my code should work unless your beep is actualy three beeps at once.
goodnight has beeps that loop perfectly on his sound effects page.
-
Thanks a lot! ^_^
This solves the problem so I will lock this topic to reduce further spam