SFX and BGM are now separate sliders

This commit is contained in:
Ishaan Bhardwaj 2020-12-20 15:26:32 -05:00
parent f4675da0b0
commit 548612123a
3 changed files with 12 additions and 7 deletions

View File

@ -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

View File

@ -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

View File

@ -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)