Unlock and fix BGM, add pause button

pull/13/head
Ishaan Bhardwaj 2020-12-20 15:08:53 -05:00
parent 511e9592bc
commit f4675da0b0
4 changed files with 14 additions and 4 deletions

View File

@ -6,7 +6,7 @@ bgm = {
}
local current_bgm = nil
local bgm_locked = true
local bgm_locked = false
function switchBGM(sound, subsound)
if bgm_locked then return end
@ -47,7 +47,7 @@ function fadeoutBGM(time)
end
function resetBGMFadeout(time)
current_bgm:setVolume(1)
current_bgm:setVolume(config.sfx_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 / total_fadeout_time)
current_bgm:setVolume(fadeout_time * config.sfx_volume / total_fadeout_time)
end
end

View File

@ -22,6 +22,7 @@ function GameScene:new(game_mode, ruleset)
rotate_180=false,
hold=false,
}
self.paused = false
DiscordRPC:update({
details = self.game.rpc_details,
state = self.game.name,
@ -29,7 +30,7 @@ function GameScene:new(game_mode, ruleset)
end
function GameScene:update()
if love.window.hasFocus() then
if love.window.hasFocus() and not self.paused then
local inputs = {}
for input, value in pairs(self.inputs) do
inputs[input] = value
@ -72,6 +73,9 @@ function GameScene:render()
if config.gamesettings.display_gamemode == 1 then
love.graphics.printf(self.game.name .. " - " .. self.ruleset.name, 0, 460, 640, "left")
end
love.graphics.setFont(font_3x5_3)
if self.paused then love.graphics.print("PAUSED!", 80, 100) end
end
function GameScene:onInputPress(e)
@ -82,6 +86,10 @@ function GameScene:onInputPress(e)
scene = e.input == "retry" and GameScene(self.retry_mode, self.retry_ruleset) or ModeSelectScene()
elseif e.input == "retry" then
scene = GameScene(self.retry_mode, self.retry_ruleset)
elseif e.input == "pause" and not (self.game.game_over or self.game.completed) then
if not self.paused then pauseBGM()
else resumeBGM() end
self.paused = not self.paused
elseif e.input == "menu_back" then
scene = ModeSelectScene()
elseif e.input and string.sub(e.input, 1, 5) ~= "menu_" then

View File

@ -18,6 +18,7 @@ local configurable_inputs = {
"rotate_180",
"hold",
"retry",
"pause",
}
local function newSetInputs()

View File

@ -18,6 +18,7 @@ function ModeSelectScene:new()
end
function ModeSelectScene:update()
switchBGM(nil) -- experimental
end
function ModeSelectScene:render()