You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
love2d-tank/Pause/PauseKeyPressed.lua

63 lines
1.3 KiB

function PauseKeyPressed(key)
if key == "escape" then
-- quickly return to the game
if not _G.MUTED then
musicBattle:setVolume(0.5)
musicPause:setVolume(0)
else
musicBattle:setVolume(0)
musicPause:setVolume(0)
end
_G.GAMESTATE = "GAME"
end
if key == "return" then
-- quickly return to the game
if not _G.MUTED then
musicBattle:setVolume(0.5)
musicPause:setVolume(0)
else
musicBattle:setVolume(0)
musicPause:setVolume(0)
end
-- 0 Return to game
-- 1 Quit
if PAUSE_POS == 0 then
-- unpause the game
_G.GAMESTATE = "GAME"
--print("STATE CHANEGD: GAME!")
_G.PAUSED = false
if not MUTED then
musicBattle:setVolume(0.5)
musicPause:setVolume(0)
else
musicBattle:setVolume(0)
musicPause:setVolume(0)
end
elseif PAUSE_POS == 1 then
_G.GAMESTATE = "MENU"
--print("STATE CHANEGD: MENU!")
_G.PAUSED = false
musicPause:stop()
musicBattle:stop()
elseif PAUSE_POS == 2 then
love.event.quit()
end
end
if love.keyboard.isDown("up") then
if _G.PAUSE_POS == 0 then
_G.PAUSE_POS = 0
else
_G.PAUSE_POS = _G.PAUSE_POS - 1
end
end
if love.keyboard.isDown("down") then
if _G.PAUSE_POS >= _G.PAUSE_MAX then
_G.PAUSE_POS = _G.PAUSE_MAX
else
_G.PAUSE_POS = _G.PAUSE_POS + 1
end
end
end