mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-22 10:59:01 -06:00
Unlock and fix BGM, add pause button
This commit is contained in:
parent
511e9592bc
commit
f4675da0b0
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -18,6 +18,7 @@ local configurable_inputs = {
|
||||
"rotate_180",
|
||||
"hold",
|
||||
"retry",
|
||||
"pause",
|
||||
}
|
||||
|
||||
local function newSetInputs()
|
||||
|
@ -18,6 +18,7 @@ function ModeSelectScene:new()
|
||||
end
|
||||
|
||||
function ModeSelectScene:update()
|
||||
switchBGM(nil) -- experimental
|
||||
end
|
||||
|
||||
function ModeSelectScene:render()
|
||||
|
Loading…
Reference in New Issue
Block a user