Create an object (named music_controller, or what you like).
Now, we should add the playlist by adding this in the create event:
//Lets make an array (the playlist) by adding lines like this
playlist[1] = music1;
playlist[2] = music2;
playlist[3] = music3;
playlist[..] = music..;
last_played = -1; //This will hold the last played track
Also, the array called playlist will hold all the tracks that can be played.
Now, run this code to play another track
if(last_played == -1) { //No track has been played ago
n = ceil(random(3)) //Replace 3 with the number of tracks
last_played = n;
sound_play(playlist[n]);
} else
if(!sound_isplaying(playlist[last_played])) {
n = ceil(random(3)) //Replace 3...
if(last_played != n) {
last_played = n;
sound_play(playlist[n]);
}
}
Add this object to the rooms you want the random music in, and you're done!
.
Users logged in:
Comments
Loading comments...