Playing Random music

Game Editor comments and discussion.

Playing Random music

Postby trippola77 » Wed Jul 15, 2009 6:36 pm

How would I make a title play between two different songs randomly.

I used this (sound1 is a variable).

sound1=rand(2);

if(sound1=1)
{
playmusic..........blah blah
}

if(sound1=2)
{
palymusic...... blahh
}


but once i did it, it only played one song and the other one wouldnt play.
could you guys help
/
trippola77
 
Posts: 16
Joined: Sat Feb 09, 2008 12:05 am
Score: 0 Give a positive score

Re: Playing Random music

Postby skydereign » Wed Jul 15, 2009 7:45 pm

rand(2) picks a random number, in this case 0 or 1. So it is a random number not including the number in parenthesis It will never pick 2... Also the if statements, instead of =, they need ==
Code: Select all
sound1=rand(2);

if(sound1==1)
{
playmusic..........blah blah
}

if(sound1==2)
{
palymusic...... blahh
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest