G
Gary Alexander Stott
Guest
Hey guys,
I'm making a Pong game and I'm trying to get my music to change as the score of the game changes. There are six tracks in total, one for scores of 0,1,2,3,4 & 5 respectively. When the game starts at 0-0, the score 0 music should play, with the music changing to score 1 when one or more players scores 1. If a player catches up, for example, going from 3-2 to 3-3, then the score 3 music wouldn't need to change. It could just keep on playing. As soon as a number is reached for the first time, the song corresponding to that score should start looping. That's the idea, and here's how I'm trying to achieve it:
if (global.paddle1_score = 1) or (global.paddle2_score = 1) and !audio_is_playing(snd_1v)
{
audio_stop_sound(snd_0v);
audio_play_sound(snd_1v,0,1);
}
if (global.paddle1_score = 2) or (global.paddle2_score = 2) and !audio_is_playing(snd_2v)
{
audio_stop_sound(snd_1v);
audio_play_sound(snd_2v,0,1);
}
if (global.paddle1_score = 3) or (global.paddle2_score = 3) and !audio_is_playing(snd_3v)
{
audio_stop_sound(snd_2v);
audio_play_sound(snd_3v,0,1);
}
if (global.paddle1_score = 4) or (global.paddle2_score = 4) and !audio_is_playing(snd_4v)
{
audio_stop_sound(snd_3v);
audio_play_sound(snd_4v,0,1);
}
if (global.paddle1_score = 5) or (global.paddle2_score = 5) and !audio_is_playing(snd_5v)
{
audio_stop_sound(snd_4v);
audio_play_sound(snd_5v,0,1);
}
Problem is, I keep getting glitchy audio, like it's turning off and on every frame. I've tried expressing this a bunch of different ways in code, any suggestions?
Thank you.
I'm making a Pong game and I'm trying to get my music to change as the score of the game changes. There are six tracks in total, one for scores of 0,1,2,3,4 & 5 respectively. When the game starts at 0-0, the score 0 music should play, with the music changing to score 1 when one or more players scores 1. If a player catches up, for example, going from 3-2 to 3-3, then the score 3 music wouldn't need to change. It could just keep on playing. As soon as a number is reached for the first time, the song corresponding to that score should start looping. That's the idea, and here's how I'm trying to achieve it:
if (global.paddle1_score = 1) or (global.paddle2_score = 1) and !audio_is_playing(snd_1v)
{
audio_stop_sound(snd_0v);
audio_play_sound(snd_1v,0,1);
}
if (global.paddle1_score = 2) or (global.paddle2_score = 2) and !audio_is_playing(snd_2v)
{
audio_stop_sound(snd_1v);
audio_play_sound(snd_2v,0,1);
}
if (global.paddle1_score = 3) or (global.paddle2_score = 3) and !audio_is_playing(snd_3v)
{
audio_stop_sound(snd_2v);
audio_play_sound(snd_3v,0,1);
}
if (global.paddle1_score = 4) or (global.paddle2_score = 4) and !audio_is_playing(snd_4v)
{
audio_stop_sound(snd_3v);
audio_play_sound(snd_4v,0,1);
}
if (global.paddle1_score = 5) or (global.paddle2_score = 5) and !audio_is_playing(snd_5v)
{
audio_stop_sound(snd_4v);
audio_play_sound(snd_5v,0,1);
}
Problem is, I keep getting glitchy audio, like it's turning off and on every frame. I've tried expressing this a bunch of different ways in code, any suggestions?
Thank you.