Skip to content

Commit

Permalink
wow functioning bgm changer
Browse files Browse the repository at this point in the history
  • Loading branch information
Potato22 committed Sep 8, 2023
1 parent f0f0fd5 commit a4fda0a
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 28 deletions.
Binary file modified assets/audio/lq/dv-i_instinct_abyss_bitcrush.ogg
Binary file not shown.
Binary file modified assets/audio/lq/dv-i_logo_bitcrush.ogg
Binary file not shown.
Binary file not shown.
82 changes: 56 additions & 26 deletions assets/js/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ $(() => {
console.log('buttonData= ' + buttonData, 'buttonInherit=', buttonInherit, 'subButtonData=', subButtonData, 'toggle=', toggle, 'toggleData=', toggleData)
setTimeout(() => {
buttonEvent()
bgmChanger()
}, 100);
switch (buttonData) {
case "apply":
Expand Down Expand Up @@ -102,8 +101,12 @@ $(() => {
$('[toggleData = "dark"]').toggleClass('toggleON')
darkBoolean = $('[toggleData = "dark"]').hasClass('toggleON')
if (darkBoolean == true) {
bgmDefault = bgm1
bgmChanger(1)
$('.darkFilter').attr('dark', "true")
} else {
bgmDefault = bgm4
bgmChanger(0)
$('.darkFilter').attr('dark', "false")
}
break;
Expand Down Expand Up @@ -147,6 +150,11 @@ $(() => {
setTimeout(() => {
sceneEnter();
}, enterDelay);
if (darkBoolean == true) {
bgmChanger(5)
} else {
bgmChanger(3)
}
break;
case "gameData":
console.log('scene', buttonData);
Expand Down Expand Up @@ -190,7 +198,7 @@ $(() => {
prevSceneName = ".initMenu"
sceneName = ".menuAudio"
scenePageName = "SETTINGS"
bgmReturn()
bgmChanger(0)
break;
case "gameData":
prevSceneName = ".initMenu"
Expand Down Expand Up @@ -319,36 +327,58 @@ $(() => {
$('#screenOrnaments').removeClass('hideOrnaments');
}

function bgmChanger() {
function bgmChanger(bgmTarget) {
updateVolumeValues()
switch (buttonData) {
case "audio":
bgm.fade((exportBgmVal()), 0, 600)
setTimeout(() => {
console.log("changing to bgm", bgmTarget, "...")
bgm.fade((exportBgmVal()), 0, 600)
setTimeout(() => {
switch (bgmTarget) {
case 0:
bgm.stop()
bgm = bgmDefault
bgm.play()
bgm.fade(0, (exportBgmVal()), 300)
console.log("bgm", (exportBgmVal()))
break;
case 1:
bgm.stop()
bgm = bgm1
bgm.play()
bgm.fade(0, (exportBgmVal()), 300)
console.log("bgm", (exportBgmVal()))
break;
case 2:
bgm.stop()
bgm = bgm2
bgm.play()
bgm.fade(0, (exportBgmVal()), 300)
console.log("bgm", (exportBgmVal()))
}, 600);
break;
case "apply":
updateVolumeValues()
if (applyData =~ "audio") {
break
} else { bgm.fade((exportBgmVal()), 0, 300) }
break;
}
}
break;
case 3:
bgm.stop()
bgm = bgm3
bgm.play()
bgm.fade(0, (exportBgmVal()), 300)
console.log("bgm", (exportBgmVal()))
break;
case 4:
bgm.stop()
bgm = bgm4
bgm.play()
bgm.fade(0, (exportBgmVal()), 300)
console.log("bgm", (exportBgmVal()))
break;
case 5:
bgm.stop()
bgm = bgmS
bgm.play()
bgm.fade(0, (exportBgmVal()), 300)
console.log("bgm", (exportBgmVal()))
break;

function bgmReturn() {
console.log("returning to bgm1...")
setTimeout(() => {
bgm.stop()
bgm = bgm1
bgm.play()
bgm.fade(0, (exportBgmVal()), 300)
console.log("bgm", (exportBgmVal()))
}, 300);
default:
break;
}
}, 600);
}
})
10 changes: 8 additions & 2 deletions assets/js/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ const bgm2 = new Howl({
volume: bgmVol
})
const bgm3 = new Howl({
src: ['assets/audio/lq/salsaverde.ogg'],
src: ['assets/audio/lq/turn me on x modern life resample extended.ogg'],
loop: true,
volume: bgmVol
})
const bgm4 = new Howl({
src: ['assets/audio/lq/dv-i_logo_bitcrush.ogg'],
loop: true,
volume: bgmVol
})
Expand Down Expand Up @@ -51,4 +56,5 @@ const warning = new Howl({
src: ['assets/audio/lq/warning.ogg'],
volume: sfxVol
})
var bgm = bgm1
var bgmDefault = bgm4
var bgm = bgmDefault

0 comments on commit a4fda0a

Please sign in to comment.