Windows Change music with score

Sawyer

Member
Hello everyone,

I am creating a little game, in this game your score can increase or decrease.
I am trying to play some song in function of your score.

For exemple you start at score = 0
decrease the gain of the old music (this is only is your score decrease or at the start)
play the new sound but slowly increase his gain

If score = 300
decrease the gain of the old music
play the new sound but slowly increase his gain

if score = 100
decrease the gain of the old music
play the new sound but slowly increase his gain

So i tried many things, but everytime i have the same problem, the transition between my old and new music dont works

GML:
if (score_ < 200){
    if play_next = false {//this is to first descrease the gain of the played musci
        audio_sound_gain(name_sound_played, 0, 2000);}//descrease the gain of the played music
    if audio_sound_get_gain(name_sound_played) = 0 && play_next = false  {
            audio_stop_sound(name_sound_played);//stop the sound played
        play_next = true;}
    if (play_next = true && !audio_is_playing(name_sound_played)){
        name_sound_played = audio_play_sound(snd_1,1,true);//play the music i want if score <200
        audio_sound_gain(name_sound_played, 0, 0)
        audio_sound_gain(name_sound_played, 1, 3000)}}//This is to slowly increase the gain


if (score_ >= 200 && score_ < 500){}
Can you help me?
 

Sawyer

Member
I find a way, it's a bit dirty and it will be long to write all because i have a lot of musics (see the code below).
However i need to find an other way to stop the current music playing actually i stop manually with : audio_stop_sound(the specific sound)

GML:
if (score_ < 200){
    audio_stop_sound(snd_1);
if !audio_is_playing(name_sound_played) {
    name_sound_played = audio_play_sound(snd_0,1,true);
    audio_sound_gain(name_sound_played,0,0)
    audio_sound_gain(name_sound_played,1,3000)
    }}


if (score_ >= 200 && score_ < 500){
    audio_stop_sound(snd_0);
    audio_stop_sound(snd_2);
if !audio_is_playing(name_sound_played) {
    name_sound_played = audio_play_sound(snd_1,1,true);
    audio_sound_gain(name_sound_played,0,0)
    audio_sound_gain(name_sound_played,1,3000)
    }}

if (score_ >= 500 && score_ < 750){
    audio_stop_sound(snd_1);
    audio_stop_sound(snd_3);
if !audio_is_playing(name_sound_played) {
    name_sound_played = audio_play_sound(snd_2,1,true);
    audio_sound_gain(name_sound_played,0,0)
    audio_sound_gain(name_sound_played,1,3000)
    }}
 
Top