ZFGC

Resources => Coding => Topic started by: Mewgull on June 23, 2007, 09:23:58 pm

Title: Low-Heart Alert
Post 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:
Code: [Select]
if global.Heart<=2.75{
sound_loop(global.lowheart_S)}

Thanks a lot:
Mewgull
Title: Re: Low-Heart Alert
Post by: Pyru on June 23, 2007, 09:29:09 pm
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...
Title: Re: Low-Heart Alert
Post by: Antidote on June 24, 2007, 04:17:18 am
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.
Title: Re: Low-Heart Alert
Post by: Mewgull on June 25, 2007, 11:42:47 am
Bump...
Title: Re: Low-Heart Alert
Post by: MG-Zero on June 25, 2007, 03:44:30 pm
That looks right, try it it should work.
Title: Re: Low-Heart Alert
Post by: Mewgull on June 25, 2007, 04:59:39 pm
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...
Title: Re: Low-Heart Alert
Post by: Windy on June 25, 2007, 05:14:22 pm
change it to sound_play, then add an additional check to see if the sound is playing
Title: Re: Low-Heart Alert
Post by: Mewgull on June 25, 2007, 05:21:28 pm
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.
Title: Re: Low-Heart Alert
Post by: Scooternew on June 25, 2007, 05:44:31 pm
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.
Title: Re: Low-Heart Alert
Post by: Mewgull on June 25, 2007, 06:26:09 pm
what would be the code for that? sorry for asking :\
Title: Re: Low-Heart Alert
Post by: cazallx on June 26, 2007, 12:39:40 pm
like this

Code: [Select]
if (global.heart)<=(global.totalheart div 3){
    if !sound_playing {
        sound_play(global.lowheart_S)
    }
}
Title: Re: Low-Heart Alert
Post by: Mewgull on June 26, 2007, 02:18:45 pm
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 :\
Title: Re: Low-Heart Alert
Post by: cazallx on June 26, 2007, 07:26:07 pm
if you want send me the source and ill fix it.
Title: Re: Low-Heart Alert
Post by: Mewgull on June 26, 2007, 07:47:33 pm
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)
Title: Re: Low-Heart Alert
Post by: Scooternew on June 26, 2007, 07:53:36 pm
Create a variable called "playcount" in your create event, and set it to 0. Then, in the step event, use this code:

Code: [Select]
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).
Title: Re: Low-Heart Alert
Post by: cazallx on June 26, 2007, 08:21:12 pm
my code should work unless your beep is actualy three beeps at once.
goodnight has beeps that loop perfectly on his sound effects page.
Title: Re: Low-Heart Alert
Post by: Mewgull on June 26, 2007, 08:28:56 pm
Thanks a lot! ^_^
This solves the problem so I will lock this topic to reduce further spam

Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved