• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Text with sound

E

EleMenTyh

Guest
hi guys i need the help
I'm trying to make a voice text like undertale but I couldn't
can someone help me?

{
counter++;
if(counter mod 4 == 0)
audio_play_sound(voice, 10, false);
}
draw_text((x1+x2) /2, y1+8 , _print);
draw_set_color(c_white);
draw_text((x1+x2) /2, y1+7 , _print);

I did this but the sound doesn't stop when the text ends
 

Tony Brice

Member
I don't get why you're using mod here? That's basically just checking if the variable counter will divide into 4, and will then play the sound.

Or am I misunderstanding this?
 
E

EleMenTyh

Guest
Do you have any other ideas that are compatible with the audio file I have?
 

Nidoking

Member
Whatever you do to make the sound go, don't do that to make the sound stop. Or, if you're setting some condition, set not that condition.

The problem is not in what you've posted here, but in what you haven't posted here. As such, that's the best advice you're going to get, aside from the usual helpful souls who will just write your game for you.
 

FrostyCat

Redemption Seeker
Your code basically plays a sound once every 4 steps. That's great for a typewriter sound effect, but not great for a voice effect. And there's NOTHING in your code here that stops the cycle once it has started. When comes to code, if it isn't written down, it won't be done.

Please, DO NOT copy-and-paste code out of context without first understanding what it really does.
 

FrostyCat

Redemption Seeker
So can you help?
Not until you make a conscious effort to understand your own code.

You have been told by 3 different responders that your code just plays a sound once every 4 steps, and there is nothing in what you've shown that stops it. Nidoking even told you that the solution will come from other parts of your code. You said you want the sound to stop when "the text ends", but there is no clue from what you've shown thus far what expression would mean "the text ends" in your setup. Like I said, when it comes to code, what isn't said will never be done.

Now, it's your turn to read your own code. Look at what you have, and think over what expression would mean "the text ends" in your setup. Then take that and substitute it for expression in the following fragment:
GML:
if (++counter mod 4 == 0 && expression) {
    audio_play_sound(voice, 10, false);
}
Topics like this demonstrate why people shouldn't go head-first into a clone of Undertale just because they like Undertale. They have to work up their basics the same way the authors of Undertale did long before working on Undertale.
 
Top