Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Candle on Thu 27/10/2005 08:09:21

Title: Random songs?
Post by: Candle on Thu 27/10/2005 08:09:21
I haven't tried it yet but was wondering if you can do them like you would do a random message or numbers?
So everytime they went into a room something else would play.
Title: Re: Random songs?
Post by: esper on Thu 27/10/2005 08:28:47
I've seen a couple other solved posts on this in the past couple days. I'm busy right now, or I'd find them for you, but it shouldn't be too hard.

My point for taking this post, though, was to ask why. If there's a good and logical reason, that's cool, but be careful that it doesn't sound disjointed to the player. Aesthetic value is one of the factors that keeps people playing.
Title: Re: Random songs?
Post by: Candle on Thu 27/10/2005 08:31:23
Well I was thinking for this main room the two chars will be in and and a lot of coming and going so maybe have diff tunes play.

EDIT:
This worked.

int blah = Random(3);
if (blah==0)PlayMusic(1);
else if (blah==1) PlayMusic(2);
else if (blah==2) PlayMusic(3);
else if (blah==3) PlayMusic(4); 
Title: Re: Random songs?
Post by: esper on Thu 27/10/2005 08:33:42
Actually, I seem to be full of crap. I just went looking for you and couldn't find anything, althoughI thought Mats Berglinn had a post about random music a week or so ago. I know how to do it, but I'm really busy right now or I'd prolly whp you up some code, but I'm sure someone wil come along any second now. It is pretty easy, if I remember correctly, so don't worry.
Title: Re: Random songs?
Post by: Ashen on Thu 27/10/2005 11:01:29
If, as in the example above, all the music files are grouped together, you could probably use:


int blah = Random(3) + 1; // Replace 1 with the lowest number you want to play (e.g. '+ 10' to play 10, 11, 12 or 13).
PlayMusic(blah);


No real difference, just saves you writing out a long list of else if's.
Title: Re: Random songs?
Post by: Candle on Thu 27/10/2005 18:46:36
Thanks Ashen.
Title: Re: Random songs?
Post by: Akumayo on Fri 28/10/2005 00:58:47
Using the Ultimate Randoms module, the files don't have to be in order, and you could run something like:
PlayMusic(RandomOfX(4, 3, 7, 11, 1));
Would play MUSIC3, MUSIC7, MUSIC11, or MUSIC1
Title: Re: Random songs?
Post by: Candle on Fri 28/10/2005 01:08:48
Thanks for pointing that out.