ok, been working on this all night and here is what we have so far (we have some code commented out so we don't lose it in case this didn't work). We added in some code to try to stop a song after 60 seconds of playing just to see if we could stop a song from playing. The pattern that it should do is play in this order:
2 min silence
PvPupbeat for 60 sec
2 min silence
PvPambientV1 for 60 sec
2 min silence
PvPdownbeat for 60 sec
Loop
Here is our code:
Variables:
Code:
MusicTheme mt_PvPmusic ; // this is the pvpisland.world music
/*MusicTheme mt_Ambient ; //this is the pvpisland.world ambient sound
Bool bAmbientPlaying=false; //don't play the mt_Ambient theme while loading the game*/
Int musicSongCounter; //counts the number of songs
Flt musicSilencePointer; //points to the song currently playing
Flt musicSilenceLength; //length of time to stop and start silence
Flt songTimePointer; //song time counter
Flt songTimeLength; //tells the length of time to play a song
Bool bInSilence=false; //we are not in silence mode
In InitGame:
Code:
if(!mt_PvPmusic.songs()) // create 'mt_PvPmusic' theme if not yet created
{
mt_PvPmusic+="music/PvPupbeat.ogg"; // add "PvPupbeat.ogg" track to 'mt_PvPmusic' theme
mt_PvPmusic+="music/PvPambientV1.ogg"; //add "PvPambientV2.ogg" track to 'mt_PvPmusic' theme
mt_PvPmusic+="music/PvPdownbeat.ogg"; // add "PvPdownbeat.ogg" track to 'mt_PvPmusic' theme
}
/*if(!mt_Ambient.songs()) //create 'mt_Ambient' theme if not yet created
{
mt_Ambient+="music/PvPambientV2.ogg"; //add PvPambientV2.ogg to 'mt_Ambient' theme
}
Music.play(mt_Ambient);*/
musicSilenceLength=120.0; //silence with no music for 120 frames
songTimeLength=60.0; //play music for 60 seconds
bInSilence=true;//we are in silence mode
return true;
}
In UpdateGame:
Code:
if(bInSilence)
{
musicSilencePointer += Time.d();
if(musicSilencePointer>=musicSilenceLength)
{
musicSilencePointer=0;
Music.play(mt_PvPmusic,musicSongCounter);
bInSilence=false;
}
}
else
{
songTimePointer += Time.d();
if(songTimePointer>=songTimeLength)
{
songTimePointer=0;
musicSongCounter++;
if(musicSongCounter>mt_PvPmusic.songs())
musicSongCounter=0;
Music.set(NULL);
bInSilence=true;
}
The result we have now is a definite pattern, but a pattern that makes no sense. Here is the pattern of music/silence we are getting:
initial 2 min silence upon game initiation, then:
PvPdownbeat in it's entirety
8 sec silence
PvPdownbeat in it's entirety
8 sec silence
PvPAmbientV1 for 1:39
40 sec silence
PvPupbeat in it's entirety
1:24 silence
This exact pattern repeats over and over. We are completely lost as to the random timing issues as well as why PvPdownbeat and 8 sec silence plays twice in a row.
Esenthel, is there an easier way to do this? lol