From 548612123a515cc3375e61a0185519b74dae66f7 Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Sun, 20 Dec 2020 15:26:32 -0500 Subject: [PATCH] SFX and BGM are now separate sliders --- load/bgm.lua | 4 ++-- main.lua | 1 + scene/game_config.lua | 14 +++++++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/load/bgm.lua b/load/bgm.lua index 950a7a7..21aa1d2 100644 --- a/load/bgm.lua +++ b/load/bgm.lua @@ -47,7 +47,7 @@ function fadeoutBGM(time) end function resetBGMFadeout(time) - current_bgm:setVolume(config.sfx_volume) + current_bgm:setVolume(config.bgm_volume) fading_bgm = false current_bgm:play() end @@ -59,7 +59,7 @@ function processBGMFadeout(dt) fadeout_time = 0 fading_bgm = false end - current_bgm:setVolume(fadeout_time * config.sfx_volume / total_fadeout_time) + current_bgm:setVolume(fadeout_time * config.bgm_volume / total_fadeout_time) end end diff --git a/main.lua b/main.lua index 017b81b..5510529 100644 --- a/main.lua +++ b/main.lua @@ -18,6 +18,7 @@ function love.load() if not config.das then config.das = 10 end if not config.arr then config.arr = 2 end if not config.sfx_volume then config.sfx_volume = 0.5 end + if not config.bgm_volume then config.bgm_volume = 0.5 end if config.secret == nil then config.secret = false elseif config.secret == true then playSE("welcome") end diff --git a/scene/game_config.lua b/scene/game_config.lua index 955207f..42593a0 100644 --- a/scene/game_config.lua +++ b/scene/game_config.lua @@ -28,12 +28,14 @@ function ConfigScene:new() state = "Changing game settings", }) - self.sfxSlider = newSlider(290, 375, 400, config.sfx_volume * 100, 0, 100, function(v) config.sfx_volume = v / 100 end, {width=20}) + self.sfxSlider = newSlider(165, 375, 225, config.sfx_volume * 100, 0, 100, function(v) config.sfx_volume = v / 100 end, {width=20}) + self.bgmSlider = newSlider(465, 375, 225, config.bgm_volume * 100, 0, 100, function(v) config.bgm_volume = v / 100 end, {width=20}) end function ConfigScene:update() config["das_last_key"] = config.gamesettings.das_last_key == 2 self.sfxSlider:update() + self.bgmSlider:update() end function ConfigScene:render() @@ -43,10 +45,11 @@ function ConfigScene:render() 0, 0, 0, 0.5, 0.5 ) - - love.graphics.setFont(font_3x5_3) - love.graphics.print("Master Volume: " .. math.floor(self.sfxSlider:getValue()) .. "%", 80, 325) + love.graphics.setFont(font_3x5_3) + love.graphics.print("SFX Volume: " .. math.floor(self.sfxSlider:getValue()) .. "%", 70, 325) + love.graphics.print("BGM Volume: " .. math.floor(self.bgmSlider:getValue()) .. "%", 370, 325) + love.graphics.setFont(font_3x5_4) love.graphics.print("GAME SETTINGS", 80, 40) @@ -62,9 +65,10 @@ function ConfigScene:render() love.graphics.printf(setting, 100 + 110 * j, 100 + i * 20, 100, "center") end end - + love.graphics.setColor(1, 1, 1, 0.75) self.sfxSlider:draw() + self.bgmSlider:draw() end function ConfigScene:onInputPress(e)