From 9182ae1642a750fd5a8a574a6bbd1a36c105d9d9 Mon Sep 17 00:00:00 2001 From: Fallstar Date: Fri, 23 May 2014 19:19:18 +0000 Subject: Music on menu + Mute button in Options. --- Gamestates/Config.lua | 13 +++++++++++++ Gamestates/Menu.lua | 7 +++++++ Gamestates/Multiplayer/InGame.lua | 6 ++++-- Gamestates/Solo.lua | 6 ++++-- TODO.odt | Bin 55329 -> 0 bytes main.lua | 2 ++ 6 files changed, 30 insertions(+), 4 deletions(-) delete mode 100644 TODO.odt diff --git a/Gamestates/Config.lua b/Gamestates/Config.lua index 394b115..a64650e 100644 --- a/Gamestates/Config.lua +++ b/Gamestates/Config.lua @@ -33,6 +33,8 @@ function Config:enter() Previous = "Gamestates/Menu" end + + function Config:update(dt) Gui.group.push{grow = "down", pos = {Utils.percentCoordinates(20, 20)}} Gui.Label{text = "Player name", size = {Utils.percentCoordinates(10, 10)}} @@ -40,9 +42,20 @@ function Config:update(dt) if Gui.Button{text = "Save", size = {Utils.percentCoordinates(60, 10)}} then love.filesystem.write( "userConfig", "PLAYERNAME: " .. Config.player_name.text) -- Write the new name to the config file end + if Gui.Button{text = "Mute", size = {Utils.percentCoordinates(40, 10)}} then + if Mute == false then + Mute = true + Menu.Music:stop() + else + Mute = false + Menu.Music:play() + end + end Gui.group.pop{} end + + -- Quickie's functions function Config:draw() Gui.core.draw() diff --git a/Gamestates/Menu.lua b/Gamestates/Menu.lua index 37e69a4..7a7b32c 100644 --- a/Gamestates/Menu.lua +++ b/Gamestates/Menu.lua @@ -46,6 +46,11 @@ function Menu:enter() Gui.core.style.color.active.bg[2] = 24 Gui.core.style.color.active.bg[3] = 24 -- End + Menu.Music = love.audio.newSource("Resources/BlueMind.ogg") + Menu.Music:setLooping(true) + if Mute == false then + Menu.Music:play() + end end function Menu:update(dt) @@ -62,4 +67,6 @@ function Menu:draw() Gui.core.draw() end + + return Menu diff --git a/Gamestates/Multiplayer/InGame.lua b/Gamestates/Multiplayer/InGame.lua index f94be12..20bf6c4 100644 --- a/Gamestates/Multiplayer/InGame.lua +++ b/Gamestates/Multiplayer/InGame.lua @@ -34,9 +34,11 @@ function InGame:enter(Local) -- Initialize or reset variables when entering game InGame:resize() -- Call the function filling the canvas InGame.Musiclowlife = love.audio.newSource("Resources/BlueMind midlife.ogg") - InGame.Music = love.audio.newSource("Resources/BlueMind.ogg") + InGame.Music = Menu.Music InGame.Music:setLooping(true) - InGame.Music:play() + if Mute == false then + InGame.Music:rewind() + end end function InGame:resize() -- Called in :enter() and when the window is resized diff --git a/Gamestates/Solo.lua b/Gamestates/Solo.lua index 7cd85da..3e19152 100644 --- a/Gamestates/Solo.lua +++ b/Gamestates/Solo.lua @@ -26,9 +26,11 @@ function Solo:enter() -- Initialize or reset variables when entering game Solo:resize() -- Call the function filling the canvas - Solo.Music = love.audio.newSource("Resources/BlueMind.ogg") + Solo.Music = Menu.Music Solo.Music:setLooping(true) - Solo.Music:play() + if Mute == false then + Solo.Music:rewind() + end end function Solo:resize() -- Called in :enter() and when the window is resized diff --git a/TODO.odt b/TODO.odt deleted file mode 100644 index 8d2a101..0000000 Binary files a/TODO.odt and /dev/null differ diff --git a/main.lua b/main.lua index b34509a..d94238b 100644 --- a/main.lua +++ b/main.lua @@ -8,6 +8,8 @@ require 'love2d-fakecanvas/fakecanvas' -- Load canvas emulation library Debug = false -- Set to true to view the answer in Solo mode +Mute = false + Screen = {} -- Contains window width and height Fonts = {} -- Used to store preloaded fonts -- cgit v1.2.3-54-g00ecf