Hullo.
Restarting is quite an integral part in my game. It is a one room game, and rather simple. Yet when the player restarts by pressing the space bar, it starts playing the music from the beginning again. However, I want the music to carry on playing. How can I get the game to restart without resetting the music, or can't I?
Thanks!
You can save the Music's position in a file and then seek it. Like this:
//before restarting the game
Musicpos=File.Open("Musicpos.dat", eFileWrite);
if (Musicpos == null)
Display("Error opening musicpos file.");
else {
Musicpos.WriteInt(GetMIDIPosition());
Musicpos.Close();
}
//at the start of the game (After PlayMusic(); )
if(File.Exists("Musicpos.dat")){
Musicpos=File.Open("Musicpos.dat", eFileRead);
if (Musicpos == null)
Display("Error opening musicpos file.");
else {
SeekMIDIPosition(Musicpos.ReadInt());
}
}
Remember to replace the "SeekMIDIPosition();" and the "GetMIDIPosition();" If you have a MP3 or MOD File. And you should Delete the Musicpos.dat file if the player quits the game.
There's also the Music Continuity Module by Andrew MacCormack, though I think it essentially does the same as NsMn already posted- just as a module.