SpelunkyFan wiki

scripts/startMusic.gml

From spelunky.gmk, Spelunky Classic 1.1's source, © 2008, 2009 Derek Yu and Mossmouth, LLC, shown whole under the Spelunky User License v1.1b. Extracted by spelunky.ai's tools, an unofficial fan project, one file per script or event; the // ==== lines are the extractor's, naming each action of the event. Some scripts are others' work that Derek Yu credits in the source's readme.txt: Martin Piecyk's platform engine, ChevyRay's view scaling scripts and tsg1zzn's Super Sound System.

The script startMusic, 80 lines of GML.

if (instance_exists(oLoadLevel)){    if (oLoadLevel.music == "LUSH")    {        playMusic(global.musLush, true);        SS_SetSoundVol(global.musLush, 2000 + 8000 * (global.musicVol/18));        SS_SetSoundFreq(global.musLush, 44100);    }    else if (oLoadLevel.music == "ICE")    {        playMusic(global.musIce, true);        SS_SetSoundVol(global.musIce, 2000 + 8000 * (global.musicVol/18));        SS_SetSoundFreq(global.musIce, 44100);    }    else if (oLoadLevel.music == "TEMPLE")    {        playMusic(global.musTemple, true);        SS_SetSoundVol(global.musTemple, 2000 + 8000 * (global.musicVol/18));        SS_SetSoundFreq(global.musTemple, 44100);    }    else if (oLoadLevel.music == "BOSS")    {        if (oPlayer1.active)        {            playMusic(global.musBoss, true);            SS_SetSoundVol(global.musBoss, 2000 + 8000 * (global.musicVol/18));            SS_SetSoundFreq(global.musBoss, 44100);        }    }    else    {        playMusic(global.musCave, true);        SS_SetSoundVol(global.musCave, 2000 + 8000 * (global.musicVol/18));        SS_SetSoundFreq(global.musCave, 44100);    }    }else if (isLevel()){    if (isRoom("rOlmec"))    {        if (oPlayer1.active)        {            playMusic(global.musBoss, true);            SS_SetSoundVol(global.musBoss, 2000 + 8000 * (global.musicVol/18));            SS_SetSoundFreq(global.musBoss, 44100);        }    }    else if (global.levelType == 1)    {        playMusic(global.musLush, true);        SS_SetSoundVol(global.musLush, 2000 + 8000 * (global.musicVol/18));        SS_SetSoundFreq(global.musLush, 44100);    }    else if (global.levelType == 2)    {        playMusic(global.musIce, true);        SS_SetSoundVol(global.musIce, 2000 + 8000 * (global.musicVol/18));        SS_SetSoundFreq(global.musIce, 44100);    }    else if (global.levelType == 3)    {        playMusic(global.musTemple, true);        SS_SetSoundVol(global.musTemple, 2000 + 8000 * (global.musicVol/18));        SS_SetSoundFreq(global.musTemple, 44100);    }    else    {        playMusic(global.musCave, true);        SS_SetSoundVol(global.musCave, 2000 + 8000 * (global.musicVol/18));        SS_SetSoundFreq(global.musCave, 44100);    }}else if (isRoom("rTitle")) SS_StopSound(global.musTitle);else if (isRoom("rSun") or isRoom("rMoon") or isRoom("rStars")){    playMusic(global.musBoss, true);    SS_SetSoundVol(global.musBoss, 2000 + 8000 * (global.musicVol/18));    SS_SetSoundFreq(global.musBoss, 44100);}